Merge pull request #13104 from vvlladd28/bug/updated-datasource/dity-state
Fixed twice call registerOnChanges in datasources component
This commit is contained in:
commit
71f7f5d857
@ -150,7 +150,8 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
|
|||||||
|
|
||||||
datasourcesMode: DatasourceType;
|
datasourcesMode: DatasourceType;
|
||||||
|
|
||||||
private propagateChange = (_val: any) => {};
|
private propagateChange: (value: any) => void;
|
||||||
|
private propagateChangePending = false;
|
||||||
|
|
||||||
constructor(private fb: UntypedFormBuilder,
|
constructor(private fb: UntypedFormBuilder,
|
||||||
private utils: UtilsService,
|
private utils: UtilsService,
|
||||||
@ -161,7 +162,7 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
|
|||||||
|
|
||||||
registerOnChange(fn: any): void {
|
registerOnChange(fn: any): void {
|
||||||
this.propagateChange = fn;
|
this.propagateChange = fn;
|
||||||
if (this.validate(null)) {
|
if (this.propagateChangePending) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value);
|
this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value);
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -227,7 +228,7 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
|
|||||||
if (this.singleDatasource && !this.datasourcesFormArray.length) {
|
if (this.singleDatasource && !this.datasourcesFormArray.length) {
|
||||||
this.addDatasource(false);
|
this.addDatasource(false);
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed || this.validate(null)) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value);
|
this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value);
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -329,7 +330,12 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
|
|||||||
if (this.datasourcesOptional) {
|
if (this.datasourcesOptional) {
|
||||||
datasources = datasources ? datasources.filter(d => datasourceValid(d)) : [];
|
datasources = datasources ? datasources.filter(d => datasourceValid(d)) : [];
|
||||||
}
|
}
|
||||||
this.propagateChange(datasources);
|
if (this.propagateChange) {
|
||||||
|
this.propagateChange(datasources);
|
||||||
|
this.propagateChangePending = false;
|
||||||
|
} else {
|
||||||
|
this.propagateChangePending = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onDatasourceDrop(event: CdkDragDrop<string[]>) {
|
public onDatasourceDrop(event: CdkDragDrop<string[]>) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user