Commit db48d900ae193b4dd96361fad215468eaed9b999
Committed by
GitHub
Merge pull request #5170 from vvlladd28/bug/widget-bundle-select
UI: When clicking the button "Show on widget", the default widget bun…
Showing
3 changed files
with
19 additions
and
12 deletions
@@ -112,8 +112,8 @@ | @@ -112,8 +112,8 @@ | ||
112 | fxFlex | 112 | fxFlex |
113 | [selectFirstBundle]="false" | 113 | [selectFirstBundle]="false" |
114 | [selectBundleAlias]="selectedWidgetsBundleAlias" | 114 | [selectBundleAlias]="selectedWidgetsBundleAlias" |
115 | - [(ngModel)]="widgetsBundle" | ||
116 | - (ngModelChange)="onWidgetsBundleChanged()"> | 115 | + [ngModel]="null" |
116 | + (ngModelChange)="onWidgetsBundleChanged($event)"> | ||
117 | </tb-widgets-bundle-select> | 117 | </tb-widgets-bundle-select> |
118 | </div> | 118 | </div> |
119 | <button mat-raised-button [fxShow]="widgetsList.length > 0" | 119 | <button mat-raised-button [fxShow]="widgetsList.length > 0" |
@@ -245,11 +245,11 @@ | @@ -245,11 +245,11 @@ | ||
245 | </ngx-hm-carousel> | 245 | </ngx-hm-carousel> |
246 | <span translate *ngIf="mode === 'widget' && widgetsLoaded && | 246 | <span translate *ngIf="mode === 'widget' && widgetsLoaded && |
247 | widgetsList.length === 0 && | 247 | widgetsList.length === 0 && |
248 | - widgetsBundle" | 248 | + widgetBundleSet" |
249 | fxFlex fxLayoutAlign="center center" | 249 | fxFlex fxLayoutAlign="center center" |
250 | style="display: flex;" | 250 | style="display: flex;" |
251 | class="mat-headline">widgets-bundle.empty</span> | 251 | class="mat-headline">widgets-bundle.empty</span> |
252 | - <span translate *ngIf="mode === 'widget' && !widgetsBundle" | 252 | + <span translate *ngIf="mode === 'widget' && !widgetBundleSet" |
253 | fxFlex fxLayoutAlign="center center" | 253 | fxFlex fxLayoutAlign="center center" |
254 | style="display: flex;" | 254 | style="display: flex;" |
255 | class="mat-headline">widget.select-widgets-bundle</span> | 255 | class="mat-headline">widget.select-widgets-bundle</span> |
@@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
17 | import { | 17 | import { |
18 | AfterViewInit, | 18 | AfterViewInit, |
19 | ChangeDetectionStrategy, | 19 | ChangeDetectionStrategy, |
20 | + ChangeDetectorRef, | ||
20 | Component, | 21 | Component, |
21 | ElementRef, | 22 | ElementRef, |
22 | Injector, | 23 | Injector, |
@@ -118,7 +119,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -118,7 +119,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
118 | viewsInited = false; | 119 | viewsInited = false; |
119 | 120 | ||
120 | selectedWidgetsBundleAlias: string = null; | 121 | selectedWidgetsBundleAlias: string = null; |
121 | - widgetsBundle: WidgetsBundle = null; | 122 | + widgetBundleSet = false; |
122 | widgetsLoaded = false; | 123 | widgetsLoaded = false; |
123 | widgetsCarouselIndex = 0; | 124 | widgetsCarouselIndex = 0; |
124 | widgetsList: Array<Array<Widget>> = []; | 125 | widgetsList: Array<Array<Widget>> = []; |
@@ -182,7 +183,8 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -182,7 +183,8 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
182 | private utils: UtilsService, | 183 | private utils: UtilsService, |
183 | private dashboardUtils: DashboardUtilsService, | 184 | private dashboardUtils: DashboardUtilsService, |
184 | private widgetService: WidgetService, | 185 | private widgetService: WidgetService, |
185 | - private zone: NgZone) { | 186 | + private zone: NgZone, |
187 | + private cd: ChangeDetectorRef) { | ||
186 | super(store); | 188 | super(store); |
187 | this.dirtyValue = !this.activeValue; | 189 | this.dirtyValue = !this.activeValue; |
188 | const sortOrder: SortOrder = { property: 'key', direction: Direction.ASC }; | 190 | const sortOrder: SortOrder = { property: 'key', direction: Direction.ASC }; |
@@ -380,8 +382,8 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -380,8 +382,8 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
380 | this.widgetsList = []; | 382 | this.widgetsList = []; |
381 | this.widgetsListCache = []; | 383 | this.widgetsListCache = []; |
382 | this.widgetsLoaded = false; | 384 | this.widgetsLoaded = false; |
385 | + this.widgetBundleSet = false; | ||
383 | this.widgetsCarouselIndex = 0; | 386 | this.widgetsCarouselIndex = 0; |
384 | - this.widgetsBundle = null; | ||
385 | this.selectedWidgetsBundleAlias = 'cards'; | 387 | this.selectedWidgetsBundleAlias = 'cards'; |
386 | 388 | ||
387 | const entityAlias: EntityAlias = { | 389 | const entityAlias: EntityAlias = { |
@@ -440,15 +442,16 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -440,15 +442,16 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
440 | } | 442 | } |
441 | } | 443 | } |
442 | 444 | ||
443 | - onWidgetsBundleChanged() { | 445 | + onWidgetsBundleChanged(widgetsBundle: WidgetsBundle) { |
446 | + this.widgetBundleSet = !!widgetsBundle; | ||
444 | if (this.mode === 'widget') { | 447 | if (this.mode === 'widget') { |
445 | this.widgetsList = []; | 448 | this.widgetsList = []; |
446 | this.widgetsListCache = []; | 449 | this.widgetsListCache = []; |
447 | - this.widgetsCarouselIndex = 0; | ||
448 | - if (this.widgetsBundle) { | 450 | + this.widgetsCarouselIndex = 0; |
451 | + if (widgetsBundle) { | ||
449 | this.widgetsLoaded = false; | 452 | this.widgetsLoaded = false; |
450 | - const bundleAlias = this.widgetsBundle.alias; | ||
451 | - const isSystem = this.widgetsBundle.tenantId.id === NULL_UUID; | 453 | + const bundleAlias = widgetsBundle.alias; |
454 | + const isSystem = widgetsBundle.tenantId.id === NULL_UUID; | ||
452 | this.widgetService.getBundleWidgetTypes(bundleAlias, isSystem).subscribe( | 455 | this.widgetService.getBundleWidgetTypes(bundleAlias, isSystem).subscribe( |
453 | (widgetTypes) => { | 456 | (widgetTypes) => { |
454 | widgetTypes = widgetTypes.sort((a, b) => { | 457 | widgetTypes = widgetTypes.sort((a, b) => { |
@@ -486,6 +489,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -486,6 +489,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
486 | } | 489 | } |
487 | } | 490 | } |
488 | this.widgetsLoaded = true; | 491 | this.widgetsLoaded = true; |
492 | + this.cd.markForCheck(); | ||
489 | } | 493 | } |
490 | ); | 494 | ); |
491 | } | 495 | } |
@@ -140,6 +140,9 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni | @@ -140,6 +140,9 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni | ||
140 | this.widgetsBundle = found; | 140 | this.widgetsBundle = found; |
141 | this.updateView(); | 141 | this.updateView(); |
142 | } | 142 | } |
143 | + } else if (this.widgetsBundle) { | ||
144 | + this.widgetsBundle = null; | ||
145 | + this.updateView(); | ||
143 | } | 146 | } |
144 | } | 147 | } |
145 | 148 |