Skip to content
Snippets Groups Projects
Commit e9e41af7 authored by jojohoch's avatar jojohoch
Browse files

Remove unused code from FormElementComponent

parent 88949a19
No related branches found
No related tags found
No related merge requests found
......@@ -14,14 +14,13 @@ export abstract class FormElementComponent extends ElementComponent implements O
@Output() elementValueChanged = new EventEmitter<ValueChangeElement>();
@Output() setValidators = new EventEmitter<ValidatorFn[]>();
parentForm!: FormGroup;
defaultValue!: InputElementValue;
elementFormControl!: FormControl;
private ngUnsubscribe = new Subject<void>();
ngOnInit(): void {
this.elementFormControl = this.formControl;
this.updateFormValue((this.elementModel as InputElement).value);
this.elementFormControl?.setValue((this.elementModel as InputElement).value, { emitEvent: false });
this.setValidators.emit(this.validators);
this.elementFormControl.valueChanges
.pipe(
......@@ -30,9 +29,7 @@ export abstract class FormElementComponent extends ElementComponent implements O
takeUntil(this.ngUnsubscribe)
)
.subscribe(([prevValue, nextValue]: [InputElementValue, InputElementValue]) => {
if (nextValue != null) { // invalid input on number fields generates event with null TODO find a better solution
this.elementValueChanged.emit({ id: this.elementModel.id, values: [prevValue, nextValue] });
}
this.elementValueChanged.emit({ id: this.elementModel.id, values: [prevValue, nextValue] });
});
}
......@@ -51,10 +48,6 @@ export abstract class FormElementComponent extends ElementComponent implements O
new FormControl({});
}
updateFormValue(newValue: InputElementValue): void {
this.elementFormControl?.setValue(newValue, { emitEvent: false });
}
ngOnDestroy(): void {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment