From 3253a18ab14b52aced1b3a11bf8b2a47c99b94d8 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 19 Sep 2024 18:06:35 +0300 Subject: [PATCH 1/3] UI: Fixed incorrect show widgets in layout when active edit mode --- .../dashboard/dashboard.component.ts | 11 +++++-- .../home/models/dashboard-component.models.ts | 30 ++++++++----------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts index 46255cfc57..36d4c17285 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.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).updatedXY(itemComponent.$item.x, itemComponent.$item.y);} + }, + draggable: { + enabled: this.isEdit && !this.isEditingWidget, + stop: (_, itemComponent) => {(itemComponent.item as DashboardWidget).updatedXY(itemComponent.$item.x, itemComponent.$item.y);} + }, itemChangeCallback: () => this.dashboardWidgets.sortWidgets(), itemInitCallback: (_, itemComponent) => { (itemComponent.item as DashboardWidget).gridsterItemComponent = itemComponent; diff --git a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts index 19838773cf..1c4e6167f9 100644 --- a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts @@ -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; } + + updatedXY(x: number, y: number) { + if (this.widgetLayout) { + this.widgetLayout.col = x; + this.widgetLayout.row = y; + } else { + this.widget.col = x; + this.widget.row = y; + } + } } From e4f3f41558523aeb8bfd1f83f93a480b0e08f8a7 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 19 Sep 2024 19:02:04 +0300 Subject: [PATCH 2/3] Update dashboard.component.ts --- .../modules/home/components/dashboard/dashboard.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts index 36d4c17285..cb60b5338c 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts @@ -251,11 +251,11 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo resizable: { enabled: this.isEdit && !this.isEditingWidget, delayStart: 50, - stop: (_, itemComponent) => {(itemComponent.item as DashboardWidget).updatedXY(itemComponent.$item.x, itemComponent.$item.y);} + 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).updatedXY(itemComponent.$item.x, itemComponent.$item.y);} + stop: (_, itemComponent) => {(itemComponent.item as DashboardWidget).updatePosition(itemComponent.$item.x, itemComponent.$item.y);} }, itemChangeCallback: () => this.dashboardWidgets.sortWidgets(), itemInitCallback: (_, itemComponent) => { From da3cc282df37f892c9b9af39d8a7fdb8e0544f7f Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 19 Sep 2024 19:03:18 +0300 Subject: [PATCH 3/3] Update dashboard-component.models.ts --- .../src/app/modules/home/models/dashboard-component.models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts index 1c4e6167f9..65c6c23004 100644 --- a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts @@ -818,7 +818,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { return order; } - updatedXY(x: number, y: number) { + updatePosition(x: number, y: number) { if (this.widgetLayout) { this.widgetLayout.col = x; this.widgetLayout.row = y;