Browse Source

HUE-7799 [dashboard] Removing a widget from Gridster should remove the instance in the items too

Enrico Berti 8 năm trước cách đây
mục cha
commit
8bfefebc92

+ 2 - 2
desktop/core/src/desktop/templates/common_dashboard.mako

@@ -204,12 +204,12 @@
     <!-- ko ifnot: widget -->
     <div class="empty-gridster-widget" data-bind="droppable: { data: function(w) { showAddFacetDemiModal(w, $data); }, options: { greedy:true, hoverClass: 'droppable-hover' }}">
       <div class="inline pull-right remove-empty-gridster" data-bind="visible: $root.isEditing">
-        <a href="javascript:void(0)" data-bind="click: function(data, e){ huePubSub.publish('gridster.remove', e.target); }"><i class="fa fa-times"></i></a>
+        <a href="javascript:void(0)" data-bind="click: function(data){ huePubSub.publish('gridster.remove', data); }"><i class="fa fa-times"></i></a>
       </div>
     </div>
     <!-- /ko -->
   <!-- ko with: widget -->
-    <span data-bind="template: 'widget-template${ suffix }'"></span>
+    <div data-bind="template: 'widget-template${ suffix }'"></div>
     <div class="clearfix"></div>
   <!-- /ko -->
   </li>

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

@@ -3748,12 +3748,16 @@ $(document).ready(function () {
     resizeGridsterWidget($(element).parents('li.gs-w'));
   }, 'dashboard');
 
-  huePubSub.subscribe('gridster.remove', function (element) {
-    $(".gridster>ul").data('gridster').remove_widget($(element).parents('li.gs-w'));
+  huePubSub.subscribe('gridster.remove', function (gridElement) {
+    searchViewModel.gridItems.remove(gridElement);
   }, 'dashboard')
 
   huePubSub.subscribe('gridster.remove.widget', function (widgetId) {
-    huePubSub.publish('gridster.remove', "#wdg_" + widgetId);
+    searchViewModel.gridItems().forEach(function (item) {
+      if (item.widgetId() === parseInt($('#wdg_' + widgetId).parents('li.gs-w').attr('data-widgetid'))) {
+        huePubSub.publish('gridster.remove', item);
+      }
+    });
   }, 'dashboard');
 
   huePubSub.subscribe('gridster.add.widget', function (options) {