Skip to content

Commit

Permalink
[#1792] Fix bug where we were unable to remove filters
Browse files Browse the repository at this point in the history
Instead of removing the filters, we were setting them to `undefined`.
  • Loading branch information
vitorbaptista committed Jun 26, 2014
1 parent 09170d8 commit 223e1df
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ckan/public/base/javascript/modules/resource-view-filters.js
Expand Up @@ -108,6 +108,9 @@ this.ckan.module('resource-view-filters', function (jQuery, _) {
currentFilters = ckan.views.viewhelpers.filters.get(filterName) || [],
addToIndex = currentFilters.length;

// Make sure we're not editing the original array, but a copy.
currentFilters = currentFilters.slice();

if (evt.removed) {
addToIndex = currentFilters.indexOf(evt.removed.id);
if (addToIndex !== -1) {
Expand All @@ -118,7 +121,11 @@ this.ckan.module('resource-view-filters', function (jQuery, _) {
currentFilters.splice(addToIndex, 0, filterValue);
}

ckan.views.viewhelpers.filters.set(filterName, currentFilters);
if (currentFilters.length > 0) {
ckan.views.viewhelpers.filters.set(filterName, currentFilters);
} else {
ckan.views.viewhelpers.filters.unset(filterName);
}
}

return {
Expand Down

0 comments on commit 223e1df

Please sign in to comment.