Browse Source

HUE-7924 [dashboard] Fix JS errors on drag and remove on the old layout mode

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

+ 17 - 7
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -3896,9 +3896,17 @@ $(document).ready(function () {
     movePreviewHolder(options);
     movePreviewHolder(options);
   }, 'dashboard');
   }, 'dashboard');
 
 
-  huePubSub.subscribe('draggable.text.drag', movePreviewHolder, 'dashboard');
+  huePubSub.subscribe('draggable.text.drag', function(options) {
+    if (searchViewModel.isGridster()) {
+      movePreviewHolder(options);
+    }
+  }, 'dashboard');
 
 
-  huePubSub.subscribe('draggable.text.meta', addPreviewHolder, 'dashboard');
+  huePubSub.subscribe('draggable.text.meta', function(options) {
+    if (searchViewModel.isGridster()) {
+      addPreviewHolder(options);
+    }
+  }, 'dashboard');
 
 
   huePubSub.subscribe('gridster.added.widget', removePreviewHolder, 'dashboard');
   huePubSub.subscribe('gridster.added.widget', removePreviewHolder, 'dashboard');
 
 
@@ -4096,11 +4104,13 @@ $(document).ready(function () {
   }, 'dashboard')
   }, 'dashboard')
 
 
   huePubSub.subscribe('gridster.remove.widget', function (widgetId) {
   huePubSub.subscribe('gridster.remove.widget', function (widgetId) {
-    searchViewModel.gridItems().forEach(function (item) {
-      if (item.widgetId() === parseInt($('#wdg_' + widgetId).parents('li.gs-w').attr('data-widgetid'))) {
-        huePubSub.publish('gridster.remove', item);
-      }
-    });
+    if (searchViewModel.isGridster()) {
+      searchViewModel.gridItems().forEach(function (item) {
+        if (item.widgetId() === parseInt($('#wdg_' + widgetId).parents('li.gs-w').attr('data-widgetid'))) {
+          huePubSub.publish('gridster.remove', item);
+        }
+      });
+    }
   }, 'dashboard');
   }, 'dashboard');
 
 
   huePubSub.subscribe('gridster.add.widget', function (options) {
   huePubSub.subscribe('gridster.add.widget', function (options) {