[TASK] Remove instead of add filter twice
This commit is contained in:
parent
b9252c864f
commit
6a3986e588
@ -54,10 +54,21 @@ define(['filters/nodefilter'], function (NodeFilter) {
|
||||
}
|
||||
|
||||
function addFilter(d) {
|
||||
filters.push(d);
|
||||
notifyObservers();
|
||||
d.setRefresh(refresh);
|
||||
refresh();
|
||||
var newItem = true;
|
||||
|
||||
filters.forEach(function (f) {
|
||||
if (f.getKey && f.getKey() === d.getKey()) {
|
||||
removeFilter(f);
|
||||
newItem = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (newItem) {
|
||||
filters.push(d);
|
||||
notifyObservers();
|
||||
d.setRefresh(refresh);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
function removeFilter(d) {
|
||||
|
@ -49,10 +49,15 @@ define(['helper'], function (helper) {
|
||||
};
|
||||
}
|
||||
|
||||
function getKey() {
|
||||
return value.concat(name);
|
||||
}
|
||||
|
||||
return {
|
||||
run: run,
|
||||
setRefresh: setRefresh,
|
||||
render: render
|
||||
render: render,
|
||||
getKey: getKey
|
||||
};
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user