@schneideress/dashboardframework 20.0.10 → 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.
@@ -5212,6 +5212,62 @@ class RADashboardArea {
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;
@@ -5224,17 +5280,6 @@ class RADashboardArea {
5224
5280
  setTimeout(() => {
5225
5281
  this.setAreaHeight();
5226
5282
  });
5227
- // Centralized persistence for Site Detail dashboards (desktop only)
5228
- if (this.isSiteDetailDashboard && this.responsiveService.IsDesktopView) {
5229
- setTimeout(() => {
5230
- this.widgetList.forEach(item => {
5231
- const id = item.widgetInfo?.widgetInstanceId;
5232
- if (id) {
5233
- this.updateWidgetPosition(id);
5234
- }
5235
- });
5236
- }, 50);
5237
- }
5238
5283
  }
5239
5284
  /**To add widget instance to the database with the next available position and to make changes in
5240
5285
  * dashboard area.