1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
Ext.define("sitools.admin.def", {
|
22
|
singleton: true,
|
23
|
require: ["sitools.public.utils.LoginDef"],
|
24
|
|
25
|
init: function () {
|
26
|
Ext.Ajax.on('requestexception', onRequestException, this);
|
27
|
},
|
28
|
|
29
|
initLocalizedVariables: function () {
|
30
|
|
31
|
Ext.apply(Ext.form.VTypes, {
|
32
|
'name': function () {
|
33
|
var re = new RegExp("^.*[!\"#$%&\'()*+,:;<=>?@\\`{}|~/]+.*$");
|
34
|
return function (v) {
|
35
|
return !re.test(v);
|
36
|
};
|
37
|
}(),
|
38
|
'nameText': "Invalid caracters : should not contain . * [ ! \" # $ % & ' ( ) * + , : ; < = > ? @ \ ` { } | ~ / ] + . * $",
|
39
|
'image': function () {
|
40
|
var re = new RegExp("^[http://]+[/:a-zA-Z0-9-_]+.*(jpg|gif|png|bmp|ico)$");
|
41
|
return function (v) {
|
42
|
return re.test(v);
|
43
|
};
|
44
|
}(),
|
45
|
'imageText': "Invalid image URL : should start with http and finish with a image extension",
|
46
|
'attachment': function () {
|
47
|
var re1 = new RegExp("^/.*$");
|
48
|
var re2 = new RegExp("^.*//.*$");
|
49
|
var re3 = new RegExp("^.*[!\"#$%&\'()*+,:;<=>?@\\`{}|~]+.*$");
|
50
|
return function (v) {
|
51
|
return (re1.test(v) && !re2.test(v) && !re3.test(v));
|
52
|
};
|
53
|
}(),
|
54
|
'attachmentText': "invalid Attachment : should not contain ! \" # $ % & ' ( ) * + , : ; < = > ? @ \ ` { } | ~ ] + . * and must begin with /",
|
55
|
'nameWithoutSpace': function () {
|
56
|
var re = new RegExp("^.*[!\"#$%&\'()*+,:;<=>?@\\`{}|~ ]+.*$");
|
57
|
return function (v) {
|
58
|
return !re.test(v);
|
59
|
};
|
60
|
}(),
|
61
|
'nameWithoutSpaceText': i18n.get('label.invalidCharacters'),
|
62
|
'withoutSpace': function () {
|
63
|
var re = new RegExp("^.*[ ]+.*$");
|
64
|
return function (v) {
|
65
|
return !re.test(v);
|
66
|
};
|
67
|
}(),
|
68
|
'withoutSpaceText': i18n.get('label.invalidCharacters'),
|
69
|
'uri': function () {
|
70
|
var re = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
|
71
|
var regEspace = new RegExp("^.*[ ]+$");
|
72
|
return function (v) {
|
73
|
return re.test(v) && !regEspace.test(v);
|
74
|
};
|
75
|
}(),
|
76
|
'uriText': "The format of the URL is invalid, should start with http, ftp or https and finish without space"
|
77
|
});
|
78
|
}
|
79
|
});
|
80
|
|
81
|
|
82
|
|
83
|
var DEFAULT_NATIVEJSON = false;
|
84
|
|
85
|
var DEFAULT_TIMEOUT = 30000;
|
86
|
var DEFAULT_TIMEBUF = 10;
|
87
|
var DEFAULT_NBRETRY = 0;
|
88
|
var LOCALE = 'en';
|
89
|
var DEFAULT_HELP_WIDTH = 600;
|
90
|
var DEFAULT_HELP_HEIGHT = 400;
|
91
|
var ADMIN_PANEL_HEIGHT = 360;
|
92
|
var ADMIN_PANEL_NB_ELEMENTS = 10;
|
93
|
var SHOW_HELP = true;
|
94
|
var SITOOLS_DATE_FORMAT = 'Y-m-d\\TH:i:s.u';
|
95
|
var SITOOLS_DEFAULT_IHM_DATE_FORMAT = 'Y-m-d H:i:s.u';
|
96
|
var EXT_JS_VERSION = Ext.versions.extjs.version;
|
97
|
var EXT_JS_FOLDER = "extjs4/ext-" + EXT_JS_VERSION;
|
98
|
|
99
|
var JAVA_TYPES = [{
|
100
|
name: "String"
|
101
|
}, {
|
102
|
name: "Date"
|
103
|
}, {
|
104
|
name: "Double"
|
105
|
}, {
|
106
|
name: "Float"
|
107
|
}, {
|
108
|
name: "Integer"
|
109
|
}, {
|
110
|
name: "Boolean"
|
111
|
}, {
|
112
|
name: "BasicDBObject"
|
113
|
}, {
|
114
|
name: "BasicDBList"
|
115
|
}];
|
116
|
Ext.Ajax.defaultHeaders = {
|
117
|
"Accept": "application/json",
|
118
|
"X-User-Agent": "Sitools"
|
119
|
};
|
120
|
|
121
|
var helpUrl;
|
122
|
Ext.BLANK_IMAGE_URL = '/sitools/client-public/cots/' + EXT_JS_FOLDER + '/resources/themes/images/default/tree/s.gif';
|
123
|
Ext.USE_NATIVE_JSON = DEFAULT_NATIVEJSON;
|
124
|
Ext.Ajax.timeout = DEFAULT_TIMEOUT;
|
125
|
|
126
|
|
127
|
|
128
|
var treePanel, mainPanel, helpPanel;
|
129
|
|
130
|
var SERVER_OK = 200;
|
131
|
|
132
|
var predicatOperators = {
|
133
|
operators: [['EQ', '='], ['GT', '>'], ['GTE', '>='], ['LT', '<'], ['LTE', '<='], ['LIKE', 'like'],
|
134
|
['NE', '!=']],
|
135
|
|
136
|
getOperatorValueForServer: function (clientValue) {
|
137
|
var value = null;
|
138
|
Ext.each(this.operators, function (operator) {
|
139
|
if (operator[1] == clientValue) {
|
140
|
value = operator[0];
|
141
|
return false;
|
142
|
}
|
143
|
}, this);
|
144
|
return value;
|
145
|
},
|
146
|
|
147
|
getOperatorValueForClient: function (serverValue) {
|
148
|
var value = null;
|
149
|
Ext.each(this.operators, function (operator) {
|
150
|
if (operator[0] == serverValue) {
|
151
|
value = operator[1];
|
152
|
return false;
|
153
|
}
|
154
|
}, this);
|
155
|
return value;
|
156
|
}
|
157
|
};
|
158
|
|
159
|
|
160
|
|
161
|
|
162
|
|
163
|
|
164
|
function alertFailure(response, opts) {
|
165
|
var txt;
|
166
|
if (response.status == SERVER_OK) {
|
167
|
var ret = Ext.decode(response.responseText).message;
|
168
|
txt = i18n.get('msg.error') + ': ' + i18n.get(ret);
|
169
|
} else {
|
170
|
txt = i18n.get('warning.serverError') + ': ' + i18n.get(response.statusText);
|
171
|
}
|
172
|
Ext.Msg.alert(i18n.get('label.warning'), txt);
|
173
|
}
|
174
|
|
175
|
function showResponse(ret) {
|
176
|
try {
|
177
|
var Json = Ext.decode(ret.responseText);
|
178
|
if (!Json.success) {
|
179
|
Ext.Msg.alert(i18n.get('label.warning'), i18n.get(Json.message));
|
180
|
return false;
|
181
|
}
|
182
|
popupMessage("", i18n.get(Json.message), loadUrl.get('APP_URL') + loadUrl.get('APP_CLIENT_PUBLIC_URL') + '/res/images/msgBox/16/icon-info.png');
|
183
|
|
184
|
return true;
|
185
|
} catch (err) {
|
186
|
Ext.Msg.alert(i18n.get('label.warning'), i18n.get('warning.javascriptError') + " : " + err);
|
187
|
return false;
|
188
|
}
|
189
|
}
|
190
|
|
191
|
Ext.override(Ext.grid.GridPanel, {
|
192
|
stripeRows: true
|
193
|
});
|
194
|
|
195
|
|
196
|
|
197
|
|
198
|
|
199
|
|
200
|
Ext.override(Ext.form.field.Base, {
|
201
|
tooltip: null,
|
202
|
listeners: {
|
203
|
afterrender: function () {
|
204
|
if (!Ext.isEmpty(this.tooltip)) {
|
205
|
var ttConfig = {};
|
206
|
if (Ext.isString(this.tooltip)) {
|
207
|
ttConfig = {
|
208
|
html: this.tooltip,
|
209
|
width: 200,
|
210
|
dismissDelay: 5000
|
211
|
};
|
212
|
}
|
213
|
else if (Ext.isObject(this.tooltip)) {
|
214
|
ttConfig = this.tooltip;
|
215
|
} else {
|
216
|
return;
|
217
|
}
|
218
|
Ext.apply(ttConfig, {
|
219
|
target: this.el
|
220
|
});
|
221
|
this.tTip = new Ext.ToolTip(ttConfig);
|
222
|
}
|
223
|
|
224
|
}
|
225
|
}
|
226
|
});
|
227
|
|
228
|
|
229
|
function onClickOption(urloption) {
|
230
|
|
231
|
|
232
|
|
233
|
|
234
|
var urltunnel = urloption + "?method=options&media=text/html";
|
235
|
var saved = Ext.Ajax.defaultHeaders.Authorization;
|
236
|
Ext.Ajax.defaultHeaders.Authorization = '';
|
237
|
var savedScheme = Ext.util.Cookies.get('scheme');
|
238
|
var savedHashCode = Ext.util.Cookies.get('hashCode');
|
239
|
Ext.util.Cookies.set('scheme', null);
|
240
|
Ext.util.Cookies.set('hashCode', null);
|
241
|
|
242
|
Ext.Ajax.un('requestexception', onRequestException, this);
|
243
|
|
244
|
Ext.Ajax.request({
|
245
|
url: urltunnel,
|
246
|
headers: {
|
247
|
'Authorization': 'none'
|
248
|
},
|
249
|
method: "GET",
|
250
|
success: function (response) {
|
251
|
if (response.status == 200) {
|
252
|
var OpenWindow = window.open(urltunnel);
|
253
|
}
|
254
|
|
255
|
Ext.Ajax.defaultHeaders.Authorization = saved;
|
256
|
Ext.util.Cookies.set('scheme', savedScheme);
|
257
|
Ext.util.Cookies.set('hashCode', savedHashCode);
|
258
|
Ext.Ajax.on('requestexception', onRequestException, this);
|
259
|
},
|
260
|
callback: function () {
|
261
|
Ext.util.Cookies.set('scheme', savedScheme);
|
262
|
Ext.util.Cookies.set('hashCode', savedHashCode);
|
263
|
Ext.Ajax.on('requestexception', onRequestException, this);
|
264
|
},
|
265
|
failure: function (response) {
|
266
|
Ext.Ajax.defaultHeaders.Authorization = saved;
|
267
|
Ext.util.Cookies.set('scheme', savedScheme);
|
268
|
Ext.util.Cookies.set('hashCode', savedHashCode);
|
269
|
if (response.status == 403) {
|
270
|
Ext.Ajax.request({
|
271
|
url: urloption + "?media=text/html",
|
272
|
method: "OPTIONS",
|
273
|
success: function (response) {
|
274
|
var OpenWindow = window.open("", urloption);
|
275
|
OpenWindow.document.write(response.responseText);
|
276
|
OpenWindow.document.close();
|
277
|
},
|
278
|
failure: function (response) {
|
279
|
},
|
280
|
scope: this
|
281
|
});
|
282
|
}
|
283
|
Ext.Ajax.on('requestexception', onRequestException, this);
|
284
|
},
|
285
|
scope: this
|
286
|
|
287
|
});
|
288
|
|
289
|
}
|
290
|
|
291
|
|
292
|
Ext.override(Ext.menu.DatePicker, {
|
293
|
initComponent: function () {
|
294
|
this.on('beforeshow', this.onBeforeShow, this);
|
295
|
if (this.strict == (Ext.isIE7 && Ext.isStrict)) {
|
296
|
this.on('show', this.onShow, this, {single: true, delay: 20});
|
297
|
}
|
298
|
this.callParent();
|
299
|
}
|
300
|
});
|
301
|
|
302
|
|
303
|
Ext.define('App.overrides.view.Table', {
|
304
|
override: 'Ext.view.Table',
|
305
|
getRecord: function (node) {
|
306
|
var me = this;
|
307
|
if (me.dataSource.buffered) {
|
308
|
node = this.getNode(node);
|
309
|
if (node) {
|
310
|
var recordIndex = node.getAttribute('data-recordIndex');
|
311
|
if (recordIndex) {
|
312
|
recordIndex = parseInt(recordIndex, 10);
|
313
|
if (recordIndex > -1) {
|
314
|
|
315
|
|
316
|
|
317
|
|
318
|
return this.store.data.getAt(recordIndex);
|
319
|
}
|
320
|
}
|
321
|
return this.dataSource.data.get(node.getAttribute('data-recordId'));
|
322
|
}
|
323
|
} else {
|
324
|
node = this.getNode(node);
|
325
|
if (node) {
|
326
|
return this.dataSource.data.get(node.getAttribute('data-recordId'));
|
327
|
}
|
328
|
}
|
329
|
},
|
330
|
indexInStore: function (node) {
|
331
|
var me = this;
|
332
|
if (me.dataSource.buffered) {
|
333
|
node = this.getNode(node, true);
|
334
|
if (!node && node !== 0) {
|
335
|
return -1;
|
336
|
}
|
337
|
var recordIndex = node.getAttribute('data-recordIndex');
|
338
|
if (recordIndex) {
|
339
|
return parseInt(recordIndex, 10);
|
340
|
}
|
341
|
return this.dataSource.indexOf(this.getRecord(node));
|
342
|
} else {
|
343
|
node = this.getNode(node, true);
|
344
|
if (!node && node !== 0) {
|
345
|
return -1;
|
346
|
}
|
347
|
return this.dataSource.indexOf(this.getRecord(node));
|
348
|
}
|
349
|
}
|
350
|
});
|