superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] 03/05: for 48 columns layout, adjust default size and layout for newly added slices (#4446)
Date Thu, 22 Feb 2018 02:16:37 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to tag 0.23.0rc4
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit f99c22af0f257e2bc6470bacc0808273a3dbe243
Author: Grace Guo <grace.guo@airbnb.com>
AuthorDate: Mon Feb 19 00:05:57 2018 -0800

    for 48 columns layout, adjust default size and layout for newly added slices (#4446)
    
    (cherry picked from commit 5768a1fe5e17f036a9c2f48afd91753e2ab6668d)
---
 superset/assets/javascripts/dashboard/reducers.js | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/superset/assets/javascripts/dashboard/reducers.js b/superset/assets/javascripts/dashboard/reducers.js
index 1e37aca..cbbb263 100644
--- a/superset/assets/javascripts/dashboard/reducers.js
+++ b/superset/assets/javascripts/dashboard/reducers.js
@@ -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({

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.

Mime
View raw message