From 232da256acd3eb5fc2f8d0417d71d6aaac3a124b Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 31 Mar 2025 14:56:41 +0200 Subject: [PATCH] fix(Dashboard Drag Placeholder): doesn't allow placeholder items to be dragged anymore and keeps the height and width of a widget when resizing the grid of the dashboard --- public/js/components/Dashboard/Section.js | 14 ++++++++++++-- public/js/components/Drop/Grid/Item.js | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/public/js/components/Dashboard/Section.js b/public/js/components/Dashboard/Section.js index 7818e06b9..3a71eb5fc 100644 --- a/public/js/components/Dashboard/Section.js +++ b/public/js/components/Dashboard/Section.js @@ -49,8 +49,18 @@ export default { return 'margin-bottom: 8px;'; }, items() { + return this.widgets.map(item => { - return { ...item, ...(item.place[this.gridWidth] || {h: 1, w:1, x:0, y:0})}; + let place; + if(!item.place[this.gridWidth]){ + const nearestIndex = Object.keys(item.place).sort((a,b)=>Math.abs(a-this.gridWidth)-Math.abs(b-this.gridWidth)).pop(); + if (nearestIndex === null){ + place = {x:0,y:0,w:1,h:1}; + }else{ + place = item.place[nearestIndex]; + } + } + return { ...item, ...(item.place[this.gridWidth] || place)}; }); }, items_hashmap() { @@ -201,7 +211,7 @@ export default { + :draggable="active && !item.placeholder"> ` }