Skip to content

Commit

Permalink
Bug: 14064 and Bug: 13643 Fix reordering of rules.
Browse files Browse the repository at this point in the history
Rules were properly reordered in the backend, and the dom id of
the rules was updated, but the existing links that contained the
rule number was not. This should fix any remaining ordering issues.
Note that this does not need to be merged up to Git master since that
code was already heavily refactored to use rule uids instead of sort
position.
  • Loading branch information
mrubinsk committed Jul 27, 2015
1 parent 9aac5e6 commit 7574ff7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ingo/js/filters.js
Expand Up @@ -41,9 +41,14 @@ var IngoFilters = {
rows = $('filterslist').select('DIV.filtersRow');
rows.invoke('writeAttribute', 'id', null);
rows.each(function(r) {
var a = r.select('a');
r.writeAttribute('id', 'filtersrow_' + (i++));
a.each(function(l) {
var href_new = IngoFilters.replaceQueryParam('rulenumber', i - 1, l.href);
href_new = IngoFilters.replaceQueryParam('edit', i - 1, href_new);
l.setAttribute('href', href_new);
});
});

$('filtersSave').fade({ duration: 0.2 });
}
}
Expand All @@ -52,6 +57,13 @@ var IngoFilters = {
tag: 'div'
});
}
},

// Adapted from http://stackoverflow.com/questions/1090948/change-url-parameters
replaceQueryParam: function(param, newval, search) {
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
var query = search.replace(regex, "$1").replace(/&$/, '');
return (query.length > 2 ? query + "&" : "?") + (param + "=" + newval);
}

};
Expand Down

0 comments on commit 7574ff7

Please sign in to comment.