git_sitools_idoc / flarecast / workspace / client-admin / js / datasets / DictionaryWin.js @ master
1 |
/***************************************
|
---|---|
2 |
* Copyright 2010-2014 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
|
3 |
*
|
4 |
* This file is part of SITools2.
|
5 |
*
|
6 |
* SITools2 is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* SITools2 is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with SITools2. If not, see <http://www.gnu.org/licenses/>.
|
18 |
***************************************/
|
19 |
/*global Ext, sitools, ID, i18n, document, showResponse, alertFailure, LOCALE, ImageChooser,
|
20 |
showHelp*/
|
21 |
Ext.namespace('sitools.admin.datasets');
|
22 |
|
23 |
/**
|
24 |
* @deprecated
|
25 |
* @class sitools.admin.datasets.DictionaryWin
|
26 |
* @extends Ext.Window
|
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 |
// alert (dictionaryId);
|
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 |
//this.recordColumn.data.notionDescription = rec.data.description;
|
174 |
this.viewColumn.refresh();
|
175 |
this.close();
|
176 |
|
177 |
} |
178 |
|
179 |
}); |