blob: 0b1216ca4bdf279247bbadfceab1ce83c5f68b38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import _ from 'underscore';
import BaseFacet from './base-facet';
import Template from '../templates/facets/coding-rules-query-facet.hbs';
export default BaseFacet.extend({
template: Template,
events: function () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'submit form': 'onFormSubmit'
});
},
onRender: function () {
this.$el.attr('data-property', this.model.get('property'));
var query = this.options.app.state.get('query'),
value = query.q;
if (value != null) {
this.$('input').val(value);
}
},
onFormSubmit: function (e) {
e.preventDefault();
this.applyFacet();
},
applyFacet: function () {
var obj = {},
property = this.model.get('property');
obj[property] = this.$('input').val();
this.options.app.state.updateFilter(obj, { force: true });
}
});
|