1 |
d2a8c3fd
|
Marc NICOLAS
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
Ext.namespace('sitools.admin.menu');
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
Ext.define('sitools.admin.menu.seeAlso', { extend : 'Ext.view.View',
|
33 |
|
|
|
34 |
|
|
id: 'links',
|
35 |
|
|
|
36 |
|
|
itemSelector: 'div.links',
|
37 |
|
|
overClass : 'links-hover',
|
38 |
|
|
singleSelect: true,
|
39 |
|
|
multiSelect : false,
|
40 |
|
|
autoScroll : false,
|
41 |
|
|
|
42 |
|
|
initComponent : function () {
|
43 |
|
|
|
44 |
|
|
var tpl = new Ext.XTemplate(
|
45 |
|
|
'<div class="title-seeAlso">See Also...</div>',
|
46 |
|
|
'<tpl for=".">',
|
47 |
|
|
'<tpl if="this.isNotEmpty(links)">',
|
48 |
|
|
'<tpl for="links">',
|
49 |
|
|
'<div id="{nodeName}" name="{text}" class="links">',
|
50 |
|
|
'<img class="icon-seeAlso" width="16" height="16" src="{iconMenu}" />',
|
51 |
|
|
'<span id="{nodeName}">{label}</span>',
|
52 |
|
|
'</div>',
|
53 |
|
|
'</tpl>',
|
54 |
|
|
'</tpl>',
|
55 |
|
|
'</tpl>',
|
56 |
|
|
{
|
57 |
|
|
compiled : true,
|
58 |
|
|
isNotEmpty : function (children) {
|
59 |
|
|
return !Ext.isEmpty(children);
|
60 |
|
|
},
|
61 |
|
|
isEmpty : function (children) {
|
62 |
|
|
return Ext.isEmpty(children);
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
);
|
66 |
|
|
this.tpl = tpl;
|
67 |
|
|
this.height = Ext.getBody().getSize().height - 220;
|
68 |
|
|
|
69 |
|
|
this.listeners = {
|
70 |
|
|
click : function (t, ind, node, e) {
|
71 |
|
|
var nodeName = node.id;
|
72 |
|
|
var title = node.attributes[1].textContent;
|
73 |
|
|
var rec = seeAlsoMenu.getStore().getAt(0);
|
74 |
|
|
var path = this.getPath(rec, title);
|
75 |
|
|
this.openSubCategory(t, title, e, nodeName, path);
|
76 |
|
|
}
|
77 |
|
|
};
|
78 |
|
|
|
79 |
|
|
this.store = new Ext.data.JsonStore({
|
80 |
|
|
root : '',
|
81 |
|
|
restful : true,
|
82 |
|
|
remoteSort : false,
|
83 |
|
|
fields : [
|
84 |
|
|
{name: 'nodeName'},
|
85 |
|
|
{name : 'id'},
|
86 |
|
|
{name : 'parentNode'},
|
87 |
|
|
{name : 'children'},
|
88 |
|
|
{name : 'iconMenu'},
|
89 |
|
|
{name : 'category'},
|
90 |
|
|
{name : 'links'},
|
91 |
|
|
{name : 'label'},
|
92 |
|
|
{name : 'path'}
|
93 |
|
|
]
|
94 |
|
|
});
|
95 |
|
|
|
96 |
|
|
this.allButtons = [];
|
97 |
|
|
|
98 |
|
|
sitools.admin.menu.seeAlso.superclass.initComponent.call(this);
|
99 |
|
|
},
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
getPath : function (rec, title) {
|
109 |
|
|
var reg = new RegExp("/");
|
110 |
|
|
|
111 |
|
|
for (var i = 0; i < rec.data.links.length; i++){
|
112 |
|
|
if (rec.data.links[i].text == title){
|
113 |
|
|
var pathTab = rec.data.links[i].path.split(reg);
|
114 |
|
|
return pathTab;
|
115 |
|
|
}
|
116 |
|
|
}
|
117 |
|
|
},
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
openSubCategory : function (t, title, e, nodeName, path) {
|
129 |
|
|
dataViewMenu.allButtons = [];
|
130 |
|
|
|
131 |
|
|
var isAddable = this.populateStore(t, title);
|
132 |
|
|
var toolbar = mainPanel.toolbars[0];
|
133 |
|
|
var textRoot = toolbar.items.items[0].text;
|
134 |
|
|
|
135 |
|
|
toolbar.removeAll();
|
136 |
|
|
toolbar.addText(textRoot);
|
137 |
|
|
toolbar.addSeparator();
|
138 |
|
|
this.addRootButton();
|
139 |
|
|
|
140 |
|
|
for (var i = 0; i < path.length; i++){
|
141 |
|
|
var button = {
|
142 |
|
|
xtype : 'button',
|
143 |
|
|
text : path[i],
|
144 |
|
|
id : path[i] + 'Id',
|
145 |
|
|
scope : t,
|
146 |
|
|
path : path,
|
147 |
|
|
handler : function (btn, e) {
|
148 |
|
|
this.populateStore(this, btn.getText());
|
149 |
|
|
|
150 |
|
|
dataViewMenu.deleteItemsFromToolbar(mainPanel.toolbars[0], btn.getText(), path);
|
151 |
|
|
dataViewWin.show();
|
152 |
|
|
mainPanel.getTopToolbar().show();
|
153 |
|
|
var dataViewEl = dataViewWin.getEl();
|
154 |
|
|
dataViewEl.fadeIn({
|
155 |
|
|
opacity: 0.95,
|
156 |
|
|
easing: 'easeOut',
|
157 |
|
|
duration: 0.5
|
158 |
|
|
});
|
159 |
|
|
}
|
160 |
|
|
};
|
161 |
|
|
this.addButton (button, toolbar);
|
162 |
|
|
}
|
163 |
|
|
mainPanel.doLayout();
|
164 |
|
|
|
165 |
|
|
if (!isAddable) {
|
166 |
|
|
this.treeAction(title, nodeName);
|
167 |
|
|
}
|
168 |
|
|
},
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
addButton : function (btn, toolbar) {
|
177 |
|
|
toolbar.add(btn);
|
178 |
|
|
toolbar.addSeparator();
|
179 |
|
|
dataViewMenu.allButtons.push(btn);
|
180 |
|
|
},
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
addRootButton : function () {
|
186 |
|
|
var button = {
|
187 |
|
|
xtype : 'button',
|
188 |
|
|
text : 'root',
|
189 |
|
|
id : 'rootId',
|
190 |
|
|
scope : this,
|
191 |
|
|
handler : function (btn, e) {
|
192 |
|
|
this.populateStore(this, btn.getText());
|
193 |
|
|
dataViewMenu.deleteItemsFromToolbar(mainPanel.toolbars[0], btn.getText());
|
194 |
|
|
dataViewWin.show();
|
195 |
|
|
mainPanel.getTopToolbar().show();
|
196 |
|
|
var dataViewEl = dataViewWin.getEl();
|
197 |
|
|
dataViewEl.fadeIn({
|
198 |
|
|
opacity: 0.95,
|
199 |
|
|
easing: 'easeOut',
|
200 |
|
|
duration: 0.5
|
201 |
|
|
});
|
202 |
|
|
}
|
203 |
|
|
};
|
204 |
|
|
|
205 |
|
|
this.addButton (button, mainPanel.toolbars[0]);
|
206 |
|
|
mainPanel.doLayout();
|
207 |
|
|
},
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
populateStore : function (t, title) {
|
217 |
|
|
var children = t.getChildrenByParentNode(dataViewMenu.allData, title);
|
218 |
|
|
if (!Ext.isEmpty(children)) {
|
219 |
|
|
t.store.removeAll();
|
220 |
|
|
|
221 |
|
|
dataViewMenu.store.removeAll();
|
222 |
|
|
dataViewMenu.store.loadData(children);
|
223 |
|
|
return true;
|
224 |
|
|
}
|
225 |
|
|
else {
|
226 |
|
|
return false;
|
227 |
|
|
}
|
228 |
|
|
},
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
getChildrenByParentNode : function (data, parentNode) {
|
238 |
|
|
if (Ext.isEmpty(data)) {
|
239 |
|
|
return null;
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
if (parentNode == 'root') {
|
243 |
|
|
return data;
|
244 |
|
|
}
|
245 |
|
|
else {
|
246 |
|
|
for (var i = 0; i < data.length; i++) {
|
247 |
|
|
if (data[i].text == parentNode) {
|
248 |
|
|
return data[i].children;
|
249 |
|
|
|
250 |
|
|
}
|
251 |
|
|
else {
|
252 |
|
|
var tmp = this.getChildrenByParentNode(data[i].children, parentNode);
|
253 |
|
|
if (!Ext.isEmpty(tmp)) {
|
254 |
|
|
return tmp;
|
255 |
|
|
}
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
|
|
}
|
259 |
|
|
},
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
treeAction : function (title, nodeName) {
|
268 |
|
|
|
269 |
|
|
var nodeId = title + 'id';
|
270 |
|
|
|
271 |
|
|
if (!Ext.isDefined(nodeName)) {
|
272 |
|
|
Ext.Msg.alert('warning', 'Undefined');
|
273 |
|
|
return;
|
274 |
|
|
}
|
275 |
|
|
var selectedNode = this.getSelectedRecords()[0];
|
276 |
|
|
|
277 |
|
|
if (!Ext.ComponentMgr.isRegistered('s-' + nodeName)) {
|
278 |
|
|
Ext.Msg.alert('warning', 'label.component' + ' \'' + 's-' + nodeName + '\' ' + 'msg.undefined');
|
279 |
|
|
return;
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
var pan_config = new sitools.admin.menu.dataView();
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
mainPanel.removeAll();
|
287 |
|
|
mainPanel.add({
|
288 |
|
|
width: "100%",
|
289 |
|
|
items : [ {
|
290 |
|
|
xtype : 's-box',
|
291 |
|
|
label : i18n.get('label.' + nodeName),
|
292 |
|
|
items : [ {
|
293 |
|
|
xtype : 's-' + nodeName,
|
294 |
|
|
sitoolsType : "mainAdminPanel"
|
295 |
|
|
} ],
|
296 |
|
|
idItem : nodeId
|
297 |
|
|
} ],
|
298 |
|
|
listeners : {
|
299 |
|
|
resize : function (panel, width, height) {
|
300 |
|
|
var size = panel.items.items[0].body.getSize();
|
301 |
|
|
var sBoxTitle = panel.items.items[0].items.items[0].getEl();
|
302 |
|
|
size = {
|
303 |
|
|
height : size.height - (sBoxTitle.getHeight() + sBoxTitle.getMargin("t") + sBoxTitle.getMargin("b")),
|
304 |
|
|
width : size.width - 8
|
305 |
|
|
};
|
306 |
|
|
var mainAdminPanel = panel.find("sitoolsType", "mainAdminPanel");
|
307 |
|
|
mainAdminPanel[0].setSize(size);
|
308 |
|
|
}
|
309 |
|
|
}
|
310 |
|
|
});
|
311 |
|
|
var helpPanel = new Ext.ux.ManagedIFrame.Panel({
|
312 |
|
|
id : ID.PANEL.HELP,
|
313 |
|
|
width : "100%",
|
314 |
|
|
flex : 1,
|
315 |
|
|
|
316 |
|
|
defaultSrc : loadUrl.get('APP_URL') + "/client-admin/res/help/" + LOCALE + "/" + nodeName + ".html",
|
317 |
|
|
defaults : {
|
318 |
|
|
padding : 10
|
319 |
|
|
}
|
320 |
|
|
});
|
321 |
|
|
mainPanel.add(
|
322 |
|
|
helpPanel
|
323 |
|
|
);
|
324 |
|
|
mainPanel.doLayout();
|
325 |
|
|
helpPanel.setVisible(SHOW_HELP);
|
326 |
|
|
|
327 |
|
|
helpUrl = loadUrl.get('APP_URL') + "/client-admin/res/help/" + LOCALE + "/" + nodeName + ".html";
|
328 |
|
|
mainPanel.getTopToolbar().show();
|
329 |
|
|
dataViewWin.hide();
|
330 |
|
|
|
331 |
|
|
}
|
332 |
|
|
}); |