[#264,bugfix,filtereditor][s]: track down and fix bug with addFilter (and hence filtereditor) - fixes #264.

* Quite a subtle bug due to the fact that we were not doing a deep copy on the filter template in addFilter
This commit is contained in:
Rufus Pollock
2012-11-08 20:35:03 +00:00
parent d479603ca7
commit ede211646a
3 changed files with 37 additions and 2 deletions

View File

@@ -495,7 +495,11 @@ my.Query = Backbone.Model.extend({
var ourfilter = JSON.parse(JSON.stringify(filter));
// not fully specified so use template and over-write
if (_.keys(filter).length <= 3) {
ourfilter = _.extend(this._filterTemplates[filter.type], ourfilter);
ourfilter = _.extend(
// crude deep copy
JSON.parse(JSON.stringify(this._filterTemplates[filter.type])),
ourfilter
);
}
var filters = this.get('filters');
filters.push(ourfilter);