Merge pull request #13105 from ArtemDzhereleiko/AD/imp/color-settings-panel/tab-validation

Color settings panel tab validation
This commit is contained in:
Igor Kulikov 2025-04-08 16:10:29 +03:00 committed by GitHub
commit 79f7c6c21b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View File

@ -110,8 +110,28 @@ export class ColorSettingsPanelComponent extends PageComponent implements OnInit
this.colorSettingsFormGroup.get('type').valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => {
this.updateValidators();
setTimeout(() => {this.popover?.updatePosition();}, 0);
});
this.updateValidators();
}
updateValidators() {
const type: ColorType = this.colorSettingsFormGroup.get('type').value;
this.colorSettingsFormGroup.get('gradient').disable({emitEvent: false});
this.colorSettingsFormGroup.get('rangeList').disable({emitEvent: false});
this.colorSettingsFormGroup.get('colorFunction').disable({emitEvent: false});
switch (type) {
case ColorType.gradient:
this.colorSettingsFormGroup.get('gradient').enable({emitEvent: false});
break;
case ColorType.range:
this.colorSettingsFormGroup.get('rangeList').enable({emitEvent: false});
break;
case ColorType.function:
this.colorSettingsFormGroup.get('colorFunction').enable({emitEvent: false});
break;
}
}
copyColorSettings(comp: ColorSettingsComponent) {
@ -131,7 +151,7 @@ export class ColorSettingsPanelComponent extends PageComponent implements OnInit
}
applyColorSettings() {
const colorSettings = this.colorSettingsFormGroup.value;
const colorSettings: ColorSettings = this.colorSettingsFormGroup.getRawValue();
this.colorSettingsApplied.emit(colorSettings);
}

View File

@ -101,7 +101,7 @@ export class DataLayerColorSettingsPanelComponent extends PageComponent implemen
}
applyColorSettings() {
const colorSettings: DataLayerColorSettings = this.colorSettingsFormGroup.value;
const colorSettings: DataLayerColorSettings = this.colorSettingsFormGroup.getRawValue();
this.colorSettingsApplied.emit(colorSettings);
}
@ -122,8 +122,15 @@ export class DataLayerColorSettingsPanelComponent extends PageComponent implemen
const type: DataLayerColorType = this.colorSettingsFormGroup.get('type').value;
if (type === DataLayerColorType.range) {
this.colorSettingsFormGroup.get('rangeKey').enable({emitEvent: false});
this.colorSettingsFormGroup.get('range').enable({emitEvent: false});
} else {
this.colorSettingsFormGroup.get('rangeKey').disable({emitEvent: false});
this.colorSettingsFormGroup.get('range').disable({emitEvent: false});
}
if (type === DataLayerColorType.function) {
this.colorSettingsFormGroup.get('colorFunction').enable({emitEvent: false});
} else {
this.colorSettingsFormGroup.get('colorFunction').disable({emitEvent: false});
}
}
}