Browse Source

HUE-8186 [dashboard] Fix move widgets corner cases when moving along the same row

Enrico Berti 7 years ago
parent
commit
1bed41e95a
1 changed files with 16 additions and 6 deletions
  1. 16 6
      desktop/libs/dashboard/src/dashboard/templates/common_search.mako

+ 16 - 6
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -4329,15 +4329,25 @@ $(document).ready(function () {
           dimensions.col = adjustedDropPosition;
           dimensions.sizex = newOptimalWidth;
 
-          var siblingCounter = 0;
-          for (var i = 1; i <= 12 / newOptimalWidth; i++) {
-            if (i !== droppedWidgetFauxColumn) {
-              if (collidingWidgets[siblingCounter]) {
-                resizeAndMove(collidingWidgets[siblingCounter], newOptimalWidth, ((i - 1) * newOptimalWidth) + 1)
+          var resizeAndMoveSiblings = function() {
+            var siblingCounter = 0;
+            for (var i = 1; i <= 12 / newOptimalWidth; i++) {
+              if (i !== droppedWidgetFauxColumn) {
+                if (collidingWidgets[siblingCounter]) {
+                  resizeAndMove(collidingWidgets[siblingCounter], newOptimalWidth, ((i - 1) * newOptimalWidth) + 1)
+                }
+                siblingCounter++;
               }
-              siblingCounter++;
             }
           }
+
+          if (tempDraggableGridsterWidget) {
+            $gridster.move_widget($(tempDraggableGridsterWidget.gridsterElement), -100, -100, resizeAndMoveSiblings); // temporarily move it off grid
+          }
+          else {
+            resizeAndMoveSiblings();
+          }
+
         }
       }