浏览代码

AMBARI-5932. Slider apps table does not remove entry when app is removed (alexantonenko)

Alex Antonenko 11 年之前
父节点
当前提交
66848d4d69
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js

+ 11 - 1
contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js

@@ -127,7 +127,8 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, {
    */
   parse: function(data) {
     var apps = [],
-    self = this;
+    self = this,
+    appsToDelete = App.SliderApp.store.all('sliderApp').get('content').mapProperty('id');
 
     data.items.forEach(function(app) {
       var componentsId = app.components ? self.parseComponents(app) : [],
@@ -153,6 +154,15 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, {
           runtimeProperties: app.configs
         })
       );
+
+      appsToDelete.splice(appsToDelete.indexOf(app.id), 1);
+    });
+
+    appsToDelete.forEach(function (app) {
+      var appRecord = App.SliderApp.store.getById('sliderApp', app);
+      if(appRecord){
+        appRecord.destroyRecord();
+      }
     });
     App.SliderApp.store.pushMany('sliderApp', apps);
   }