1 |
d2a8c3fd
|
Marc NICOLAS
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
Ext.namespace('sitools.admin.datasets');
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
Ext.define('sitools.admin.datasets.UnitWin', {
|
31 |
|
|
extend : 'Ext.Window',
|
32 |
|
|
alias : 'widget.s-datasetsUnits',
|
33 |
|
|
width : 600,
|
34 |
|
|
height : 400,
|
35 |
|
|
modal : true,
|
36 |
|
|
pageSize : ADMIN_PANEL_NB_ELEMENTS,
|
37 |
|
|
|
38 |
|
|
initComponent : function () {
|
39 |
|
|
this.title = i18n.get('label.units');
|
40 |
|
|
|
41 |
|
|
this.storeUnits = Ext.create('Ext.data.JsonStore', {
|
42 |
|
|
id : 'storeUnitSelect',
|
43 |
|
|
proxy : {
|
44 |
|
|
type : 'ajax',
|
45 |
|
|
url : this.urlDimension,
|
46 |
|
|
reader : {
|
47 |
|
|
type : 'json',
|
48 |
|
|
root : 'dimension.sitoolsUnits',
|
49 |
|
|
idProperty : 'id'
|
50 |
|
|
}
|
51 |
|
|
},
|
52 |
|
|
fields : [{
|
53 |
|
|
name : 'label',
|
54 |
|
|
type : 'string'
|
55 |
|
|
}, {
|
56 |
|
|
name : 'unitName',
|
57 |
|
|
type : 'string'
|
58 |
|
|
}]
|
59 |
|
|
});
|
60 |
|
|
|
61 |
|
|
this.cmUnits = {
|
62 |
|
|
items : [{
|
63 |
|
|
header : i18n.get('headers.label'),
|
64 |
|
|
dataIndex : 'label',
|
65 |
|
|
width : 100
|
66 |
|
|
}],
|
67 |
|
|
defaults : {
|
68 |
|
|
sortable : true,
|
69 |
|
|
width : 100
|
70 |
|
|
}
|
71 |
|
|
};
|
72 |
|
|
|
73 |
|
|
this.smUnits = Ext.create('Ext.selection.RowModel', {
|
74 |
|
|
mode : 'SINGLE'
|
75 |
|
|
});
|
76 |
|
|
|
77 |
|
|
this.gridUnits = Ext.create('Ext.grid.Panel', {
|
78 |
|
|
id : 'gridUnitId',
|
79 |
|
|
title : i18n.get('title.unitList'),
|
80 |
|
|
autoScroll : true,
|
81 |
|
|
store : this.storeUnits,
|
82 |
|
|
columns : this.cmUnits,
|
83 |
|
|
selModel : this.smUnits,
|
84 |
|
|
forceFit : true,
|
85 |
|
|
region : "center"
|
86 |
|
|
});
|
87 |
|
|
|
88 |
|
|
var storeDimensions = Ext.create('Ext.data.JsonStore', {
|
89 |
|
|
autoLoad : true,
|
90 |
|
|
proxy : {
|
91 |
|
|
type : 'ajax',
|
92 |
|
|
url : this.urlDimension,
|
93 |
|
|
reader : {
|
94 |
|
|
type : 'json',
|
95 |
|
|
root : 'data'
|
96 |
|
|
}
|
97 |
|
|
},
|
98 |
|
|
fields : [ 'id', 'name', 'description' ]
|
99 |
|
|
});
|
100 |
|
|
|
101 |
|
|
this.cmDimensions = {
|
102 |
|
|
items : [{
|
103 |
|
|
header : i18n.get('headers.name'),
|
104 |
|
|
dataIndex : 'name',
|
105 |
|
|
width : 100
|
106 |
|
|
}, {
|
107 |
|
|
header : i18n.get('headers.description'),
|
108 |
|
|
dataIndex : 'description',
|
109 |
|
|
width : 100
|
110 |
|
|
}],
|
111 |
|
|
defaults : {
|
112 |
|
|
sortable : true,
|
113 |
|
|
width : 100
|
114 |
|
|
}
|
115 |
|
|
};
|
116 |
|
|
|
117 |
|
|
this.smDimensions = Ext.create('Ext.selection.RowModel', {
|
118 |
|
|
mode : 'SINGLE'
|
119 |
|
|
});
|
120 |
|
|
|
121 |
|
|
this.gridDimensions = Ext.create('Ext.grid.GridPanel', {
|
122 |
|
|
id : 'gridViewDimensionsId',
|
123 |
|
|
title : i18n.get('title.DimensionsList'),
|
124 |
|
|
region : "west",
|
125 |
|
|
autoScroll : true,
|
126 |
|
|
store : storeDimensions,
|
127 |
|
|
columns : this.cmDimensions,
|
128 |
|
|
selModel : this.smDimensions,
|
129 |
|
|
flex : 1,
|
130 |
|
|
forceFit : true,
|
131 |
|
|
listeners : {
|
132 |
|
|
scope : this,
|
133 |
|
|
itemClick : function (grid, record, item, rowIndex) {
|
134 |
|
|
|
135 |
|
|
var dimensionId = record.get('id');
|
136 |
|
|
this.loadUnits(dimensionId);
|
137 |
|
|
}
|
138 |
|
|
}
|
139 |
|
|
});
|
140 |
|
|
|
141 |
|
|
this.layout = "border";
|
142 |
|
|
this.items = [this.gridUnits, this.gridDimensions ];
|
143 |
|
|
|
144 |
|
|
this.buttons = [{
|
145 |
|
|
text : i18n.get('label.ok'),
|
146 |
|
|
scope : this,
|
147 |
|
|
handler : this.onValidate
|
148 |
|
|
}, {
|
149 |
|
|
text : i18n.get('label.cancel'),
|
150 |
|
|
scope : this,
|
151 |
|
|
handler : function () {
|
152 |
|
|
this.close();
|
153 |
|
|
}
|
154 |
|
|
}];
|
155 |
|
|
sitools.admin.datasets.UnitWin.superclass.initComponent.call(this);
|
156 |
|
|
},
|
157 |
|
|
|
158 |
|
|
loadUnits : function (dimensionId) {
|
159 |
|
|
this.storeUnits.getProxy().url = this.urlDimension + "/" + dimensionId;
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
this.storeUnits.load({
|
163 |
|
|
callback : function () {
|
164 |
|
|
this.gridUnits.getView().refresh();
|
165 |
|
|
},
|
166 |
|
|
scope : this
|
167 |
|
|
});
|
168 |
|
|
|
169 |
|
|
},
|
170 |
|
|
|
171 |
|
|
onValidate : function () {
|
172 |
|
|
var recUnit = this.gridUnits.getSelectionModel().getSelection()[0];
|
173 |
|
|
if (Ext.isEmpty(recUnit)) {
|
174 |
|
|
Ext.Msg.alert(i18n.get('label.error'), i18n.get('label.noSelection'));
|
175 |
|
|
return;
|
176 |
|
|
}
|
177 |
|
|
var recDimension = this.gridDimensions.getSelectionModel().getSelection()[0];
|
178 |
|
|
|
179 |
|
|
this.recordColumn.data.unit = recUnit.data;
|
180 |
|
|
this.recordColumn.data.dimensionId = recDimension.data.id;
|
181 |
|
|
|
182 |
|
|
this.viewColumn.refresh();
|
183 |
|
|
this.close();
|
184 |
|
|
}
|
185 |
|
|
});
|