Update new Filter and Branch Selector Changes from ISA-Integration

This commit is contained in:
Nino
2023-05-22 17:26:15 +02:00
parent 2a442dde85
commit 4b7c26b009
5 changed files with 47 additions and 10 deletions

View File

@@ -25,18 +25,31 @@ export class OrderBranchIdInputComponent extends AbstractUiFilterInputDirective
ngOnInit() {
this.control.setValue({ id: Number(this.value) });
const uiInputChangesSub = this.uiInput?.changes?.subscribe((changes) => {
const controlValue = this.control?.value?.id;
const changesValue = Number(changes?.target?.value);
if (controlValue !== changesValue) {
this.control.setValue(changesValue && !isNaN(changesValue) ? { id: changesValue } : undefined);
}
});
const onInputChangeSub = this.onUiInputChange$.subscribe((input) => {
if (this.control.value !== input.value) {
this.control.setValue(input.value ? { id: Number(input.value) } : undefined);
const controlValue = this.control?.value?.id;
const inputValue = Number(input?.value);
if (controlValue !== inputValue) {
this.control.setValue(inputValue && !isNaN(inputValue) ? { id: inputValue } : undefined);
}
});
const onControlValueChangeSub = this.control.valueChanges.subscribe((value) => {
if (this.value !== value) {
this.setValue(value ? String(value?.id) : undefined);
if (!value) {
this.setValue(undefined);
} else if (this.value !== String(value?.id)) {
this.setValue(String(value?.id));
}
});
this._subscriptions.add(uiInputChangesSub);
this._subscriptions.add(onInputChangeSub);
this._subscriptions.add(onControlValueChangeSub);
}

View File

@@ -207,14 +207,18 @@ export class BranchSelectorComponent implements OnInit, OnDestroy, AfterViewInit
clear() {
this.setBranch();
this.emitValues();
this.complete.next('');
this.onChange(undefined);
this.onTouched();
this.valueChange.emit(undefined);
}
emitValues(branch?: BranchDTO) {
this.onChange(branch);
this.onTouched();
this.valueChange.emit(branch);
if (!!branch) {
this.onChange(branch);
this.onTouched();
this.valueChange.emit(branch);
}
}
closeAndClearAutocomplete() {

View File

@@ -22,6 +22,12 @@ export class FilterInputTextComponent extends AbstractUiFilterInputDirective imp
this.control.setValue(this.value);
this.updateValidator();
const uiInputChangesSub = this.uiInput?.changes?.subscribe((changes) => {
if (this.control.value !== changes?.target?.value) this.control.setValue(changes?.target?.value);
this.updateValidator();
});
const onInputChangeSub = this.onUiInputChange$.subscribe((input) => {
if (this.control.value !== input.value) this.control.setValue(input.value);
@@ -32,6 +38,7 @@ export class FilterInputTextComponent extends AbstractUiFilterInputDirective imp
if (this.value !== value) this.setValue(value);
});
this._subscriptions.add(uiInputChangesSub);
this._subscriptions.add(onInputChangeSub);
this._subscriptions.add(onControlValueChangeSub);
}

View File

@@ -203,10 +203,16 @@ export class Filter implements IFilter {
unselectAll() {
this.filter?.forEach((uiInputGroup) =>
uiInputGroup?.input?.forEach((uiInput) => uiInput?.options?.values?.forEach((uiOption) => uiOption?.setSelected(undefined)))
uiInputGroup?.input?.forEach((uiInput) => {
uiInput?.setSelected(undefined);
uiInput?.setValue(undefined);
})
);
this.input?.forEach((uiInputGroup) =>
uiInputGroup?.input?.forEach((uiInput) => uiInput?.options?.values?.forEach((uiOption) => uiOption?.setSelected(undefined)))
uiInputGroup?.input?.forEach((uiInput) => {
uiInput?.setSelected(undefined);
uiInput?.setValue(undefined);
})
);
}

View File

@@ -22,6 +22,12 @@ export class UiFilterInputTextComponent extends AbstractUiFilterInputDirective i
this.control.setValue(this.value);
this.updateValidator();
const uiInputChangesSub = this.uiInput?.changes?.subscribe((changes) => {
if (this.control.value !== changes?.target?.value) this.control.setValue(changes?.target?.value);
this.updateValidator();
});
const onInputChangeSub = this.onUiInputChange$.subscribe((input) => {
if (this.control.value !== input.value) this.control.setValue(input.value);
@@ -32,6 +38,7 @@ export class UiFilterInputTextComponent extends AbstractUiFilterInputDirective i
if (this.value !== value) this.setValue(value);
});
this._subscriptions.add(uiInputChangesSub);
this._subscriptions.add(onInputChangeSub);
this._subscriptions.add(onControlValueChangeSub);
}