fix(Dashboard Grid Height): a bug was removed where the grid height was not correct when adding a new widget and the widget was not correctly displayed when adding a new widget

This commit is contained in:
SimonGschnell
2025-04-14 14:33:49 +02:00
parent 54bbfacf86
commit d4ae8b0f91
2 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ export default {
<drop-grid v-model:cols="gridWidth" :items="items" :active="editModeIsActive" :resize-limit="checkResizeLimit" :margin-for-extra-row=".01" @draggedItem="draggedItem=$event" @rearrange-items="updatePositions" @gridHeight="gridHeight=$event" >
<template #default="item">
<div v-if="item.placeholder" class="empty-tile-hover" @click="$emit('widgetAdd', name, { widget: 1, config: {}, place: {[gridWidth]: {x:item.x,y:item.y,w:1,h:1}}, custom: 1 })"></div>
<div v-else-if="item.blank || item.widgetid == draggedItem?.data.widgetid" :class="{'dashboard-item-overlay':item.resizeOverlay}" class="dashboard-item card overflow-hidden h-100 position-relative draggedItem" ></div>
<div v-else-if="item.blank || (item.widgetid && item.widgetid == draggedItem?.data.widgetid)" :class="{'dashboard-item-overlay':item.resizeOverlay}" class="dashboard-item card overflow-hidden h-100 position-relative draggedItem" ></div>
<dashboard-item
v-else
:id="item.widget"
+10 -5
View File
@@ -118,8 +118,9 @@ export default {
return [...this.placedItems, ...this.items_placeholders];
},
rows() {
if ((this.mode == MODE_MOVE || this.mode == MODE_RESIZE) && this.dragGrid)
if ((this.mode == MODE_MOVE || this.mode == MODE_RESIZE) && this.dragGrid){
return this.dragGrid.h;
}
return this.grid ? this.grid.h : 1;
},
gridStyle() {
@@ -171,7 +172,6 @@ export default {
let mappedPlacedItems= this.prePlacedItems.map(item => {
if (!this.positionUpdates[item.index] )
return item;
let height_diff = this.positionUpdates[item.index]?.h - item.h;
let width_diff = this.positionUpdates[item.index]?.w - item.w;
return {
@@ -345,7 +345,10 @@ export default {
this.x = -1;
this.y = -1;
if (this.additionalRow !== null) {
this.grid.h = this.additionalRow;
let gridHeight = this.grid.getMaxY() + 1;
if(this.grid.h>gridHeight){
this.grid.h = gridHeight;
}
this.additionalRow = null;
}
}
@@ -376,11 +379,13 @@ export default {
this.additionalRow = this.grid.h;
this.grid.h += 1;
} else if (this.additionalRow !== null && gridY != this.rows - 1) {
this.grid.h = this.additionalRow;
let gridHeight = this.grid.getMaxY() + 1;
if(this.grid.h > gridHeight){
this.grid.h = gridHeight;
}
this.additionalRow = null;
}
}
this.x = gridX;
this.y = gridY;