this.colorRangeControl(r))),
+ rangeList: [this.colorSettings?.rangeList, []],
colorFunction: [this.colorSettings?.colorFunction, []]
}
);
@@ -76,51 +76,15 @@ export class ColorSettingsPanelComponent extends PageComponent implements OnInit
});
}
- private colorRangeControl(range: ColorRange): AbstractControl {
- return this.fb.group({
- from: [range?.from, []],
- to: [range?.to, []],
- color: [range?.color, []]
- });
- }
-
- get rangeListFormArray(): UntypedFormArray {
- return this.colorSettingsFormGroup.get('rangeList') as UntypedFormArray;
- }
-
- get rangeListFormGroups(): FormGroup[] {
- return this.rangeListFormArray.controls as FormGroup[];
- }
-
- trackByRange(index: number, rangeControl: AbstractControl): any {
- return rangeControl;
- }
-
- removeRange(index: number) {
- this.rangeListFormArray.removeAt(index);
- this.colorSettingsFormGroup.markAsDirty();
- setTimeout(() => {this.popover?.updatePosition();}, 0);
- }
-
- addRange() {
- const newRange: ColorRange = {
- color: 'rgba(0,0,0,0.87)'
- };
- this.rangeListFormArray.push(this.colorRangeControl(newRange));
- this.colorSettingsFormGroup.markAsDirty();
- setTimeout(() => {this.popover?.updatePosition();}, 0);
- }
-
copyColorSettings(comp: ColorSettingsComponent) {
const sourceSettings = deepClone(comp.modelValue);
this.colorSettings = sourceSettings;
this.colorSettingsFormGroup.patchValue({
type: this.colorSettings.type,
color: this.colorSettings.color,
- colorFunction: this.colorSettings.colorFunction
+ colorFunction: this.colorSettings.colorFunction,
+ rangeList: this.colorSettings.rangeList || []
}, {emitEvent: false});
- this.colorSettingsFormGroup.setControl('rangeList',
- this.fb.array((this.colorSettings.rangeList || []).map(r => this.colorRangeControl(r))), {emitEvent: false});
this.colorSettingsFormGroup.markAsDirty();
}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts
index 4018549863..7c2022c5d4 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts
@@ -45,7 +45,12 @@ import {
} from '@home/components/widget/lib/settings/common/background-settings-panel.component';
import {
CountWidgetSettingsComponent
-} from "@home/components/widget/lib/settings/common/count-widget-settings.component";
+} from '@home/components/widget/lib/settings/common/count-widget-settings.component';
+import { ColorRangeListComponent } from '@home/components/widget/lib/settings/common/color-range-list.component';
+import { ColorRangePanelComponent } from '@home/components/widget/lib/settings/common/color-range-panel.component';
+import {
+ ColorRangeSettingsComponent, ColorRangeSettingsComponentService
+} from '@home/components/widget/lib/settings/common/color-range-settings.component';
@NgModule({
declarations: [
@@ -63,7 +68,10 @@ import {
ValueSourceComponent,
LegendConfigComponent,
WidgetFontComponent,
- CountWidgetSettingsComponent
+ CountWidgetSettingsComponent,
+ ColorRangeListComponent,
+ ColorRangePanelComponent,
+ ColorRangeSettingsComponent
],
imports: [
CommonModule,
@@ -85,10 +93,14 @@ import {
ValueSourceComponent,
LegendConfigComponent,
WidgetFontComponent,
- CountWidgetSettingsComponent
+ CountWidgetSettingsComponent,
+ ColorRangeListComponent,
+ ColorRangePanelComponent,
+ ColorRangeSettingsComponent
],
providers: [
- ColorSettingsComponentService
+ ColorSettingsComponentService,
+ ColorRangeSettingsComponentService
]
})
export class WidgetSettingsCommonModule {