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 |
|
|
Ext.define('sitools.admin.datasets.DictionaryWin', {
|
29 |
|
|
extend : 'Ext.Window',
|
30 |
|
|
alias : 'widget.s-datasetsdictionary',
|
31 |
|
|
width : 700,
|
32 |
|
|
height : 480,
|
33 |
|
|
modal : true,
|
34 |
|
|
pageSize : ADMIN_PANEL_NB_ELEMENTS,
|
35 |
|
|
|
36 |
|
|
initComponent : function () {
|
37 |
|
|
this.title = i18n.get('label.dictionary');
|
38 |
|
|
|
39 |
|
|
this.httpProxy = new Ext.data.HttpProxy({
|
40 |
|
|
url : this.urlDictionary,
|
41 |
|
|
restful : true,
|
42 |
|
|
method : 'GET'
|
43 |
|
|
});
|
44 |
|
|
this.storeNotion = new Ext.data.JsonStore({
|
45 |
|
|
id : 'storeNotionSelect',
|
46 |
|
|
root : 'dictionary.notions',
|
47 |
|
|
idProperty : 'id',
|
48 |
|
|
proxy : this.httpProxy,
|
49 |
|
|
fields : [ {
|
50 |
|
|
name : 'id',
|
51 |
|
|
type : 'string'
|
52 |
|
|
}, {
|
53 |
|
|
name : 'name',
|
54 |
|
|
type : 'string'
|
55 |
|
|
}, {
|
56 |
|
|
name : 'unit',
|
57 |
|
|
type : 'string'
|
58 |
|
|
}, {
|
59 |
|
|
name : 'description',
|
60 |
|
|
type : 'string'
|
61 |
|
|
}, {
|
62 |
|
|
name : 'type',
|
63 |
|
|
type : 'string'
|
64 |
|
|
}, {
|
65 |
|
|
name : 'dictionaryId',
|
66 |
|
|
type : 'string'
|
67 |
|
|
} ]
|
68 |
|
|
});
|
69 |
|
|
|
70 |
|
|
this.cmNotion = new Ext.grid.ColumnModel({
|
71 |
|
|
columns : [ {
|
72 |
|
|
header : i18n.get('headers.id'),
|
73 |
|
|
dataIndex : 'id',
|
74 |
|
|
width : 100
|
75 |
|
|
}, {
|
76 |
|
|
header : i18n.get('headers.name'),
|
77 |
|
|
dataIndex : 'name',
|
78 |
|
|
width : 100
|
79 |
|
|
}, {
|
80 |
|
|
header : i18n.get('headers.unit'),
|
81 |
|
|
dataIndex : 'unit',
|
82 |
|
|
width : 100
|
83 |
|
|
}, {
|
84 |
|
|
header : i18n.get('headers.type'),
|
85 |
|
|
dataIndex : 'type',
|
86 |
|
|
width : 50
|
87 |
|
|
}, {
|
88 |
|
|
header : i18n.get('headers.description'),
|
89 |
|
|
dataIndex : 'description',
|
90 |
|
|
width : 100
|
91 |
|
|
} ],
|
92 |
|
|
defaults : {
|
93 |
|
|
sortable : true,
|
94 |
|
|
width : 100
|
95 |
|
|
}
|
96 |
|
|
});
|
97 |
|
|
|
98 |
|
|
this.smNotion = Ext.create('Ext.selection.RowModel',{
|
99 |
|
|
mode : 'SINGLE'
|
100 |
|
|
});
|
101 |
|
|
|
102 |
|
|
this.gridNotion = new Ext.grid.EditorGridPanel({
|
103 |
|
|
id : 'gridNotionSelect',
|
104 |
|
|
title : i18n.get('title.gridNotion'),
|
105 |
|
|
layout : 'fit',
|
106 |
|
|
height : 350,
|
107 |
|
|
autoScroll : true,
|
108 |
|
|
store : this.storeNotion,
|
109 |
|
|
cm : this.cmNotion,
|
110 |
|
|
selModel : this.smNotion
|
111 |
|
|
});
|
112 |
|
|
|
113 |
|
|
var storeDictionary = new Ext.data.JsonStore({
|
114 |
|
|
fields : [ 'id', 'name' ],
|
115 |
|
|
url : this.urlDictionary,
|
116 |
|
|
root : "data",
|
117 |
|
|
autoLoad : true
|
118 |
|
|
});
|
119 |
|
|
this.comboDictionary = new Ext.form.ComboBox({
|
120 |
|
|
store : storeDictionary,
|
121 |
|
|
displayField : 'name',
|
122 |
|
|
valueField : 'id',
|
123 |
|
|
typeAhead : true,
|
124 |
|
|
queryMode : 'local',
|
125 |
|
|
forceSelection : true,
|
126 |
|
|
triggerAction : 'all',
|
127 |
|
|
emptyText : 'Select a dictionary...',
|
128 |
|
|
selectOnFocus : true,
|
129 |
|
|
listeners : {
|
130 |
|
|
scope : this,
|
131 |
|
|
select : function (combo, rec, index) {
|
132 |
|
|
this.loadNotions(rec.data.id);
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
}
|
136 |
|
|
});
|
137 |
|
|
|
138 |
|
|
this.items = [ {
|
139 |
|
|
xtype : 'panel',
|
140 |
|
|
height : 450,
|
141 |
|
|
title : i18n.get('label.dictionarySelect'),
|
142 |
|
|
items : [ this.comboDictionary, this.gridNotion ],
|
143 |
|
|
buttons : [ {
|
144 |
|
|
text : i18n.get('label.ok'),
|
145 |
|
|
scope : this,
|
146 |
|
|
handler : this.onValidate
|
147 |
|
|
|
148 |
|
|
}, {
|
149 |
|
|
text : i18n.get('label.cancel'),
|
150 |
|
|
scope : this,
|
151 |
|
|
handler : function () {
|
152 |
|
|
this.close();
|
153 |
|
|
}
|
154 |
|
|
} ]
|
155 |
|
|
|
156 |
|
|
} ];
|
157 |
|
|
sitools.admin.datasets.DictionaryWin.superclass.initComponent.call(this);
|
158 |
|
|
},
|
159 |
|
|
loadNotions : function (dictionaryId) {
|
160 |
|
|
|
161 |
|
|
this.httpProxy.url = this.urlDictionary + dictionaryId;
|
162 |
|
|
this.gridNotion.getStore().load({
|
163 |
|
|
callback : function () {
|
164 |
|
|
this.gridNotion.getView().refresh();
|
165 |
|
|
},
|
166 |
|
|
scope : this
|
167 |
|
|
});
|
168 |
|
|
},
|
169 |
|
|
onValidate : function () {
|
170 |
|
|
var rec = this.gridNotion.getSelectionModel().getSelected();
|
171 |
|
|
this.recordColumn.data.notion = rec.data;
|
172 |
|
|
this.recordColumn.data.notion.url = this.urlDictionary + this.comboDictionary.getValue() + "/notions/" + rec.data.id;
|
173 |
|
|
|
174 |
|
|
this.viewColumn.refresh();
|
175 |
|
|
this.close();
|
176 |
|
|
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
}); |