diff --git a/lib/datadistributor.js b/lib/datadistributor.js index 32e5c1c..ea0bf75 100644 --- a/lib/datadistributor.js +++ b/lib/datadistributor.js @@ -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) { diff --git a/lib/filters/genericnode.js b/lib/filters/genericnode.js index cef74c6..ca43a38 100644 --- a/lib/filters/genericnode.js +++ b/lib/filters/genericnode.js @@ -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 }; }; });