@schneideress/dashboardframework 20.0.9 → 20.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5207,11 +5207,67 @@ class RADashboardArea {
|
|
|
5207
5207
|
}
|
|
5208
5208
|
if (this.isSiteDetailDashboard) {
|
|
5209
5209
|
this.raDashboardEventBus.publish(RAEvent.UpdateWidgetCount, -1);
|
|
5210
|
-
this.
|
|
5210
|
+
this.rearrangeWidgets();
|
|
5211
5211
|
}
|
|
5212
5212
|
}
|
|
5213
5213
|
/**To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc*/
|
|
5214
5214
|
rearrangeWidgets() {
|
|
5215
|
+
// Site Detail dashboard: deterministic reflow instead of zeroing all positions
|
|
5216
|
+
if (this.isSiteDetailDashboard) {
|
|
5217
|
+
const isDesktop = this.responsiveService.IsDesktopView;
|
|
5218
|
+
const maxCols = (this.options && (this.options.maxCols || this.options.minCols)) || this.responsiveService.maxColsDesktop;
|
|
5219
|
+
if (isDesktop) {
|
|
5220
|
+
let curX = 0;
|
|
5221
|
+
let curY = 0;
|
|
5222
|
+
this.userWidgets.forEach(w => {
|
|
5223
|
+
let width = w.width || this.widgetWidth;
|
|
5224
|
+
if (width > maxCols) {
|
|
5225
|
+
width = maxCols;
|
|
5226
|
+
w.width = width;
|
|
5227
|
+
}
|
|
5228
|
+
if (curX + width > maxCols) {
|
|
5229
|
+
curX = 0;
|
|
5230
|
+
curY++;
|
|
5231
|
+
}
|
|
5232
|
+
w.position_x = curX;
|
|
5233
|
+
w.position_y = curY;
|
|
5234
|
+
curX += width;
|
|
5235
|
+
});
|
|
5236
|
+
// Update existing gridster items in-place if counts match; else rebuild
|
|
5237
|
+
if (this.widgetList.length === this.userWidgets.length) {
|
|
5238
|
+
this.widgetList.forEach(item => {
|
|
5239
|
+
const w = item.widgetInfo;
|
|
5240
|
+
item.x = w.position_x;
|
|
5241
|
+
item.y = w.position_y;
|
|
5242
|
+
});
|
|
5243
|
+
}
|
|
5244
|
+
else {
|
|
5245
|
+
this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
else { // mobile view: vertical stack
|
|
5249
|
+
this.userWidgets.forEach((w, idx) => { w.position_x = 0; w.position_y = idx; });
|
|
5250
|
+
if (this.widgetList.length === this.userWidgets.length) {
|
|
5251
|
+
this.widgetList.forEach(item => { const w = item.widgetInfo; item.x = 0; item.y = w.position_y; });
|
|
5252
|
+
}
|
|
5253
|
+
else {
|
|
5254
|
+
this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
this.options?.api?.optionsChanged?.();
|
|
5258
|
+
this.raDashboardEventBus.publish(RAEvent.HideDashboardBanner, false);
|
|
5259
|
+
// Persist new positions (desktop only)
|
|
5260
|
+
if (this.responsiveService.IsDesktopView) {
|
|
5261
|
+
setTimeout(() => {
|
|
5262
|
+
this.widgetList.forEach(item => { const id = item.widgetInfo?.widgetInstanceId; if (id) {
|
|
5263
|
+
this.updateWidgetPosition(id);
|
|
5264
|
+
} });
|
|
5265
|
+
}, 50);
|
|
5266
|
+
}
|
|
5267
|
+
setTimeout(() => { this.setAreaHeight(); });
|
|
5268
|
+
return;
|
|
5269
|
+
}
|
|
5270
|
+
// Legacy behaviour for other dashboards (reset + rebuild)
|
|
5215
5271
|
for (let i = 0; i < this.userWidgets.length; i++) {
|
|
5216
5272
|
this.userWidgets[i].position_x = 0;
|
|
5217
5273
|
this.userWidgets[i].position_y = 0;
|