fix vertical panel repeat (#10619)
This commit is contained in:
committed by
Torkel Ödegaard
parent
b79017e4a4
commit
cffbb6afd5
@@ -354,6 +354,14 @@ export class DashboardModel {
|
|||||||
if (panel.repeatDirection === REPEAT_DIR_VERTICAL) {
|
if (panel.repeatDirection === REPEAT_DIR_VERTICAL) {
|
||||||
copy.gridPos.y = yPos;
|
copy.gridPos.y = yPos;
|
||||||
yPos += copy.gridPos.h;
|
yPos += copy.gridPos.h;
|
||||||
|
|
||||||
|
// Update gridPos for panels below
|
||||||
|
let panelBelowIndex = panelIndex + index + 1;
|
||||||
|
for (let i = panelBelowIndex; i < this.panels.length; i++) {
|
||||||
|
if (this.panels[i].gridPos.y < yPos) {
|
||||||
|
this.panels[i].gridPos.y += copy.gridPos.h;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// set width based on how many are selected
|
// set width based on how many are selected
|
||||||
// assumed the repeated panels should take up full row width
|
// assumed the repeated panels should take up full row width
|
||||||
|
|||||||
@@ -142,12 +142,9 @@ describe('given dashboard with panel repeat in vertical direction', function() {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
dashboard = new DashboardModel({
|
dashboard = new DashboardModel({
|
||||||
panels: [
|
panels: [
|
||||||
{
|
{ id: 1, type: 'row', gridPos: { x: 0, y: 0, h: 1, w: 24 } },
|
||||||
id: 2,
|
{ id: 2, repeat: 'apps', repeatDirection: 'v', gridPos: { x: 5, y: 1, h: 2, w: 8 } },
|
||||||
repeat: 'apps',
|
{ id: 3, type: 'row', gridPos: { x: 0, y: 3, h: 1, w: 24 } },
|
||||||
repeatDirection: 'v',
|
|
||||||
gridPos: { x: 5, y: 0, h: 2, w: 8 },
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
templating: {
|
templating: {
|
||||||
list: [
|
list: [
|
||||||
@@ -171,24 +168,13 @@ describe('given dashboard with panel repeat in vertical direction', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should place on items on top of each other and keep witdh', function() {
|
it('should place on items on top of each other and keep witdh', function() {
|
||||||
expect(dashboard.panels[0].gridPos).toMatchObject({
|
expect(dashboard.panels[0].gridPos).toMatchObject({ x: 0, y: 0, h: 1, w: 24 }); // first row
|
||||||
x: 5,
|
|
||||||
y: 0,
|
expect(dashboard.panels[1].gridPos).toMatchObject({ x: 5, y: 1, h: 2, w: 8 });
|
||||||
h: 2,
|
expect(dashboard.panels[2].gridPos).toMatchObject({ x: 5, y: 3, h: 2, w: 8 });
|
||||||
w: 8,
|
expect(dashboard.panels[3].gridPos).toMatchObject({ x: 5, y: 5, h: 2, w: 8 });
|
||||||
});
|
|
||||||
expect(dashboard.panels[1].gridPos).toMatchObject({
|
expect(dashboard.panels[4].gridPos).toMatchObject({ x: 0, y: 7, h: 1, w: 24 }); // last row
|
||||||
x: 5,
|
|
||||||
y: 2,
|
|
||||||
h: 2,
|
|
||||||
w: 8,
|
|
||||||
});
|
|
||||||
expect(dashboard.panels[2].gridPos).toMatchObject({
|
|
||||||
x: 5,
|
|
||||||
y: 4,
|
|
||||||
h: 2,
|
|
||||||
w: 8,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user