UI: Fixed incorrect show widgets in layout

This commit is contained in:
Vladyslav_Prykhodko 2024-09-18 12:54:47 +03:00
parent 1f518cddbe
commit c217769e96
3 changed files with 7 additions and 3 deletions

View File

@ -66,7 +66,7 @@
</mat-menu>
<div [class]="dashboardClass" id="gridster-background">
<gridster #gridster id="gridster-child" [options]="gridsterOpts">
<gridster-item #gridsterItem [item]="widget" [class]="{'tb-noselect': isEdit}" *ngFor="let widget of dashboardWidgets">
<gridster-item #gridsterItem [item]="widget" [class]="{'tb-noselect': isEdit}" *ngFor="let widget of dashboardWidgets; trackBy: trackByWidgetId">
<tb-widget-container
[gridsterItem]="gridsterItem"
[widget]="widget"

View File

@ -558,6 +558,10 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
}
}
public trackByWidgetId(_index: number, widget: DashboardWidget) {
return widget.widgetId;
}
private scrollToWidget(widget: DashboardWidget, delay?: number) {
const parentElement = this.gridster.el as HTMLElement;
widget.gridsterItemComponent$().subscribe((gridsterItem) => {

View File

@ -707,7 +707,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
}
set x(x: number) {
if (!this.dashboard.isMobileSize) {
if (!this.dashboard.isMobileSize && this.dashboard.isEdit) {
if (this.widgetLayout) {
this.widgetLayout.col = x;
} else {
@ -728,7 +728,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
}
set y(y: number) {
if (!this.dashboard.isMobileSize) {
if (!this.dashboard.isMobileSize && this.dashboard.isEdit) {
if (this.widgetLayout) {
this.widgetLayout.row = y;
} else {