mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-26 00:54:27 +00:00
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
This commit is contained in:
@@ -49,8 +49,18 @@ export default {
|
|||||||
return 'margin-bottom: 8px;';
|
return 'margin-bottom: 8px;';
|
||||||
},
|
},
|
||||||
items() {
|
items() {
|
||||||
|
|
||||||
return this.widgets.map(item => {
|
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() {
|
items_hashmap() {
|
||||||
@@ -201,7 +211,7 @@ export default {
|
|||||||
<dashboard-item
|
<dashboard-item
|
||||||
v-if="!item.placeholder"
|
v-if="!item.placeholder"
|
||||||
:id="item.widget"
|
:id="item.widget"
|
||||||
:widgetID="item.widgetid"
|
:widgetID="item.id"
|
||||||
:width="item.w"
|
:width="item.w"
|
||||||
:height="item.h"
|
:height="item.h"
|
||||||
:loading="item.loading"
|
:loading="item.loading"
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ export default {
|
|||||||
"startResize",
|
"startResize",
|
||||||
"dragging",
|
"dragging",
|
||||||
"endDrag",
|
"endDrag",
|
||||||
"dropDrag"
|
"dropDrag",
|
||||||
|
"item"
|
||||||
],
|
],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -63,12 +64,12 @@ export default {
|
|||||||
template: `
|
template: `
|
||||||
<div class="drop-grid-item"
|
<div class="drop-grid-item"
|
||||||
@mousedown="registerDragAction"
|
@mousedown="registerDragAction"
|
||||||
@touchstart="tryDragStart($event, item)"
|
@touchstart.prevent="tryDragStart($event, item)"
|
||||||
@touchend="touchDragEnd"
|
@touchend="touchDragEnd"
|
||||||
@dragstart="tryDragStart($event, item)"
|
@dragstart="tryDragStart($event, item)"
|
||||||
@drag="$emit('dragging',$event)"
|
@drag="$emit('dragging',$event)"
|
||||||
@dragend="$emit('endDrag', $event)"
|
@dragend="$emit('endDrag', $event)"
|
||||||
:draggable="active">
|
:draggable="active && !item.placeholder">
|
||||||
<slot v-bind="item"></slot>
|
<slot v-bind="item"></slot>
|
||||||
</div>`
|
</div>`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user