Browse Source

filterSrv refactoring cleanup and testing

Torkel Ödegaard 11 years ago
parent
commit
beca72cc40
2 changed files with 9 additions and 7 deletions
  1. 1 1
      src/app/panels/filtering/module.html
  2. 8 6
      src/app/services/filterSrv.js

+ 1 - 1
src/app/panels/filtering/module.html

@@ -2,7 +2,7 @@
 
 
   <div class='filtering-container'>
   <div class='filtering-container'>
 
 
-    <div ng-repeat="filter in filter.list" class="small filter-panel-filter">
+    <div ng-repeat="filter in filter.templateParameters" class="small filter-panel-filter">
       <div>
       <div>
         <i class="filter-action pointer icon-remove" bs-tooltip="'Remove'" ng-click="remove(filter)"></i>
         <i class="filter-action pointer icon-remove" bs-tooltip="'Remove'" ng-click="remove(filter)"></i>
         <i class="filter-action pointer icon-edit" ng-hide="filter.editing" bs-tooltip="'Edit'" ng-click="filter.editing = true"></i>
         <i class="filter-action pointer icon-edit" ng-hide="filter.editing" bs-tooltip="'Edit'" ng-click="filter.editing = true"></i>

+ 8 - 6
src/app/services/filterSrv.js

@@ -16,7 +16,7 @@ define([
     };
     };
 
 
     var result = {
     var result = {
-        _updateTemplateData : function( initial ) {
+        _updateTemplateData : function(initial) {
             var _templateData = {};
             var _templateData = {};
             _.each(this.templateParameters, function( templateParameter ) {
             _.each(this.templateParameters, function( templateParameter ) {
                 if (initial) {
                 if (initial) {
@@ -29,7 +29,7 @@ define([
                     return;
                     return;
                 }
                 }
 
 
-                _templateData[ templateParameter.name ] = templateParameter.current.value;
+                _templateData[templateParameter.name] = templateParameter.current.value;
             });
             });
             this._templateData = _templateData;
             this._templateData = _templateData;
         },
         },
@@ -92,17 +92,19 @@ define([
             this.templateParameters = _.without( this.templateParameters, templateParameter );
             this.templateParameters = _.without( this.templateParameters, templateParameter );
         },
         },
 
 
-        init : function( dashboard ) {
+        init: function(dashboard) {
             _.defaults(this, _d);
             _.defaults(this, _d);
             this.dashboard = dashboard;
             this.dashboard = dashboard;
             this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
             this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
-            if( dashboard && dashboard.services && dashboard.services.filter ) {
-                // compatiblity hack
+
+            if(dashboard.services && dashboard.services.filter) {
                 this.time = dashboard.services.filter.time;
                 this.time = dashboard.services.filter.time;
+                this.templateParameters = dashboard.services.filter.list || [];
+                this._updateTemplateData(true);
             }
             }
 
 
         }
         }
-    }; 
+    };
     return result;
     return result;
   });
   });