Merge pull request #11504 from vvlladd28/bug/dashboard/move-all-widget
Improved move all widget action: fixed overlap widget and add support dashboard layout
This commit is contained in:
commit
8410bd6f22
@ -752,10 +752,25 @@ export class DashboardUtilsService {
|
|||||||
public moveWidgets(layout: DashboardLayout, cols: number, rows: number) {
|
public moveWidgets(layout: DashboardLayout, cols: number, rows: number) {
|
||||||
cols = isDefinedAndNotNull(cols) ? Math.round(cols) : 0;
|
cols = isDefinedAndNotNull(cols) ? Math.round(cols) : 0;
|
||||||
rows = isDefinedAndNotNull(rows) ? Math.round(rows) : 0;
|
rows = isDefinedAndNotNull(rows) ? Math.round(rows) : 0;
|
||||||
|
if (cols < 0 || rows < 0) {
|
||||||
|
let widgetMinCol = Infinity;
|
||||||
|
let widgetMinRow = Infinity;
|
||||||
|
for (const w of Object.keys(layout.widgets)) {
|
||||||
|
const widget = layout.widgets[w];
|
||||||
|
widgetMinCol = Math.min(widgetMinCol, widget.col);
|
||||||
|
widgetMinRow = Math.min(widgetMinRow, widget.row);
|
||||||
|
}
|
||||||
|
if ((cols + widgetMinCol) < 0 ){
|
||||||
|
cols = -widgetMinCol;
|
||||||
|
}
|
||||||
|
if ((rows + widgetMinRow) < 0 ){
|
||||||
|
rows = -widgetMinRow;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (const w of Object.keys(layout.widgets)) {
|
for (const w of Object.keys(layout.widgets)) {
|
||||||
const widget = layout.widgets[w];
|
const widget = layout.widgets[w];
|
||||||
widget.col = Math.max(0, widget.col + cols);
|
widget.col += cols;
|
||||||
widget.row = Math.max(0, widget.row + rows);
|
widget.row += rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -988,7 +988,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private moveWidgets($event: Event, layoutId: DashboardLayoutId) {
|
private moveWidgets($event: Event, layoutId: DashboardLayoutId, breakpointId: BreakpointId) {
|
||||||
if ($event) {
|
if ($event) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
@ -1001,7 +1001,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
}).afterClosed().subscribe((result) => {
|
}).afterClosed().subscribe((result) => {
|
||||||
this.layouts[layoutId].layoutCtx.displayGrid = 'onDrag&Resize';
|
this.layouts[layoutId].layoutCtx.displayGrid = 'onDrag&Resize';
|
||||||
if (result) {
|
if (result) {
|
||||||
const targetLayout = this.dashboardConfiguration.states[this.dashboardCtx.state].layouts[layoutId];
|
const dashboardLayout = this.dashboardConfiguration.states[this.dashboardCtx.state].layouts[layoutId];
|
||||||
|
const targetLayout = this.dashboardUtils.getDashboardLayoutConfig(dashboardLayout, breakpointId);
|
||||||
this.dashboardUtils.moveWidgets(targetLayout, result.cols, result.rows);
|
this.dashboardUtils.moveWidgets(targetLayout, result.cols, result.rows);
|
||||||
this.updateLayouts();
|
this.updateLayouts();
|
||||||
} else {
|
} else {
|
||||||
@ -1582,7 +1583,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
dashboardContextActions.push(
|
dashboardContextActions.push(
|
||||||
{
|
{
|
||||||
action: ($event) => {
|
action: ($event) => {
|
||||||
this.moveWidgets($event, layoutCtx.id);
|
this.moveWidgets($event, layoutCtx.id, layoutCtx.breakpoint);
|
||||||
},
|
},
|
||||||
enabled: true,
|
enabled: true,
|
||||||
value: 'dashboard.move-all-widgets',
|
value: 'dashboard.move-all-widgets',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user