79aef93f by Adam Heath

Improve the api, by having applyQueryParameters() call resetParameters,

instead of resetSearch.
1 parent 14fb6444
......@@ -210,6 +210,12 @@ define(function(require) {
}
return Facet.__super__.initialize.apply(this, arguments);
},
resetSearch: function(options) {
this.get('items').invoke('reset', null, options);
},
resetParameters: function(options) {
this.get('items').invoke('set', {checked: false}, options);
},
applyFacetResults: function(facetName, data, options) {
options = options || {};
var facetCounts = Util.getField(data, 'facet_counts');
......
......@@ -46,9 +46,10 @@ define(function(require) {
return Facets.__super__.initialize.apply(this, arguments);
},
resetSearch: function(options) {
_.each(this.values(), function(facet) {
facet.get('items').reset(null, options);
});
_.invoke(this.values(), 'resetSearch', options);
},
resetParameters: function(options) {
_.invoke(this.values(), 'resetParameters', options);
},
applyFacetResults: function(data, options) {
options = options || {};
......
......@@ -10,6 +10,9 @@ define(function(require) {
fields: null,
multi: false
},
resetParameters: function(options) {
this.set({query: null, queries: []}, options);
},
});
return QueryTextField;
});
......
......@@ -11,6 +11,13 @@ define(function(require) {
//var module = require('module');
var QueryTextFields = Backbone.Model.extend({
initialize: function(data, options) {
},
resetParameters: function(options) {
_.invoke(this.values(), 'resetParameters', options);
},
});
var Solr = Pagination.extend({
url: function url() {
return this.constructor.selectUrl;
......@@ -25,7 +32,7 @@ define(function(require) {
formNameMap[formName] = facet;
}
});
var queryFields = new Backbone.Model();
var queryFields = new QueryTextFields();
_.each(constructor.queryTextFields, function(definition, queryName) {
var qtf = new QueryTextField({formName: definition.formName, name: queryName, queries: [], fields: definition.fields, multi: !!definition.multi});
var formName = qtf.get('formName');
......@@ -49,13 +56,8 @@ define(function(require) {
var skipOptions = {skipSearch: true};
var parts = document.location.href.match(/.*\?(.*)/);
var facets = this.get('facets');
facets.resetSearch();
_.each(this.get('queryFields').values(), function(qtf) {
qtf.set({
query: null,
queries: [],
}, skipOptions);
});
facets.resetParameters(skipOptions);
this.get('queryFields').resetParameters(skipOptions);
if (parts) {
var formNameMap = this.get('formNameMap');
......