blob: 0f2cdfb95f2f97fdc216c1aea83048d3e237092b (
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
37
38
39
40
41
42
43
|
import _ from 'underscore';
import Marionette from 'backbone.marionette';
import CustomRuleView from './custom-rule-view';
import CustomRuleCreationView from './custom-rule-creation-view';
import Template from '../templates/rule/coding-rules-custom-rules.hbs';
export default Marionette.CompositeView.extend({
template: Template,
childView: CustomRuleView,
childViewContainer: '#coding-rules-detail-custom-rules',
childViewOptions: function () {
return {
app: this.options.app,
templateRule: this.model
};
},
modelEvents: {
'change': 'render'
},
events: {
'click .js-create-custom-rule': 'createCustomRule'
},
onRender: function () {
this.$el.toggleClass('hidden', !this.model.get('isTemplate'));
},
createCustomRule: function () {
new CustomRuleCreationView({
app: this.options.app,
templateRule: this.model
}).render();
},
serializeData: function () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite
});
}
});
|