Skip to content

Commit

Permalink
for 48 columns layout, adjust default size and layout for newly added…
Browse files Browse the repository at this point in the history
… slices (#4446)

(cherry picked from commit 5768a1f)
  • Loading branch information
Grace Guo authored and mistercrunch committed Feb 22, 2018
1 parent a1173f4 commit f99c22a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions superset/assets/javascripts/dashboard/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ export function getInitialState(bootstrapData) {
dashboard.posDict[position.slice_id] = position;
});
}
dashboard.slices.forEach((slice, index) => {
const lastRowId = Math.max.apply(null,
dashboard.position_json.map(pos => (pos.row + pos.size_y)));
let newSliceCounter = 0;
dashboard.slices.forEach((slice) => {
const sliceId = slice.slice_id;
let pos = dashboard.posDict[sliceId];
if (!pos) {
// append new slices to dashboard bottom, 3 slices per row
pos = {
col: (index * 4 + 1) % 12,
row: Math.floor((index) / 3) * 4,
size_x: 4,
size_y: 4,
col: (newSliceCounter % 3) * 16 + 1,
row: lastRowId + Math.floor(newSliceCounter / 3) * 16,
size_x: 16,
size_y: 16,
};
newSliceCounter++;
}

dashboard.layout.push({
Expand Down

0 comments on commit f99c22a

Please sign in to comment.