Commit 2eafc77cd4d55618ac8bb8d79349a23455ea671a

Authored by Igor Kulikov
Committed by GitHub
2 parents d28312ef 74e20e2c

Merge pull request #4345 from vvlladd28/bug/widget-selector/filter-type

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