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
44
45
|
define([
'coding-rules/rule/custom-rule-view',
'coding-rules/rule/custom-rule-creation-view',
'templates/coding-rules'
], function (CustomRuleView, CustomRuleCreationView) {
return Marionette.CompositeView.extend({
template: Templates['coding-rules-custom-rules'],
itemView: CustomRuleView,
itemViewContainer: '#coding-rules-detail-custom-rules',
itemViewOptions: 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
});
}
});
});
|