1 |
43a2f5b2
|
Alessandro_N
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
Ext.namespace('sitools.user.component.dataviews');
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
sitools.user.component.dataviews.dataviewUtils = {
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
getFormParamsFromRecsSelected : function (recSelected) {
|
38 |
|
|
var rec = recSelected[0], result = {};
|
39 |
|
|
var primaryKeyName = "";
|
40 |
|
|
Ext.each(rec.fields.items, function (field) {
|
41 |
|
|
if (field.primaryKey) {
|
42 |
|
|
primaryKeyName = field.name;
|
43 |
|
|
}
|
44 |
|
|
});
|
45 |
|
|
if (Ext.isEmpty(primaryKeyName)) {
|
46 |
|
|
Ext.Msg.alert(i18n.get('label.error'), i18n.get('label.noPrimaryKey'));
|
47 |
|
|
return;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
var primaryKeyValues = [];
|
51 |
|
|
Ext.each(recSelected, function (record) {
|
52 |
|
|
primaryKeyValues.push(record.get(primaryKeyName));
|
53 |
|
|
});
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
result["p[0]"] = "LISTBOXMULTIPLE|" + primaryKeyName + "|" + primaryKeyValues.join("|");
|
57 |
|
|
return result;
|
58 |
|
|
},
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
getRendererLiveGrid : function (item, dataviewConfig) {
|
68 |
|
|
var renderer;
|
69 |
|
|
if (!Ext.isEmpty(item.columnRenderer)) {
|
70 |
|
|
renderer = function (value, metadata, record, rowIndex, colIndex,
|
71 |
|
|
store) {
|
72 |
|
|
if (!Ext.isEmpty(value)) {
|
73 |
|
|
if (!Ext.isEmpty(item.columnRenderer.toolTip)){
|
74 |
|
|
metadata.attr = 'ext:qtip="' + item.columnRenderer.toolTip + '"';
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
var imageStyle = "max-width:" + (item.width - 10) + "px;";
|
78 |
|
|
if (!Ext.isEmpty(dataviewConfig) && !Ext.isEmpty(dataviewConfig.lineHeight)) {
|
79 |
|
|
imageStyle += "max-height: " + (dataviewConfig.lineHeight - 10) + "px;";
|
80 |
|
|
}
|
81 |
|
|
var html = sitools.user.component.dataviews.dataviewUtils.getRendererHTML(item, imageStyle );
|
82 |
|
|
var str;
|
83 |
|
|
if (!Ext.isEmpty(html)) {
|
84 |
|
|
if (item.columnRenderer.behavior == ColumnRendererEnum.IMAGE_FROM_SQL) {
|
85 |
|
|
var imageUrl = record.get(item.columnRenderer.columnAlias);
|
86 |
|
|
str = String.format(html, value, imageUrl);
|
87 |
|
|
} else {
|
88 |
|
|
str = String.format(html, value);
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
return str;
|
92 |
|
|
} else {
|
93 |
|
|
return value;
|
94 |
|
|
}
|
95 |
|
|
};
|
96 |
|
|
} else {
|
97 |
|
|
renderer = function (value) {
|
98 |
|
|
var valueFormat = value;
|
99 |
|
|
if (sql2ext.get(item.sqlColumnType) == 'dateAsString') {
|
100 |
|
|
valueFormat = sitools.user.component.dataviews.dataviewUtils.formatDate(
|
101 |
|
|
value, item);
|
102 |
|
|
}
|
103 |
|
|
if (sql2ext.get(item.sqlColumnType) == 'boolean') {
|
104 |
|
|
valueFormat = value ? i18n.get('label.true') : i18n
|
105 |
|
|
.get('label.false');
|
106 |
|
|
}
|
107 |
|
|
return valueFormat;
|
108 |
|
|
};
|
109 |
|
|
}
|
110 |
|
|
return renderer;
|
111 |
|
|
},
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
getRendererDataView : function (col, style, dataviewConfig) {
|
123 |
|
|
var tplString = "", value, behavior, label, valueDisplayed;
|
124 |
|
|
var columnRenderer = col.columnRenderer;
|
125 |
|
|
if (!Ext.isEmpty(columnRenderer)) {
|
126 |
|
|
behavior = columnRenderer.behavior;
|
127 |
|
|
var html = sitools.user.component.dataviews.dataviewUtils.getRendererHTML(col, dataviewConfig);
|
128 |
|
|
switch (behavior) {
|
129 |
|
|
case ColumnRendererEnum.URL_LOCAL :
|
130 |
|
|
case ColumnRendererEnum.URL_EXT_NEW_TAB :
|
131 |
|
|
case ColumnRendererEnum.URL_EXT_DESKTOP :
|
132 |
|
|
|
133 |
|
|
case ColumnRendererEnum.DATASET_ICON_LINK :
|
134 |
|
|
if (!Ext.isEmpty(columnRenderer.linkText)) {
|
135 |
|
|
tplString += String.format("<tpl if=\"this.isNotEmpty({0})\">", col.columnAlias);
|
136 |
|
|
value = String.format(html, "{" + col.columnAlias + "}");
|
137 |
|
|
tplString += String.format('<span class="dataview_columnValue"><div class=x-view-entete style="{2}">{0} </div> {1}</span>', col.header, value, style);
|
138 |
|
|
tplString += "</tpl>";
|
139 |
|
|
tplString += String.format("<tpl if=\"this.isEmpty({0})\">", col.columnAlias);
|
140 |
|
|
value = "";
|
141 |
|
|
tplString += String.format('<span class="dataview_columnValue"><div class=x-view-entete style="{2}">{0} </div> {1}</span>', col.header, value, style);
|
142 |
|
|
tplString += "</tpl>";
|
143 |
|
|
} else if (!Ext.isEmpty(columnRenderer.image)) {
|
144 |
|
|
tplString += String.format("<tpl if=\"this.isNotEmpty({0})\">", col.columnAlias);
|
145 |
|
|
tplString += String.format('<li class="img-link" ext:qtip="{0}">', col.header);
|
146 |
|
|
tplString += String.format(html, "{" + col.columnAlias + "}");
|
147 |
|
|
tplString += '</li></tpl>';
|
148 |
|
|
}
|
149 |
|
|
break;
|
150 |
|
|
case ColumnRendererEnum.IMAGE_THUMB_FROM_IMAGE :
|
151 |
|
|
tplString += String.format("<tpl if=\"this.isNotEmpty({0})\">", col.columnAlias);
|
152 |
|
|
tplString += String.format('<li class="img-link" ext:qtip="{0}">', col.header);
|
153 |
|
|
tplString += String.format(html, "{" + col.columnAlias + "}");
|
154 |
|
|
tplString += '</li></tpl>';
|
155 |
|
|
break;
|
156 |
|
|
case ColumnRendererEnum.IMAGE_FROM_SQL :
|
157 |
|
|
var imageUrl = "";
|
158 |
|
|
if (!Ext.isEmpty(columnRenderer.url)) {
|
159 |
|
|
imageUrl = columnRenderer.url;
|
160 |
|
|
} else if (!Ext.isEmpty(columnRenderer.columnAlias)) {
|
161 |
|
|
imageUrl = "{" + columnRenderer.columnAlias + "}";
|
162 |
|
|
}
|
163 |
|
|
tplString += String.format("<tpl if=\"this.isNotEmpty({0})\">", col.columnAlias);
|
164 |
|
|
tplString += String.format('<li class="img-link" ext:qtip="{0}">', col.header, imageUrl);
|
165 |
|
|
tplString += String.format(html, "{" + col.columnAlias + "}", imageUrl);
|
166 |
|
|
tplString += '</li></tpl>';
|
167 |
|
|
break;
|
168 |
|
|
default :
|
169 |
|
|
tplString += String.format("<tpl if=\"this.isNotEmpty({0})\">", col.columnAlias);
|
170 |
|
|
value = String.format(html, "{" + col.columnAlias + "}");
|
171 |
|
|
tplString += String.format('<span class="dataview_columnValue"><div class=x-view-entete style="{2}">{0} </div> {1}</span>', col.header, value, style);
|
172 |
|
|
tplString += "</tpl>";
|
173 |
|
|
tplString += String.format("<tpl if=\"this.isEmpty({0})\">", col.columnAlias);
|
174 |
|
|
value = "";
|
175 |
|
|
tplString += String.format('<span class="dataview_columnValue"><div class=x-view-entete style="{2}">{0} </div> {1}</span>', col.header, value, style);
|
176 |
|
|
tplString += "</tpl>";
|
177 |
|
|
break;
|
178 |
|
|
}
|
179 |
|
|
} else {
|
180 |
|
|
if (sql2ext.get(col.sqlColumnType) == 'dateAsString') {
|
181 |
|
|
tplString += String.format('<span class="dataview_columnValue"><div class=x-view-entete style="{2}">{0} </div> <tpl if=\"this.isValidDate({1})\">{[Date.parseDate(values.{1}, SITOOLS_DATE_FORMAT).format("{3}")]}</tpl></span>',
|
182 |
|
|
col.header,
|
183 |
|
|
col.columnAlias,
|
184 |
|
|
style,
|
185 |
|
|
Ext.isEmpty(col.format) ? SITOOLS_DEFAULT_IHM_DATE_FORMAT : col.format);
|
186 |
|
|
}
|
187 |
|
|
else {
|
188 |
|
|
tplString += String.format('<span class="dataview_columnValue"><div class=x-view-entete style="{2}">{0} </div> {{1}}</span>', col.header, col.columnAlias, style);
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
return tplString;
|
192 |
|
|
},
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
getRendererHTML : function (item, imageStyle) {
|
202 |
|
|
var renderer, valueDisplayed, imageUrl;
|
203 |
|
|
var html;
|
204 |
|
|
if (!Ext.isEmpty(item.columnRenderer) && !Ext.isEmpty(item.columnRenderer.behavior)) {
|
205 |
|
|
|
206 |
|
|
var columnRenderer = item.columnRenderer;
|
207 |
|
|
switch (columnRenderer.behavior) {
|
208 |
|
|
case ColumnRendererEnum.URL_LOCAL :
|
209 |
|
|
case ColumnRendererEnum.URL_EXT_NEW_TAB :
|
210 |
|
|
case ColumnRendererEnum.URL_EXT_DESKTOP :
|
211 |
|
|
if (!Ext.isEmpty(columnRenderer.linkText)) {
|
212 |
|
|
html = "<span class='link featureType' sitools:column='"+item.columnAlias+"'>" + columnRenderer.linkText + "</span>";
|
213 |
|
|
} else if (!Ext.isEmpty(columnRenderer.image)) {
|
214 |
|
|
html = "<div class='image-link featureType' sitools:column='"+item.columnAlias+"'><img src=\"" + columnRenderer.image.url + "\" class='sitools-display-image' style ='" + imageStyle + "' ></img></div>";
|
215 |
|
|
}
|
216 |
|
|
break;
|
217 |
|
|
case ColumnRendererEnum.IMAGE_NO_THUMB :
|
218 |
|
|
html = "<span class='link featureType' sitools:column='"+item.columnAlias+"'>" + columnRenderer.linkText + "</span>";
|
219 |
|
|
break;
|
220 |
|
|
case ColumnRendererEnum.IMAGE_THUMB_FROM_IMAGE :
|
221 |
|
|
html = "<div class='image-link featureType' sitools:column='"+item.columnAlias+"'><img class='sitools-display-image' src='{0}' style ='" + imageStyle + "'></img></div>";
|
222 |
|
|
break;
|
223 |
|
|
case ColumnRendererEnum.IMAGE_FROM_SQL :
|
224 |
|
|
html = "<div class='image-link featureType' sitools:column='"+item.columnAlias+"'><img class='sitools-display-image image-link' src='{1}' style ='" + imageStyle + "'></div>";
|
225 |
|
|
break;
|
226 |
|
|
case ColumnRendererEnum.DATASET_LINK :
|
227 |
|
|
html = "<span class='link featureType' sitools:column='"+item.columnAlias+"'>{0}</span>";
|
228 |
|
|
break;
|
229 |
|
|
case ColumnRendererEnum.DATASET_ICON_LINK :
|
230 |
|
|
if (!Ext.isEmpty(columnRenderer.image)) {
|
231 |
|
|
imageUrl = columnRenderer.image.url;
|
232 |
|
|
}
|
233 |
|
|
html = "<div class='image-link featureType' sitools:column='"+item.columnAlias+"'><img style ='" + imageStyle + "' class='sitools-display-image' src='" + imageUrl + "'></div>";
|
234 |
|
|
break;
|
235 |
|
|
default :
|
236 |
|
|
html = "{0}";
|
237 |
|
|
break;
|
238 |
|
|
}
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
return html;
|
242 |
|
|
},
|
243 |
|
|
|
244 |
|
|
getRendererViewDataDetails : function (item) {
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
},
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
featureTypeAction : function (column, record, controller) {
|
264 |
|
|
var service = controller.getService(column.columnAlias);
|
265 |
|
|
if (!Ext.isEmpty(service)) {
|
266 |
|
|
controller.callGuiService(service.id, record, column.columnAlias);
|
267 |
|
|
}
|
268 |
|
|
else {
|
269 |
|
|
this.executeFeatureType(column, record);
|
270 |
|
|
}
|
271 |
|
|
},
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
executeFeatureType : function (column, record) {
|
281 |
|
|
if (!Ext.isEmpty(column.columnRenderer) && !Ext.isEmpty(column.columnRenderer.behavior)) {
|
282 |
|
|
var value = record.get(column.columnAlias);
|
283 |
|
|
var columnRenderer = column.columnRenderer;
|
284 |
|
|
switch (columnRenderer.behavior) {
|
285 |
|
|
case ColumnRendererEnum.URL_LOCAL :
|
286 |
|
|
sitools.user.component.dataviews.dataviewUtils.downloadData(value);
|
287 |
|
|
break;
|
288 |
|
|
case ColumnRendererEnum.URL_EXT_NEW_TAB :
|
289 |
|
|
window.open(value);
|
290 |
|
|
break;
|
291 |
|
|
case ColumnRendererEnum.URL_EXT_DESKTOP :
|
292 |
|
|
sitools.user.component.dataviews.dataviewUtils.showDisplayableUrl(value, columnRenderer.displayable);
|
293 |
|
|
break;
|
294 |
|
|
case ColumnRendererEnum.IMAGE_NO_THUMB :
|
295 |
|
|
sitools.user.component.dataviews.dataviewUtils.showPreview(value, columnRenderer.linkText);
|
296 |
|
|
break;
|
297 |
|
|
case ColumnRendererEnum.IMAGE_THUMB_FROM_IMAGE :
|
298 |
|
|
case ColumnRendererEnum.IMAGE_FROM_SQL :
|
299 |
|
|
sitools.user.component.dataviews.dataviewUtils.showPreview(value, column.header);
|
300 |
|
|
break;
|
301 |
|
|
case ColumnRendererEnum.DATASET_LINK :
|
302 |
|
|
case ColumnRendererEnum.DATASET_ICON_LINK :
|
303 |
|
|
sitools.user.component.dataviews.dataviewUtils.showDetailsData(value, columnRenderer.columnAlias, columnRenderer.datasetLinkUrl);
|
304 |
|
|
break;
|
305 |
|
|
default :
|
306 |
|
|
break;
|
307 |
|
|
}
|
308 |
|
|
}
|
309 |
|
|
},
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
formatDate : function (value, item) {
|
314 |
|
|
var valueFormat;
|
315 |
|
|
var result = Date.parseDate(value, SITOOLS_DATE_FORMAT, true);
|
316 |
|
|
|
317 |
|
|
if (Ext.isEmpty(result)) {
|
318 |
|
|
valueFormat = "";
|
319 |
|
|
}
|
320 |
|
|
else {
|
321 |
|
|
if (Ext.isEmpty(item.format)) {
|
322 |
|
|
valueFormat = result.format(SITOOLS_DEFAULT_IHM_DATE_FORMAT);
|
323 |
|
|
}
|
324 |
|
|
else {
|
325 |
|
|
try {
|
326 |
|
|
valueFormat = result.format(item.format);
|
327 |
|
|
}
|
328 |
|
|
catch (err) {
|
329 |
|
|
valueFormat = "unable to format Date";
|
330 |
|
|
}
|
331 |
|
|
}
|
332 |
|
|
}
|
333 |
|
|
return valueFormat;
|
334 |
|
|
},
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
downloadData : function (value) {
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
Ext.Ajax.request({
|
345 |
|
|
url : value,
|
346 |
|
|
method : 'HEAD',
|
347 |
|
|
scope : this,
|
348 |
|
|
success : function (ret) {
|
349 |
|
|
try {
|
350 |
|
|
var headerFile = ret.getResponseHeader("Content-Type")
|
351 |
|
|
.split(";")[0].split("/")[0];
|
352 |
|
|
if (headerFile == "text") {
|
353 |
|
|
Ext.Ajax.request({
|
354 |
|
|
url : value,
|
355 |
|
|
method : 'GET',
|
356 |
|
|
scope : this,
|
357 |
|
|
success : function (ret) {
|
358 |
|
|
var windowConfig = {
|
359 |
|
|
id : "winPreferenceDetailId",
|
360 |
|
|
title : value,
|
361 |
|
|
iconCls : "version"
|
362 |
|
|
};
|
363 |
|
|
var jsObj = Ext.Panel;
|
364 |
|
|
var componentCfg = {
|
365 |
|
|
layout : 'fit',
|
366 |
|
|
autoScroll : true,
|
367 |
|
|
html : ret.responseText
|
368 |
|
|
};
|
369 |
|
|
SitoolsDesk.addDesktopWindow(
|
370 |
|
|
windowConfig, componentCfg,
|
371 |
|
|
jsObj);
|
372 |
|
|
}
|
373 |
|
|
});
|
374 |
|
|
} else if (headerFile == "image") {
|
375 |
|
|
sitools.user.component.dataviews.dataviewUtils.showPreview(value, item.header);
|
376 |
|
|
} else {
|
377 |
|
|
sitools.user.component.dataviews.dataviewUtils.downloadFile(value);
|
378 |
|
|
}
|
379 |
|
|
} catch (err) {
|
380 |
|
|
Ext.Msg.alert(i18n.get('label.error'), err);
|
381 |
|
|
}
|
382 |
|
|
},
|
383 |
|
|
failure : function (ret) {
|
384 |
|
|
return null;
|
385 |
|
|
}
|
386 |
|
|
});
|
387 |
|
|
},
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
|
395 |
|
|
showDisplayableUrl : function (value, isDisplayable, customConfig) {
|
396 |
|
|
if (isDisplayable) {
|
397 |
|
|
|
398 |
|
|
if (customConfig) {
|
399 |
|
|
var windowConfig = customConfig;
|
400 |
|
|
}
|
401 |
|
|
else {
|
402 |
|
|
var windowConfig = {
|
403 |
|
|
title : "Preview",
|
404 |
|
|
id : value,
|
405 |
|
|
iconCls : "version"
|
406 |
|
|
};
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
var jsObj = Ext.ux.ManagedIFrame.Panel;
|
410 |
|
|
var componentCfg = {
|
411 |
|
|
defaults : {
|
412 |
|
|
padding : 10
|
413 |
|
|
},
|
414 |
|
|
layout : 'fit',
|
415 |
|
|
region : 'center',
|
416 |
|
|
defaultSrc : value,
|
417 |
|
|
listeners : {
|
418 |
|
|
documentloaded : function (iframe){
|
419 |
|
|
this.ownerCt.syncSize();
|
420 |
|
|
}
|
421 |
|
|
}
|
422 |
|
|
};
|
423 |
|
|
|
424 |
|
|
SitoolsDesk.addDesktopWindow(
|
425 |
|
|
windowConfig, componentCfg,
|
426 |
|
|
jsObj);
|
427 |
|
|
} else {
|
428 |
|
|
sitools.user.component.dataviews.dataviewUtils.downloadFile(value);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
},
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
downloadFile : function (url) {
|
437 |
|
|
if (Ext.getCmp("mifToDownload")) {
|
438 |
|
|
Ext.getCmp("mifToDownload").destroy();
|
439 |
|
|
}
|
440 |
|
|
|
441 |
|
|
var forceDlParam = "forceDownload=true";
|
442 |
|
|
var defaultSrc = url + ((url.indexOf("?") === -1) ? "?" : "&") + forceDlParam;
|
443 |
|
|
|
444 |
|
|
var mifToDownload = new Ext.ux.ManagedIFrame.Panel({
|
445 |
|
|
layout : 'fit',
|
446 |
|
|
id : "mifToDownload",
|
447 |
|
|
region : 'center',
|
448 |
|
|
defaultSrc : defaultSrc,
|
449 |
|
|
renderTo : Ext.getBody(),
|
450 |
|
|
cls : 'x-hidden'
|
451 |
|
|
});
|
452 |
|
|
|
453 |
|
|
},
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
showDetailsData : function (value, columnAlias, datasetUrl) {
|
464 |
|
|
var desktop = getDesktop();
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
Ext.Ajax.request({
|
468 |
|
|
scope : this,
|
469 |
|
|
method : 'GET',
|
470 |
|
|
url : datasetUrl,
|
471 |
|
|
success : function (response, opts) {
|
472 |
|
|
try {
|
473 |
|
|
var json = Ext.decode(response.responseText);
|
474 |
|
|
if (!json.success) {
|
475 |
|
|
Ext.Msg.alert(i18n.get('label.error'), json.message);
|
476 |
|
|
return;
|
477 |
|
|
}
|
478 |
|
|
var formParams = [ "RADIO|" + columnAlias + "|" + value ];
|
479 |
|
|
var dataset = json.dataset;
|
480 |
|
|
var jsObj = eval(dataset.datasetView.jsObject);
|
481 |
|
|
var componentCfg = {
|
482 |
|
|
dataUrl : dataset.sitoolsAttachementForUsers,
|
483 |
|
|
datasetId : dataset.id,
|
484 |
|
|
datasetCm : dataset.columnModel,
|
485 |
|
|
formParams : formParams,
|
486 |
|
|
datasetName : dataset.name,
|
487 |
|
|
dictionaryMappings : dataset.dictionaryMappings,
|
488 |
|
|
datasetViewConfig : dataset.datasetViewConfig,
|
489 |
|
|
preferencesPath : "/" + dataset.name,
|
490 |
|
|
preferencesFileName : "datasetView"
|
491 |
|
|
|
492 |
|
|
};
|
493 |
|
|
|
494 |
|
|
var windowConfig = {
|
495 |
|
|
id : "wind" + dataset.id + columnAlias + value,
|
496 |
|
|
title : i18n.get('label.dataTitle') + " : " + dataset.name,
|
497 |
|
|
datasetName : dataset.name,
|
498 |
|
|
type : "data",
|
499 |
|
|
saveToolbar : true,
|
500 |
|
|
iconCls : "dataDetail"
|
501 |
|
|
};
|
502 |
|
|
SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, jsObj);
|
503 |
|
|
|
504 |
|
|
} catch (err) {
|
505 |
|
|
}
|
506 |
|
|
}
|
507 |
|
|
});
|
508 |
|
|
|
509 |
|
|
},
|
510 |
|
|
|
511 |
|
|
|
512 |
|
|
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
showPreview : function (value, title) {
|
516 |
|
|
var previewWin = new sitools.widget.WindowImageViewer({
|
517 |
|
|
title : title,
|
518 |
|
|
src : value,
|
519 |
|
|
hideAction : 'close',
|
520 |
|
|
resizeImage : false
|
521 |
|
|
});
|
522 |
|
|
|
523 |
|
|
previewWin.show();
|
524 |
|
|
previewWin.toFront();
|
525 |
|
|
},
|
526 |
|
|
|
527 |
|
|
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
|
531 |
|
|
isNoClientAccess : function (column) {
|
532 |
|
|
return !Ext.isEmpty(column.columnRenderer) && ColumnRendererEnum.NO_CLIENT_ACCESS == column.columnRenderer.behavior;
|
533 |
|
|
},
|
534 |
|
|
|
535 |
|
|
|
536 |
|
|
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
|
542 |
|
|
getFilters : function (listeColonnes, activeFilters) {
|
543 |
|
|
|
544 |
|
|
var filters = [];
|
545 |
|
|
var i = 0;
|
546 |
|
|
if (!Ext.isEmpty(listeColonnes)) {
|
547 |
|
|
|
548 |
|
|
Ext.each(listeColonnes, function (item, index, totalItems) {
|
549 |
|
|
if (item.filter) {
|
550 |
|
|
var boolActiveFilter = false, activeFilterValue = "", activeComparison = "";
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
Ext.each(activeFilters, function (activeFilter) {
|
554 |
|
|
if (item.columnAlias == activeFilter.columnAlias) {
|
555 |
|
|
boolActiveFilter = true;
|
556 |
|
|
|
557 |
|
|
if (activeFilter.data.type == 'numeric') {
|
558 |
|
|
if (!Ext.isObject(activeFilterValue)) {
|
559 |
|
|
activeFilterValue = {};
|
560 |
|
|
}
|
561 |
|
|
activeFilterValue[activeFilter.data.comparison] = activeFilter.data.value;
|
562 |
|
|
} else if (activeFilter.data.type == 'date') {
|
563 |
|
|
var date = new Date();
|
564 |
|
|
var tmp = activeFilter.data.value.split('-');
|
565 |
|
|
date.setFullYear(tmp[0], tmp[1] - 1, tmp[2]);
|
566 |
|
|
|
567 |
|
|
if (!Ext.isObject(activeFilterValue)) {
|
568 |
|
|
activeFilterValue = {};
|
569 |
|
|
}
|
570 |
|
|
if (activeFilter.data.comparison == 'eq') {
|
571 |
|
|
activeFilterValue.on = date;
|
572 |
|
|
}
|
573 |
|
|
if (activeFilter.data.comparison == 'gt') {
|
574 |
|
|
activeFilterValue.after = date;
|
575 |
|
|
}
|
576 |
|
|
if (activeFilter.data.comparison == 'lt') {
|
577 |
|
|
activeFilterValue.before = date;
|
578 |
|
|
}
|
579 |
|
|
} else {
|
580 |
|
|
activeFilterValue = activeFilter.data.value;
|
581 |
|
|
}
|
582 |
|
|
}
|
583 |
|
|
});
|
584 |
|
|
var filter = {
|
585 |
|
|
type : sql2ext.get(item.sqlColumnType),
|
586 |
|
|
active : boolActiveFilter,
|
587 |
|
|
dataIndex : item.columnAlias,
|
588 |
|
|
columnAlias : item.columnAlias,
|
589 |
|
|
value : activeFilterValue
|
590 |
|
|
};
|
591 |
|
|
|
592 |
|
|
filters.push(filter);
|
593 |
|
|
}
|
594 |
|
|
i++;
|
595 |
|
|
|
596 |
|
|
}, this);
|
597 |
|
|
}
|
598 |
|
|
return filters;
|
599 |
|
|
|
600 |
|
|
},
|
601 |
|
|
|
602 |
|
|
createColMenu : function (view, columnModel) {
|
603 |
|
|
var colCount = columnModel.getColumnCount();
|
604 |
|
|
var menu = new Ext.menu.Menu();
|
605 |
|
|
|
606 |
|
|
for (var i = 0; i < colCount; i++) {
|
607 |
|
|
if (columnModel.config[i].hideable !== false && !columnModel.config[i].isSelectionModel) {
|
608 |
|
|
|
609 |
|
|
menu.add(new Ext.menu.CheckItem({
|
610 |
|
|
itemId : 'col-' + columnModel.getColumnId(i),
|
611 |
|
|
text : columnModel.getColumnHeader(i),
|
612 |
|
|
checked : !columnModel.isHidden(i),
|
613 |
|
|
hideOnClick : false,
|
614 |
|
|
disabled : columnModel.config[i].hideable === false,
|
615 |
|
|
listeners : {
|
616 |
|
|
scope : view,
|
617 |
|
|
checkchange : function (ci, checked) {
|
618 |
|
|
if (checked) {
|
619 |
|
|
var colModel = extColModelToSrv(columnModel);
|
620 |
|
|
view.grid.getStore().load({
|
621 |
|
|
params : {
|
622 |
|
|
colModel : Ext.util.JSON.encode(colModel)
|
623 |
|
|
}
|
624 |
|
|
});
|
625 |
|
|
}
|
626 |
|
|
}
|
627 |
|
|
}
|
628 |
|
|
}));
|
629 |
|
|
}
|
630 |
|
|
}
|
631 |
|
|
menu.on('itemclick', view.handleHdMenuClick, view);
|
632 |
|
|
|
633 |
|
|
return menu;
|
634 |
|
|
},
|
635 |
|
|
|
636 |
|
|
copyImageToClipboard : function CopyToClip(img) {
|
637 |
|
|
|
638 |
|
|
}
|
639 |
|
|
}; |