From 21065a3c9523d631fbdf2fb9005a6f91900d1c80 Mon Sep 17 00:00:00 2001 From: chfhtw Date: Tue, 21 Apr 2026 13:47:08 +0200 Subject: [PATCH] because of 4ab90567003cb9d564c7236930156829db395380 pinned property can't be deleted (will get overwritten by the original value) so work around that with boolean values that are later removed if false --- .../js/components/Dashboard/Admin/Presets.js | 6 ++++++ public/js/components/Dashboard/Dashboard.js | 6 ++++++ public/js/components/Dashboard/Item.js | 4 ++-- public/js/components/Dashboard/Section.js | 19 ++++++++++--------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/public/js/components/Dashboard/Admin/Presets.js b/public/js/components/Dashboard/Admin/Presets.js index 4b0c9f7ea..63e8b99e0 100644 --- a/public/js/components/Dashboard/Admin/Presets.js +++ b/public/js/components/Dashboard/Admin/Presets.js @@ -86,6 +86,12 @@ export default { break; } } + if (payload[k].place) { + Object.values(payload[k].place).forEach(place => { + if (place.pinned === false) + delete place.pinned; + }); + } payload[k].widgetid = k; } this.$api diff --git a/public/js/components/Dashboard/Dashboard.js b/public/js/components/Dashboard/Dashboard.js index 4185210ab..64d4de71d 100644 --- a/public/js/components/Dashboard/Dashboard.js +++ b/public/js/components/Dashboard/Dashboard.js @@ -74,6 +74,12 @@ export default { break; } } + if (payload[k].place) { + Object.values(payload[k].place).forEach(place => { + if (place.pinned === false) + delete place.pinned; + }); + } payload[k].widgetid = k; } this.$api diff --git a/public/js/components/Dashboard/Item.js b/public/js/components/Dashboard/Item.js index 00951cdd5..4a7333591 100644 --- a/public/js/components/Dashboard/Item.js +++ b/public/js/components/Dashboard/Item.js @@ -118,11 +118,11 @@ export default { // Unpinning is only possible in edit mode if (!this.editMode) return; - let result = { item: this.item_data, x: this.item_data.x, y: this.item_data.y }; + let result = { item: this.item_data, pinned: false }; this.$emit('unPinItem', [result]); }, pinItem() { - let result = { item: this.item_data, x: this.item_data.x, y: this.item_data.y }; + let result = { item: this.item_data, pinned: true }; this.$emit('pinItem', [result]); }, getWidgetC4Link(widget) { diff --git a/public/js/components/Dashboard/Section.js b/public/js/components/Dashboard/Section.js index c2342e7d6..b01658182 100644 --- a/public/js/components/Dashboard/Section.js +++ b/public/js/components/Dashboard/Section.js @@ -155,20 +155,22 @@ export default { payload[item.id] = { config }; this.updatePreset(payload); }, - updatePositions(updated, pinned=false) { + updatePositions(updated) { let result = {}; updated.forEach(update => { - let item = structuredClone(ObjectUtils.deepToRaw(update.item)); + if (!item.placeholder) { if (!item.place[this.gridWidth]) - item.place[this.gridWidth] = {x: 0, y: 0, w: 1, h: 1}; + item.place[this.gridWidth] = { x: 0, y: 0, w: 1, h: 1 }; + delete item.x; delete item.y; delete item.w; delete item.h; - delete item.place[this.gridWidth].pinned; + delete item.pinned; delete item.weight; + if (update.x !== undefined) item.place[this.gridWidth].x = update.x; if (update.y !== undefined) @@ -177,9 +179,8 @@ export default { item.place[this.gridWidth].w = update.w; if (update.h !== undefined) item.place[this.gridWidth].h = update.h; - if (pinned) { - item.place[this.gridWidth].pinned = true; - } + if (update.pinned !== undefined) + item.place[this.gridWidth].pinned = update.pinned; result[item.id] = item; } @@ -250,8 +251,8 @@ export default { @remove="removeWidget(item, $event)" @config-opened="handleConfigOpened" @config-closed="handleConfigClosed" - @pinItem="updatePositions($event,true)" - @unPinItem="updatePositions" + @pin-item="updatePositions" + @un-pin-item="updatePositions" >