Browse Source
Merge pull request #11707 from vvlladd28/bug/updated-widzed-size-xy
Fixed incorrect show widgets in layout when active edit mode
pull/11725/head
Igor Kulikov
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
21 additions and
20 deletions
-
ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts
-
ui-ngx/src/app/modules/home/models/dashboard-component.models.ts
|
|
|
@ -248,8 +248,15 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo |
|
|
|
defaultItemCols: 8, |
|
|
|
defaultItemRows: 6, |
|
|
|
displayGrid: this.displayGrid, |
|
|
|
resizable: {enabled: this.isEdit && !this.isEditingWidget, delayStart: 50}, |
|
|
|
draggable: {enabled: this.isEdit && !this.isEditingWidget}, |
|
|
|
resizable: { |
|
|
|
enabled: this.isEdit && !this.isEditingWidget, |
|
|
|
delayStart: 50, |
|
|
|
stop: (_, itemComponent) => {(itemComponent.item as DashboardWidget).updatePosition(itemComponent.$item.x, itemComponent.$item.y);} |
|
|
|
}, |
|
|
|
draggable: { |
|
|
|
enabled: this.isEdit && !this.isEditingWidget, |
|
|
|
stop: (_, itemComponent) => {(itemComponent.item as DashboardWidget).updatePosition(itemComponent.$item.x, itemComponent.$item.y);} |
|
|
|
}, |
|
|
|
itemChangeCallback: () => this.dashboardWidgets.sortWidgets(), |
|
|
|
itemInitCallback: (_, itemComponent) => { |
|
|
|
(itemComponent.item as DashboardWidget).gridsterItemComponent = itemComponent; |
|
|
|
|
|
|
|
@ -706,15 +706,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { |
|
|
|
return Math.floor(res); |
|
|
|
} |
|
|
|
|
|
|
|
set x(x: number) { |
|
|
|
if (!this.dashboard.isMobileSize && this.dashboard.isEdit) { |
|
|
|
if (this.widgetLayout) { |
|
|
|
this.widgetLayout.col = x; |
|
|
|
} else { |
|
|
|
this.widget.col = x; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
set x(_: number) {} |
|
|
|
|
|
|
|
@enumerable(true) |
|
|
|
get y(): number { |
|
|
|
@ -727,15 +719,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { |
|
|
|
return Math.floor(res); |
|
|
|
} |
|
|
|
|
|
|
|
set y(y: number) { |
|
|
|
if (!this.dashboard.isMobileSize && this.dashboard.isEdit) { |
|
|
|
if (this.widgetLayout) { |
|
|
|
this.widgetLayout.row = y; |
|
|
|
} else { |
|
|
|
this.widget.row = y; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
set y(_: number) {} |
|
|
|
|
|
|
|
get preserveAspectRatio(): boolean { |
|
|
|
if (!this.dashboard.isMobileSize && this.widgetLayout) { |
|
|
|
@ -833,4 +817,14 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { |
|
|
|
} |
|
|
|
return order; |
|
|
|
} |
|
|
|
|
|
|
|
updatePosition(x: number, y: number) { |
|
|
|
if (this.widgetLayout) { |
|
|
|
this.widgetLayout.col = x; |
|
|
|
this.widgetLayout.row = y; |
|
|
|
} else { |
|
|
|
this.widget.col = x; |
|
|
|
this.widget.row = y; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|