From 095e26f80985e526ebe5cec7ff74bc3fe25b9d4d Mon Sep 17 00:00:00 2001 From: Stephan de Wit Date: Wed, 4 Sep 2024 11:06:50 +0200 Subject: [PATCH] dashboard: restructure previous --- src/opnsense/www/js/opnsense_widget_manager.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/opnsense/www/js/opnsense_widget_manager.js b/src/opnsense/www/js/opnsense_widget_manager.js index 0c5773d94..c4cbaf28c 100644 --- a/src/opnsense/www/js/opnsense_widget_manager.js +++ b/src/opnsense/www/js/opnsense_widget_manager.js @@ -605,16 +605,6 @@ class WidgetManager { $('#save-grid').prop('disabled', true); let items = this.grid.save(false); - let saveNewXY = this.grid.getColumn() >= 12; - - // prevent restricting the grid to a few columns when saving on a smaller screen - if (!saveNewXY) { - items.forEach((item) => { - item.x = this.widgetConfigurations[item.id].x; - item.y = this.widgetConfigurations[item.id].y; - }); - } - items = await Promise.all(items.map(async (item) => { let widgetConfig = await this.widgetClasses[item.id].getWidgetConfig(); if (widgetConfig) { @@ -624,12 +614,16 @@ class WidgetManager { // XXX the gridstack save() behavior is inconsistent with the responsive columnWidth option, // as the calculation will return impossible values for the x, y, w and h attributes. // For now, the gs-{x,y,w,h} attributes are a better representation of the grid for layout persistence - if (saveNewXY) { + if (this.grid.getColumn() >= 12) { let elem = $(this.widgetHTMLElements[item.id]); item.x = parseInt(elem.attr('gs-x')) ?? 1; item.y = parseInt(elem.attr('gs-y')) ?? 1; item.w = parseInt(elem.attr('gs-w')) ?? 1; item.h = parseInt(elem.attr('gs-h')) ?? 1; + } else { + // prevent restricting the grid to a few columns when saving on a smaller screen + item.x = this.widgetConfigurations[item.id].x; + item.y = this.widgetConfigurations[item.id].y; } delete item['callbacks'];