From 3fe15a302c943095c5d1f59a1fa7b87ea8b4fd9e Mon Sep 17 00:00:00 2001 From: chfhtw Date: Mon, 30 Mar 2026 14:14:06 +0200 Subject: [PATCH] correct calculation of allowed resize directions --- public/js/components/Dashboard/Item.js | 136 +++++++++++++--------- public/js/components/Dashboard/Section.js | 17 ++- 2 files changed, 88 insertions(+), 65 deletions(-) diff --git a/public/js/components/Dashboard/Item.js b/public/js/components/Dashboard/Item.js index 0cc274b70..196329377 100644 --- a/public/js/components/Dashboard/Item.js +++ b/public/js/components/Dashboard/Item.js @@ -37,25 +37,49 @@ export default { "loading", "item_data", "place", - "setup", + "resizeLimits", "dragstate", "resizeOverlay" ], computed: { - maxHeight() { - if (Object.prototype.toString.call(this.setup?.height) == "[object Number]") { - return this.setup?.height; + isResizeableHorizontal() { + if (this.resizeLimits.width === undefined) + return true; + + if (Object.prototype.toString.call(this.resizeLimits.width) == "[object Number]") + return false; + + if (this.resizeLimits.width.min === undefined) { + if (this.resizeLimits.width.max === undefined) + return true; + return this.resizeLimits.width.max > 1; } - return this.setup?.height?.max; + + if (this.resizeLimits.width.max === undefined) + return true; + + return this.resizeLimits.width.max > this.resizeLimits.width.min; }, - maxWidth() { - if (Object.prototype.toString.call(this.setup?.width) == "[object Number]") { - return this.setup?.width; + isResizeableVertical() { + if (this.resizeLimits.height === undefined) + return true; + + if (Object.prototype.toString.call(this.resizeLimits.height) == "[object Number]") + return false; + + if (this.resizeLimits.height.min === undefined) { + if (this.resizeLimits.height.max === undefined) + return true; + return this.resizeLimits.height.max > 1; } - return this.setup?.width?.max; + + if (this.resizeLimits.height.max === undefined) + return true; + + return this.resizeLimits.height.max > this.resizeLimits.height.min; }, isResizeable() { - return this.maxWidth > 1 || this.maxHeight > 1; + return this.isResizeableVertical || this.isResizeableHorizontal; }, isPinned() { return this.place?.pinned ? true : false; @@ -213,52 +237,52 @@ export default { - diff --git a/public/js/components/Dashboard/Section.js b/public/js/components/Dashboard/Section.js index 817cc52a3..98d930edc 100644 --- a/public/js/components/Dashboard/Section.js +++ b/public/js/components/Dashboard/Section.js @@ -52,12 +52,13 @@ export default { } }, computed: { - computedWidgetsSetup(){ - if(!this.widgetsSetup) return {}; - return this.widgetsSetup.reduce((acc, setup)=>{ + computedWidgetsSetup() { + if (!this.widgetsSetup) + return {}; + return this.widgetsSetup.reduce((acc, setup) => { acc[setup.widget_id] = setup.setup; return acc; - },{}) + }, {}); }, editModeIsActive() { return (this.editMode || this.adminMode) && !this.configOpened @@ -240,17 +241,15 @@ export default { :hidden="item.hidden" :editMode="editModeIsActive" :place="item.place[gridWidth]" - :setup="computedWidgetsSetup[item.widget]" + :resize-limits="computedWidgetsSetup[item.widget]" @change="saveConfig($event, item)" @remove="removeWidget(item, $event)" @config-opened="handleConfigOpened" @config-closed="handleConfigClosed" @pinItem="updatePositions($event,true)" - @unPinItem="updatePositions"> - - + @unPinItem="updatePositions" + > - ` }