1
|
|
|
define(function(require) { |
2
|
|
|
'use strict'; |
3
|
|
|
|
4
|
|
|
var AttributeGroupTabsComponent; |
5
|
|
|
var mediator = require('oroui/js/mediator'); |
6
|
|
|
var BaseComponent = require('oroui/js/app/components/base/component'); |
7
|
|
|
var BaseCollection = require('oroui/js/app/models/base/collection'); |
8
|
|
|
var TabCollectionView = require('oroui/js/app/views/tab-collection-view'); |
9
|
|
|
|
10
|
|
|
AttributeGroupTabsComponent = BaseComponent.extend({ |
11
|
|
|
/** |
12
|
|
|
* @inheritDoc |
13
|
|
|
*/ |
14
|
|
|
constructor: function AttributeGroupTabsComponent() { |
15
|
|
|
AttributeGroupTabsComponent.__super__.constructor.apply(this, arguments); |
16
|
|
|
}, |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param {Object} options |
20
|
|
|
*/ |
21
|
|
|
initialize: function(options) { |
22
|
|
|
this.groups = new BaseCollection(options.data); |
23
|
|
|
|
24
|
|
|
var first = this.groups.first(); |
25
|
|
|
first.set('active', true); |
26
|
|
|
this.triggerGroupChange(first, true); |
27
|
|
|
|
28
|
|
|
this.view = new TabCollectionView({ |
29
|
|
|
el: options._sourceElement, |
30
|
|
|
animationDuration: 0, |
31
|
|
|
collection: this.groups |
32
|
|
|
}); |
33
|
|
|
|
34
|
|
|
this.listenTo(this.groups, 'change', this.onGroupChange); |
35
|
|
|
this.listenTo(this.groups, 'select', this.onGroupChange); |
36
|
|
|
}, |
37
|
|
|
|
38
|
|
|
onGroupChange: function(model) { |
39
|
|
|
if (model.get('active') === true) { |
40
|
|
|
this.triggerGroupChange(model); |
41
|
|
|
} |
42
|
|
|
}, |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Triggers global event via mediator and pass params to listeners |
46
|
|
|
* |
47
|
|
|
* @param {Backbone.Model} model |
48
|
|
|
* @param {boolean} initialize |
49
|
|
|
*/ |
50
|
|
|
triggerGroupChange: function(model, initialize) { |
51
|
|
|
mediator.trigger('entity-config:attribute-group:changed', model, initialize); |
52
|
|
|
} |
53
|
|
|
}); |
54
|
|
|
|
55
|
|
|
return AttributeGroupTabsComponent; |
56
|
|
|
}); |
57
|
|
|
|