filterSrv refactoring cleanup and testing

This commit is contained in:
Torkel Ödegaard
2014-05-20 16:18:24 +02:00
parent 5ea07d0f07
commit beca72cc40
2 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<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>
<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>
+8 -6
View File
@@ -16,7 +16,7 @@ define([
};
var result = {
_updateTemplateData : function( initial ) {
_updateTemplateData : function(initial) {
var _templateData = {};
_.each(this.templateParameters, function( templateParameter ) {
if (initial) {
@@ -29,7 +29,7 @@ define([
return;
}
_templateData[ templateParameter.name ] = templateParameter.current.value;
_templateData[templateParameter.name] = templateParameter.current.value;
});
this._templateData = _templateData;
},
@@ -92,17 +92,19 @@ define([
this.templateParameters = _.without( this.templateParameters, templateParameter );
},
init : function( dashboard ) {
init: function(dashboard) {
_.defaults(this, _d);
this.dashboard = dashboard;
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.templateParameters = dashboard.services.filter.list || [];
this._updateTemplateData(true);
}
}
};
};
return result;
});