PlotLayoutForm.js
2.8 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* Project : AMDA-NG
* Name : PlotLayoutForm.js
* @class amdaPlotComp.PlotLayoutForm
* @extends amdaPlotComp.PlotStandardForm
* @brief Form to define layout options
* @author Benjamin Renard
* @version $Id: PlotLayoutForm.js benjamin $
*/
Ext.define('amdaPlotComp.PlotLayoutForm', {
extend: 'amdaPlotComp.PlotStandardForm',
requires: [
'amdaPlotComp.PlotLayoutVerticalForm',
'amdaPlotComp.PlotLayoutAutoForm',
'amdaPlotComp.PlotLayoutManualForm'
],
layoutOptionsContainer: null,
layoutOptionsFormsManager : new Ext.AbstractManager(),
destroy: function() {
this.layoutOptionsFormsManager.each(function (key, value, length) {
this.layoutOptionsFormsManager.unregister(value);
value.destroy();
}, this);
this.callParent();
},
setObject : function(object) {
this.object = object;
this.loadRecord(this.object);
this.updateLayoutOptions();
},
getLayoutOptionsForm: function(type) {
var formId = '';
if (!type || (type == ''))
formId = 'none';
else
formId = type;
formId += '-layout-options-form';
if (!this.layoutOptionsFormsManager.get(formId))
{
switch(type)
{
//Create layout options form
case 'vertical' :
this.layoutOptionsFormsManager.register(new amdaPlotComp.PlotLayoutVerticalForm({id : formId}));
break;
case 'auto' :
this.layoutOptionsFormsManager.register(new amdaPlotComp.PlotLayoutAutoForm({id : formId}));
break;
case 'manual' :
this.layoutOptionsFormsManager.register(new amdaPlotComp.PlotLayoutManualForm({id : formId}));
break;
default :
this.layoutOptionsFormsManager.register(new Ext.form.Label({id : formId, text: 'No available options for this layout type'}));
}
}
return this.layoutOptionsFormsManager.get(formId);
},
updateLayoutOptions: function() {
var typeField = this.getForm().findField('page-layout-type');
var layoutType = typeField.getValue();
this.object.setLayout(layoutType);
this.layoutOptionsContainer.removeAll(false);
var layoutOptionsForm = this.getLayoutOptionsForm(layoutType);
this.layoutOptionsContainer.add(layoutOptionsForm);
layoutOptionsForm.crtTree = this.crtTree;
if (layoutOptionsForm.setObject)
layoutOptionsForm.setObject(this.object);
},
getFormItems: function() {
var me = this;
this.layoutOptionsContainer = Ext.create('Ext.container.Container', {
layout: 'fit'
});
return [
this.addStandardCombo('page-layout-type', 'Layout type', amdaDefaultConfigs.availablePageLayouts, function(name, value, oldValue) {
if (me.object.get('page-layout-type') != value)
{
me.updateLayoutOptions();
me.object.set('page-layout-type', value);
me.crtTree.refresh();
}
}),
this.layoutOptionsContainer
];
}
});