Commit 2eafc77cd4d55618ac8bb8d79349a23455ea671a
Committed by
GitHub
Merge pull request #4345 from vvlladd28/bug/widget-selector/filter-type
UI: Fixed didn't save widget type filter in widgets selector
Showing
2 changed files
with
11 additions
and
6 deletions
@@ -90,7 +90,6 @@ import { | @@ -90,7 +90,6 @@ import { | ||
90 | } from '@home/components/alias/entity-aliases-dialog.component'; | 90 | } from '@home/components/alias/entity-aliases-dialog.component'; |
91 | import { EntityAliases } from '@app/shared/models/alias.models'; | 91 | import { EntityAliases } from '@app/shared/models/alias.models'; |
92 | import { EditWidgetComponent } from '@home/components/dashboard-page/edit-widget.component'; | 92 | import { EditWidgetComponent } from '@home/components/dashboard-page/edit-widget.component'; |
93 | -import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; | ||
94 | import { | 93 | import { |
95 | AddWidgetDialogComponent, | 94 | AddWidgetDialogComponent, |
96 | AddWidgetDialogData | 95 | AddWidgetDialogData |
@@ -118,8 +117,7 @@ import { ComponentPortal } from '@angular/cdk/portal'; | @@ -118,8 +117,7 @@ import { ComponentPortal } from '@angular/cdk/portal'; | ||
118 | import { | 117 | import { |
119 | DISPLAY_WIDGET_TYPES_PANEL_DATA, | 118 | DISPLAY_WIDGET_TYPES_PANEL_DATA, |
120 | DisplayWidgetTypesPanelComponent, | 119 | DisplayWidgetTypesPanelComponent, |
121 | - DisplayWidgetTypesPanelData, | ||
122 | - WidgetTypes | 120 | + DisplayWidgetTypesPanelData |
123 | } from '@home/components/dashboard-page/widget-types-panel.component'; | 121 | } from '@home/components/dashboard-page/widget-types-panel.component'; |
124 | import { DashboardWidgetSelectComponent } from '@home/components/dashboard-page/dashboard-widget-select.component'; | 122 | import { DashboardWidgetSelectComponent } from '@home/components/dashboard-page/dashboard-widget-select.component'; |
125 | import {AliasEntityType, EntityType} from "@shared/models/entity-type.models"; | 123 | import {AliasEntityType, EntityType} from "@shared/models/entity-type.models"; |
@@ -1189,13 +1187,16 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC | @@ -1189,13 +1187,16 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC | ||
1189 | overlayRef.dispose(); | 1187 | overlayRef.dispose(); |
1190 | }); | 1188 | }); |
1191 | 1189 | ||
1190 | + const filterWidgetTypes = this.dashboardWidgetSelectComponent.filterWidgetTypes; | ||
1191 | + const widgetTypesList = Array.from(this.dashboardWidgetSelectComponent.widgetTypes.values()).map(type => { | ||
1192 | + return {type, display: filterWidgetTypes === null ? true : filterWidgetTypes.includes(type)}; | ||
1193 | + }); | ||
1194 | + | ||
1192 | const providers: StaticProvider[] = [ | 1195 | const providers: StaticProvider[] = [ |
1193 | { | 1196 | { |
1194 | provide: DISPLAY_WIDGET_TYPES_PANEL_DATA, | 1197 | provide: DISPLAY_WIDGET_TYPES_PANEL_DATA, |
1195 | useValue: { | 1198 | useValue: { |
1196 | - types: Array.from(this.dashboardWidgetSelectComponent.widgetTypes.values()).map(type => { | ||
1197 | - return {type, display: true}; | ||
1198 | - }), | 1199 | + types: widgetTypesList, |
1199 | typesUpdated: (newTypes) => { | 1200 | typesUpdated: (newTypes) => { |
1200 | this.filterWidgetTypes = newTypes.filter(type => type.display).map(type => type.type); | 1201 | this.filterWidgetTypes = newTypes.filter(type => type.display).map(type => type.type); |
1201 | } | 1202 | } |
@@ -77,6 +77,10 @@ export class DashboardWidgetSelectComponent implements OnInit { | @@ -77,6 +77,10 @@ export class DashboardWidgetSelectComponent implements OnInit { | ||
77 | this.filterWidgetTypes$.next(widgetTypes); | 77 | this.filterWidgetTypes$.next(widgetTypes); |
78 | } | 78 | } |
79 | 79 | ||
80 | + get filterWidgetTypes(): Array<widgetType> { | ||
81 | + return this.filterWidgetTypes$.value; | ||
82 | + } | ||
83 | + | ||
80 | @Output() | 84 | @Output() |
81 | widgetSelected: EventEmitter<WidgetInfo> = new EventEmitter<WidgetInfo>(); | 85 | widgetSelected: EventEmitter<WidgetInfo> = new EventEmitter<WidgetInfo>(); |
82 | 86 |