Commit 47e4b771 by Torkel Ödegaard

lodash remove override fix, Fixes #1304

parent 7c6f0ad4
...@@ -14,10 +14,6 @@ function () { ...@@ -14,10 +14,6 @@ function () {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]); array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
return array; return array;
}, },
remove: function (array, index) {
array.splice(index, 1);
return array;
},
// If variable is value, then return alt. If variable is anything else, return value; // If variable is value, then return alt. If variable is anything else, return value;
toggle: function (variable, value, alt) { toggle: function (variable, value, alt) {
return variable === value ? alt : value; return variable === value ? alt : value;
......
...@@ -27,28 +27,27 @@ function (angular, _) { ...@@ -27,28 +27,27 @@ function (angular, _) {
this.list = []; this.list = [];
this.set = function(title,text,severity,timeout) { this.set = function(title,text,severity,timeout) {
var var newAlert = {
_a = { title: title || '',
title: title || '', text: $sce.trustAsHtml(text || ''),
text: $sce.trustAsHtml(text || ''), severity: severity || 'info',
severity: severity || 'info', };
},
_ca = angular.toJson(_a), var newAlertJson = angular.toJson(newAlert);
_clist = _.map(self.list,function(alert) {return angular.toJson(alert);});
// If we already have this alert, remove it and add a new one
// Why do this instead of skipping the add because it resets the timer
if(_.contains(_clist,_ca)) {
_.remove(self.list,_.indexOf(_clist,_ca));
}
self.list.push(_a); // remove same alert if it already exists
_.remove(self.list, function(value) {
return angular.toJson(value) === newAlertJson;
});
self.list.push(newAlert);
if (timeout > 0) { if (timeout > 0) {
$timeout(function() { $timeout(function() {
self.list = _.without(self.list,_a); self.list = _.without(self.list,newAlert);
}, timeout); }, timeout);
} }
return(_a);
return(newAlert);
}; };
this.clear = function(alert) { this.clear = function(alert) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment