git_sitools_idoc / szcluster-db / workspace / client-user / js / components / dataviews / dataviewUtils.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 it under the
|
7 |
* terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation, either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* SITools2 is distributed in the hope that it will be useful, but WITHOUT ANY
|
12 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13 |
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License along with
|
16 |
* SITools2. If not, see <http://www.gnu.org/licenses/>.
|
17 |
******************************************************************************/
|
18 |
|
19 |
/*global Ext, sitools, i18n, sql2ext, extColModelToSrv, window,
|
20 |
extColModelToJsonColModel, DEFAULT_NEAR_LIMIT_SIZE,
|
21 |
DEFAULT_LIVEGRID_BUFFER_SIZE, SITOOLS_DEFAULT_IHM_DATE_FORMAT,
|
22 |
DEFAULT_PREFERENCES_FOLDER, SitoolsDesk, getDesktop, userLogin, projectGlobal, ColumnRendererEnum, SITOOLS_DATE_FORMAT
|
23 |
*/
|
24 |
Ext.namespace('sitools.user.component.dataviews');
|
25 |
|
26 |
/**
|
27 |
* A Simple Object to publish common methods to use dataviews in Sitools2.
|
28 |
* @type
|
29 |
*/
|
30 |
sitools.user.component.dataviews.dataviewUtils = { |
31 |
//sitools.user.component.liveGrid.dataviewUtils = {
|
32 |
/**
|
33 |
* build the param that will represent the active selection.
|
34 |
* @param [Ext.data.Record] recSelected the selected records
|
35 |
* @returns {} this object contains the param that will use FORM API
|
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 |
// build the primaryKey Value
|
50 |
var primaryKeyValues = [];
|
51 |
Ext.each(recSelected, function (record) {
|
52 |
primaryKeyValues.push(record.get(primaryKeyName)); |
53 |
}); |
54 |
|
55 |
// use the form API to request the selected records
|
56 |
result["p[0]"] = "LISTBOXMULTIPLE|" + primaryKeyName + "|" + primaryKeyValues.join("|"); |
57 |
return result;
|
58 |
}, |
59 |
|
60 |
|
61 |
/**
|
62 |
* Get the renderer for a column from its featureType for the DataView
|
63 |
* @param {Object} item col the Column definition
|
64 |
* @param {Object} dataviewConfig the specific dataview Configuration.
|
65 |
* @return {function} the renderer for a column
|
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 |
* Get the template to render a column from its featureType for the DataView
|
117 |
* @param {Object} col the Column definition
|
118 |
* @param {String} style the style to add to the label part
|
119 |
* @param {Object} dataviewConfig the specific dataview Configuration.
|
120 |
* @return {String} a template to render a column from its featureType for the DataView
|
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 |
* Get the HTML specific part to render a column corresponding to its featureType (columnRenderer)
|
196 |
* It is a formated date where {0} must be replaced by the column value and {1} by the imageUrl to display in big only for ColumnRendererEnum.IMAGE_FROM_SQL
|
197 |
* @param {Object} item the column definition
|
198 |
* @param {Object} dataviewConfig the specific dataview Configuration.
|
199 |
* @return {String} a formated HTML String
|
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 |
* Execute the action on a featureType column. It can be either a
|
252 |
* Gui_Service action if one is configured, or a classic featureType
|
253 |
* action
|
254 |
*
|
255 |
* @param column
|
256 |
* {Object} the column
|
257 |
* @param record
|
258 |
* {Ext.data.Record} the record
|
259 |
* @param controller
|
260 |
* {sitools.user.component.dataviews.services.GuiServiceController}
|
261 |
* the current Gui_Service controller
|
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 |
* Execute the featureType action depending on the given column and record
|
274 |
*
|
275 |
* @param column
|
276 |
* {Object} the column
|
277 |
* @param record
|
278 |
* {Ext.data.Record} the record
|
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 |
// try to build Date with "Y-m-d" format
|
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 |
* @static
|
337 |
* Execute a REST OPTION request to the value url.
|
338 |
* Switch on Content-Type value to determine if we open a new iframe, or a window.
|
339 |
* @param {} value the url to request
|
340 |
*/
|
341 |
downloadData : function (value) { |
342 |
// value = encodeURIComponent(value);
|
343 |
//build first request to get the headers
|
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 |
* @static Build a MIF panel with a given url and load it into the desktop
|
390 |
* @param {}
|
391 |
* value the url to request
|
392 |
* @param {boolean}
|
393 |
* true if the url is displayable in a window, false otherwise
|
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", //value, |
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 |
* Use a spcialized MIF to download datas...
|
434 |
* @param {String} url the url to request.
|
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 |
* @static
|
456 |
* Definition of the showDetailData method used by the columnRenderer. Calls the
|
457 |
* Livegrid corresponding to the dataset linked to the column. To filter the
|
458 |
* data : use the form API : ["RADIO|" + columnAlias + "|'" + value + "'"]
|
459 |
* @param {string} value
|
460 |
* @param {string} columnAlias
|
461 |
* @param {string} datasetUrl
|
462 |
*/
|
463 |
showDetailsData : function (value, columnAlias, datasetUrl) { |
464 |
var desktop = getDesktop();
|
465 |
|
466 |
// récupération des données du dataset
|
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 |
* @static
|
512 |
* Definition of the showPreview method used by the columnRenderer.
|
513 |
* @param {string} value The img src
|
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 |
* Return true if the column is NoClientAccess
|
528 |
* @param {Object} column the column object
|
529 |
* @return {boolean} true if the column should not be used in client
|
530 |
*/
|
531 |
isNoClientAccess : function (column) { |
532 |
return !Ext.isEmpty(column.columnRenderer) && ColumnRendererEnum.NO_CLIENT_ACCESS == column.columnRenderer.behavior;
|
533 |
}, |
534 |
/**
|
535 |
* @param {Array} listeColonnes
|
536 |
* ColumnModel of the grid
|
537 |
* @param {Array} activeFilters
|
538 |
* Definition of the filters used to build the grid
|
539 |
*
|
540 |
* @returns {Array} The filters configuration for the grid
|
541 |
*/
|
542 |
getFilters : function (listeColonnes, activeFilters) { |
543 |
|
544 |
var filters = [];
|
545 |
var i = 0; |
546 |
if (!Ext.isEmpty(listeColonnes)) {
|
547 |
// First loop on all the columns
|
548 |
Ext.each(listeColonnes, function (item, index, totalItems) {
|
549 |
if (item.filter) {
|
550 |
var boolActiveFilter = false, activeFilterValue = "", activeComparison = ""; |
551 |
// loop on active filters to determine if there is an active
|
552 |
// filter on the column
|
553 |
Ext.each(activeFilters, function (activeFilter) {
|
554 |
if (item.columnAlias == activeFilter.columnAlias) {
|
555 |
boolActiveFilter = true;
|
556 |
// construct the value for the specific filter
|
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 |
}; |