Blame view

js/app/views/CatalogUI.js 67.5 KB
f792a3de   elena   catalog ihm
1
2
3
4
5
6
7
8
9
10
/**
 * Project       AMDA-NG
 * Name          CatalogUI.js
 * @class 	 amdaUI.catalogUI
 * @extends      Ext.container.Container
 * @brief	 Catalog Module UI definition (View)
 * @author 	 elena
 */

Ext.define('amdaUI.CatalogUI', {
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
11
12
13
14
15
16
17
18
19
    extend: 'Ext.container.Container',
    alias: 'widget.panelCatalog',

    requires: [
        'Ext.ux.grid.menu.RangeMenu',
        'Ext.ux.grid.FiltersFeature',
        'Ext.ux.grid.filter.DateFilter',
        'Ext.ux.grid.filter.NumericFilter',
        'Ext.ux.grid.filter.StringFilter',
8046f4ee   Erdogan Furkan   #7862-Done
20
21
22
23
        // 'amdaUI.CustomNumericFilter',
        // 'amdaUI.CustomStringFilter',
        // 'amdaUI.CustomDateFilter',
        'amdaUI.CustomFilters',
f3e15e49   Erdogan Furkan   #10700 - Done
24
        'amdaUI.OperationsTT',
533ea933   Benjamin Renard   Show description ...
25
        'amdaUI.DescriptionField',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
26
        'Ext.grid.plugin.BufferedRenderer',
a19578d1   Erdogan Furkan   Status for parame...
27
        'amdaUI.StatusGrid',
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
28
        'amdaUI.StatisticalPlug',
7fc31ac3   Erdogan Furkan   For now, will com...
29
30
        'amdaDesktop.AmdaStateProvider',
        'Ext.grid.plugin.CellEditing'
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
31
32
33
    ],

    isCatalog: true,
709a2d2e   Hacene SI HADJ MOHAND   il reste auto sta...
34
    activeField : null,
ce347c54   Erdogan Furkan   Done.
35
    statusGrid:null,
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    statics: {
        COL_TO_HIDE_DURATION: 'colToHideDuration'
    },

    constructor: function (config) {
        this.init(config);
        this.callParent(arguments);
        this.toReconfigure = true;

        if (this.object) {
            this.loadObject();
        }
    },

    setObject: function (object, toReconfigure) {
        if (toReconfigure)
            this.toReconfigure = true;
        // set object
        this.object = object;
        // load object into view
        this.loadObject();
        // show the default duration column
        this.TTGrid.headerCt.getGridColumns();

        Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function (item, index, all) {
            // if item is the default duration column
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
62
            if (item.id == amdaUI.CatalogUI.COL_TO_HIDE_DURATION + Ext.state.Manager.getProvider().get('cat_duration').toString()) {
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
                // show this column
                item.show();
            }
        });
        // fire the refresh event (to statistical plugin)
        this.fireEvent("refresh");
        // global event
        myDesktopApp.EventManager.fireEvent("refresh");
    },

    /**
     * set params description into this.object
     */
    setParamInfo: function (parameters) {
        var params = [];
        Ext.Array.each(parameters, function (item, index) {
            params[index] = item;
        }, this);

        this.object.set('parameters', params);
        this.object.set('nbParameters', params.length);
    },

    /**
     * update this.object from form
     */
    updateObject: function () {
        // get the basic form
        var basicForm = this.formPanel.getForm();
        var updateStatus = true;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
93
94
95
96
97
98
        var fieldsWithoutName = basicForm.getFields().items;
        Ext.Array.each(fieldsWithoutName, function (item, index, allItems) {
            if (item !== this.fieldName) {
                if (!item.isValid()) {
                    // set update isn't allowed
                    updateStatus = false;
8b11b1af   Benjamin Renard   Insert intervals ...
99
                }
dd143fd0   Benjamin Renard   Fix conflit
100
            }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
101
102
103
104
105
        }, this);
        // if the update is allowed
        if (updateStatus) {
            /// real object update
            // update TimeTable object with the content of form
b0720b91   Benjamin Renard   Finalize catalog ...
106
            basicForm.updateRecord(this.object);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
        }
        // return the update status
        return updateStatus;
    },

    addInterval: function (start, stop) {
        var row = this.TTGrid.getStore().getTotalCount();
        var me = this;
        this.TTGrid.getSelectionModel().deselectAll();
        AmdaAction.addCacheInterval({'start': start, 'stop': stop, 'index': row, 'isCatalog': true}, function (result, e) {
            this.status = result.status;
            if (!this.TTGrid.getStore().loading) {
                this.TTGrid.getStore().reload({
                    callback: function (records, options, success) {
                        me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function () {
                            me.TTGrid.getView().select(row);
                        }, me);
                    }
                });
            }
        }, this);
    },

    updateCount: function () {
        this.object.set('nbIntervals', this.TTGrid.getStore().getTotalCount());
        this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
    },
    generateTT: function () {
        if (this.fclose()) {
            Ext.Msg.confirm('Generate TT', 'Current Catalog has been modified.\nDo you want to save it to include these changes in the generated Time Table ?',
                    function (btn, text) {
                        if (btn == 'yes') {
827bddef   Benjamin Renard   Fix save of a fil...
139
			    var me = this;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
140
141
142
                            // mark this.closed as true before the call to close() as that will fire the beforeclose event again
                            if (this.object.get('id') == "") {
                                // case of creation of catalog
827bddef   Benjamin Renard   Fix save of a fil...
143
144
145
                                this.saveCatalog(function () {
					me.createTT(me.object.get('id'));
				}, true);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
146
147
                            } else {
                                // casse existing catalog
827bddef   Benjamin Renard   Fix save of a fil...
148
149
150
                                this.saveProcess(false, function () {
					me.createTT(me.object.get('id'));
				}, true);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
151
152
153
154
155
156
157
158
159
160
                            }
                            return;
                        }
                    }, this);

        } else {
            this.createTT(this.object.get('id'));
            return;
        }
    },
5535e93a   Erdogan Furkan   Filter(#10688)/So...
161
    updateSurveyDates : function(res){
6d20bc66   Hacene SI HADJ MOHAND   correction ok
162
163
        if (this.TTGrid.getStore().getTotalCount() <= 0)
            return;
79dd62c6   Erdogan Furkan   #10576 - Bug fixed
164

5535e93a   Erdogan Furkan   Filter(#10688)/So...
165
166
167
168
169
170
171
172
        if(! this.object.get('surveyStart') ){
            this.object.set('surveyStart',  res['minStart']);
            this.status.isModified = true;
        }
        if(! this.object.get('surveyStop') ){
            this.object.set('surveyStop',  res['maxStop']);
            this.status.isModified = true;
        } 
709a2d2e   Hacene SI HADJ MOHAND   il reste auto sta...
173
174
  },

13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
175
176
177
178
179
    createTT: function (catId) {
        var ttObj = Ext.create('amdaModel.TimeTable');
        var timeTabNode = Ext.create('amdaModel.TimeTableNode', {leaf: true});
        ttObj.set('relatedCatalogId', catId)
        creatDate = new Date(this.object.get('created'));
217e6c35   Hacene SI HADJ MOHAND   affichage oki
180
        date = Ext.Date.format(creatDate, 'Y-m-d\\TH:i:s.u');
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
181
182
        descr = 'Generated by CDPP/Amda Catalog Module \n' + 'From Catalog: ' + this.object.get('name') + '\nOn: ' + date + '\n';
        ttObj.set('description', descr + this.object.get('description'));
a4acaf46   Hacene SI HADJ MOHAND   IHM progess
183
        ttObj.set('contact', this.object.get('contact'));
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
184
185
186
187
188
189
190
191
192
193
        timeTabNode.set('object', ttObj);
        var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
        var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true);
        amdaModel.InteractiveNode.preloadNodes(ttRootNode.getRootNode(),
                function ()
                {
                    // edit newNode into Parameter Module with node as contextNode
                    timeTabNode.editInModule();
                });
    },
33705dc4   Benjamin Renard   Catalog visu rework
194
    // Convert UTC date to client local date
bad1e728   Hacene SI HADJ MOHAND   Ok for time zone
195
    convertUTCDateToLocalDate: function (date) {
1d7c3a74   Hacene SI HADJ MOHAND   correcting #7320
196
197
198
199
        if (date == null) {
            return date;
        }
        ;
bad1e728   Hacene SI HADJ MOHAND   Ok for time zone
200
201
202
203
204
205
206
207
208
        var newDate = new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);

        var offset = date.getTimezoneOffset() / 60;
        var hours = date.getHours();

        newDate.setHours(hours - offset);

        return newDate;
    },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
    onAfterInit: function (result, e)
    {
        var me = this;
        if (!result) {
            myDesktopApp.errorMsg(e.message);
            Ext.defer(function () {
                Ext.Msg.toFront()
            }, 10);

            return;
        } else if (!result.success)
        {
            if (result.message)
                myDesktopApp.errorMsg(result.message);
            else
                myDesktopApp.errorMsg('Unknown error during catalog cache initialisation');

            Ext.defer(function () {
                Ext.Msg.toFront()
            }, 10);
            return;
        }

        if (me.toReconfigure)
        {
            // clear filters
            if (me.TTGrid.filters) {
                me.TTGrid.getStore().clearFilter(true);
                me.TTGrid.filters.clearFilters();
                me.TTGrid.filters.destroy();
            }

            var fieldsConfig = [
                {
                    name: 'start',
                    type: 'date',
217e6c35   Hacene SI HADJ MOHAND   affichage oki
245
                    dateFormat: 'Y-m-d\\TH:i:s.u',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
246
247
                    convert: function (value, rec) {
                        if (!Ext.isDate(value)) {
3a8eaaff   Hacene SI HADJ MOHAND   resolue
248
                            return new Date(value);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
249
250
251
252
253
254
255
                        }
                        return value;
                    }
                },
                {
                    name: 'stop',
                    type: 'date',
217e6c35   Hacene SI HADJ MOHAND   affichage oki
256
                    dateFormat: 'Y-m-d\\TH:i:s.u',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
257
258
                    convert: function (value, rec) {
                        if (!Ext.isDate(value)) {
3a8eaaff   Hacene SI HADJ MOHAND   resolue
259
                            return new Date(value);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
260
261
262
263
                        }
                        return value;
                    }
                },
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
264
265
266
267
268
269
270
271
272
273
                 {
                    name: 'durationDay',
                    type: 'float',
                    convert: function (value, rec) {
                        if (rec.get('stop') && rec.get('start') && (rec.get('stop') - rec.get('start')) >= 0) {
                            return (rec.get('stop') - rec.get('start')) / 3600000.0/24.0;
                        }
                    },
                    persist: false
                },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
274
275
276
277
278
279
280
                {
                    name: 'durationHour',
                    type: 'float',
                    convert: function (value, rec) {
                        if (rec.get('stop') && rec.get('start') && (rec.get('stop') - rec.get('start')) >= 0) {
                            return (rec.get('stop') - rec.get('start')) / 3600000.0;
                        }
02e89fbe   Hacene SI HADJ MOHAND   rm_6903 ok
281
                    },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
282
283
284
285
286
287
288
289
290
                    persist: false
                },
                {
                    name: 'durationMin',
                    type: 'float',
                    convert: function (value, rec) {
                        if (rec.get('stop') && rec.get('start') && (rec.get('stop') - rec.get('start')) >= 0) {
                            return (rec.get('stop') - rec.get('start')) / 60000.0;
                        }
d547a559   Hacene SI HADJ MOHAND   rm_6903 ok
291
                    },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
                    persist: false
                },
                {
                    name: 'durationSec',
                    type: 'float',
                    convert: function (value, rec) {
                        if (rec.get('stop') && rec.get('start') && (rec.get('stop') - rec.get('start')) >= 0) {
                            return (rec.get('stop') - rec.get('start')) / 1000.0;
                        }
                    },
                    persist: false
                },
                {name: 'cacheId', type: 'int'},
                {name: 'isNew', type: 'boolean', defaultValue: false},
                {name: 'isModified', type: 'boolean', defaultValue: false}
            ];

            var updateDurationColumnsVisibility = function (columns, visibleId) {
                Ext.Array.each(columns, function (item, index) {
                    // if item is a column to hide automatically
                    if (Ext.util.Format.substr(item.id, 0, amdaUI.CatalogUI.COL_TO_HIDE_DURATION.length) == amdaUI.CatalogUI.COL_TO_HIDE_DURATION) {
                        // if item isn't the column which is being declared and is not hidden
                        if (item.id != visibleId && !item.isHidden()) {
                            // hide this column
                            item.hide();
                        }
                    }
                });
            };

            var columnsConfig = [
                {
                    xtype: 'rownumberer',
                    width: 50,
fd1e1850   Benjamin Renard   Apply minWidth to...
326
                    minWidth: 50,
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
327
328
329
330
331
332
333
334
335
336
                    renderer: function (value, metaData, record) {
                        var msg = record.index + 1;
                        if (record.get('isNew') || record.get('isModified')) {
                            msg += ' *';
                            metaData.style = 'font-weight: bold'
                        }
                        return msg;
                    }
                },
                {
abde111c   Benjamin Renard   Fix columns size ...
337
                    header: 'Start Time', dataIndex: 'start', width: 145,
3a8eaaff   Hacene SI HADJ MOHAND   resolue
338
339
340
341
342
343
344
345
346
347
348
349
                    editor: {xtype: 'datefield', allowBlank: false, hideTrigger: true, format: 'Y-m-d\\TH:i:s.u'},
                    renderer: function (value) {
                        if (value != null) {
                            if (Ext.isDate(value)) {
                                return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u');
                            } else {
                                return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u');
                            }
                        } else {
                            return value;
                        }
                    }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
350
351
                },
                {
abde111c   Benjamin Renard   Fix columns size ...
352
                    header: 'Stop Time', dataIndex: 'stop', width: 145,
3a8eaaff   Hacene SI HADJ MOHAND   resolue
353
354
355
356
357
358
359
360
361
362
363
364
                    editor: {xtype: 'datefield', allowBlank: false, hideTrigger: true, format: 'Y-m-d\\TH:i:s.u'},
                    renderer: function (value) {
                        if (value != null) {
                            if (Ext.isDate(value)) {
                                return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u');
                            } else {
                                return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u');
                            }
                        } else {
                            return value;
                        }
                    }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
365
                },
3a8eaaff   Hacene SI HADJ MOHAND   resolue
366
                    {
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
367
368
369
370
371
372
373
                    xtype: 'gridcolumn',
                    text: 'Duration (day)',
                    sortable: true,
                    dataIndex: 'durationDay',
                    width: 120,
                    minWidth: 50,
                    menuDisabled: false,
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
374
                    hidden: Ext.state.Manager.getProvider().get('cat_duration') != 1 ? true : false,
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
375
376
                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1',
                    renderer: function (value) {
8ee13af1   Hacene SI HADJ MOHAND   solving 9344
377
                        return this.dateToString(value);
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
378
379
380
381
382
383
                    },
                    listeners: {
                        beforeshow: function () {
                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1');
                        }
                    },
8046f4ee   Erdogan Furkan   #7862-Done
384
                    filter: {type: 'customnumericfilter'}
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
385
                },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
386
387
388
389
390
391
                {
                    xtype: 'gridcolumn',
                    text: 'Duration (hour)',
                    sortable: true,
                    dataIndex: 'durationHour',
                    width: 120,
fd1e1850   Benjamin Renard   Apply minWidth to...
392
                    minWidth: 50,
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
393
                    menuDisabled: false,
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
394
                    hidden: Ext.state.Manager.getProvider().get('cat_duration') != 2 ? true : false,
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
395
                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
396
                    renderer: function (value) {
8ee13af1   Hacene SI HADJ MOHAND   solving 9344
397
                        return this.dateToString(value);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
398
399
400
                    },
                    listeners: {
                        beforeshow: function () {
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
401
                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2');
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
402
403
                        }
                    },
8046f4ee   Erdogan Furkan   #7862-Done
404
                    filter: {type: 'customnumericfilter'}
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
405
406
407
408
409
410
411
                },
                {
                    xtype: 'gridcolumn',
                    text: 'Duration (Min)',
                    sortable: true,
                    dataIndex: 'durationMin',
                    width: 120,
fd1e1850   Benjamin Renard   Apply minWidth to...
412
                    minWidth: 50,
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
413
                    menuDisabled: false,
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
414
                    hidden: Ext.state.Manager.getProvider().get('cat_duration') != 3 ? true : false,
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
415
                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
416
                    renderer: function (value) {
8ee13af1   Hacene SI HADJ MOHAND   solving 9344
417
                        return this.dateToString(value);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
418
419
420
                    },
                    listeners: {
                        beforeshow: function () {
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
421
                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3');
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
422
423
                        }
                    },
8046f4ee   Erdogan Furkan   #7862-Done
424
                    filter: {type: 'customnumericfilter'}
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
425
426
427
428
429
430
431
                },
                {
                    xtype: 'gridcolumn',
                    text: 'Duration (Sec)',
                    sortable: true,
                    dataIndex: 'durationSec',
                    width: 120,
fd1e1850   Benjamin Renard   Apply minWidth to...
432
                    minWidth: 50,
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
433
                    menuDisabled: false,
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
434
                    hidden: Ext.state.Manager.getProvider().get('cat_duration') != 4 ? true : false,
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
435
                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '4',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
436
                    renderer: function (value) {
8ee13af1   Hacene SI HADJ MOHAND   solving 9344
437
                        return Ext.util.Format.number(value, '0.000');
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
438
439
440
                    },
                    listeners: {
                        beforeshow: function () {
791d4b0a   Hacene SI HADJ MOHAND   ok cat nok tt
441
                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '4');
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
442
443
                        }
                    },
8046f4ee   Erdogan Furkan   #7862-Done
444
                    filter: {type: 'customnumericfilter'}
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
445
446
447
448
449
450
451
452
453
454
455
                }
            ];
            var pramColumnWidth = 120 * (1 - 0.7 * (1 - 1 / result.parameters.length));
            Ext.Array.each(result.parameters, function (obj, index) {
                var field = {
                    name: obj.id
                };
                var column = {
                    text: obj.name,
                    sortable: true,
                    dataIndex: obj.id,
fd1e1850   Benjamin Renard   Apply minWidth to...
456
                    menuDisabled: false,
3d95b0a6   furkan   Adding the Delete...
457
458
                    minWidth: 50,
                    paramColumn: true
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
459
460
461
462
463
464
465
466
467
468
                };
                switch (obj.type) {
                    case 0: //double
                        field = Ext.apply({}, field, {
                            type: 'string'
                        });
                        column = Ext.apply({}, column, {
                            xtype: 'gridcolumn',
                            width: pramColumnWidth * parseInt(obj.size),
                            editor: 'textfield',
8046f4ee   Erdogan Furkan   #7862-Done
469
                            filter: {type: 'customnumericfilter', menuItemCfgs: {decimalPrecision: 10}},
f6464410   Erdogan Furkan   #10765 - Done.
470
471
472
                            renderer :function(value){
                                return (value == "NAN") ? "nan": value;
                            },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
473
474
475
476
477
                        });
                        break;
                    case 1: //dateTime
                        field = Ext.apply({}, field, {
                            type: 'date',
217e6c35   Hacene SI HADJ MOHAND   affichage oki
478
                            dateFormat: 'Y-m-d\\TH:i:s.u',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
479
480
                            convert: function (value, rec) {
                                if (!Ext.isDate(value)) {
42c4ccd3   Erdogan Furkan   #9660 - Done
481
                                    return new Date(value);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
482
483
                                }
                                return value;
edd2e650   Hacene SI HADJ MOHAND   correcting 7100
484
                            }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
485
486
                        });
                        column = Ext.apply({}, column, {
edd2e650   Hacene SI HADJ MOHAND   correcting 7100
487
                            xtype: 'datecolumn',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
488
489
490
491
492
                            width: 120,
                            editor: {
                                xtype: 'datefield',
                                allowBlank: false,
                                hideTrigger: true,
217e6c35   Hacene SI HADJ MOHAND   affichage oki
493
                                format: 'Y-m-d\\TH:i:s.u'
edd2e650   Hacene SI HADJ MOHAND   correcting 7100
494
                            },
8046f4ee   Erdogan Furkan   #7862-Done
495
                            filter: {type: 'customdatefilter', dateFormat: 'Y-m-d'},
42c4ccd3   Erdogan Furkan   #9660 - Done
496
497
498
499
500
501
502
503
504
505
506
                            renderer: function (value) {
                                if (value != null) {
                                    if (Ext.isDate(value)) {
                                        return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u');
                                    } else {
                                        return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u');
                                    }
                                } else {
                                    return value;
                                }
                            }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
507
508
509
510
511
512
513
514
515
516
                        });
                        break;
                    case 2: //string
                        field = Ext.apply({}, field, {
                            type: 'string'
                        });
                        column = Ext.apply({}, column, {
                            xtype: 'gridcolumn',
                            width: pramColumnWidth * parseInt(obj.size),
                            editor: 'textfield',
8046f4ee   Erdogan Furkan   #7862-Done
517
                            filter: {type: 'customstringfilter'},
d93e3f55   Hacene SI HADJ MOHAND   us ok
518
                            renderer :function(value){
d34525e2   Benjamin Renard   Fix URL in catalo...
519
520
521
				var renderedVal = value;
                                if(value.toLowerCase().startsWith("http://") ||value.toLowerCase().startsWith("https://")) {
                                         renderedVal = '<a href="' + value + '" target="_blank">' + value +'</a>';
d93e3f55   Hacene SI HADJ MOHAND   us ok
522
                                }
d34525e2   Benjamin Renard   Fix URL in catalo...
523
                                return renderedVal;
8046f4ee   Erdogan Furkan   #7862-Done
524
                          }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
525
526
527
528
529
530
531
532
533
534
                        });
                        break;
                    case 3: //int
                        field = Ext.apply({}, field, {
                            type: 'string'
                        });
                        column = Ext.apply({}, column, {
                            xtype: 'gridcolumn',
                            width: pramColumnWidth * parseInt(obj.size),
                            editor: 'textfield',
8046f4ee   Erdogan Furkan   #7862-Done
535
                            filter: {type: 'customnumericfilter'}
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
536
537
538
539
540
541
542
543
544
545
                        });
                        break;
                    default:
                        field = Ext.apply({}, field, {
                            type: 'string'
                        });
                        column = Ext.apply({}, column, {
                            xtype: 'gridcolumn',
                            width: pramColumnWidth * parseInt(obj.size),
                            editor: 'textfield',
8046f4ee   Erdogan Furkan   #7862-Done
546
                            filter: {type: 'customstringfilter'}
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
547
548
549
550
                        });
                }
                fieldsConfig.push(field);
                columnsConfig.push(column);
e022e5b5   Benjamin Renard   Filter parameter ...
551
            });
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
            var store = Ext.create('Ext.data.Store', {
                fields: fieldsConfig,
                autoDestroy: false,
                pageSize: 200,
                buffered: true,
                purgePageCount: 0,
                remoteSort: true,
                proxy: {
                    type: 'direct',
                    api: {read: AmdaAction.readCacheIntervals},
                    // remplir automatiquement tt, sharedtt , catalog, shared catalog
                    extraParams: {'typeTT': 'catalog'},
                    reader:
                            {
                                type: 'json',
                                root: 'intervals',
                                totalProperty: 'totalCount'
                            }
                },
                listeners: {
                    scope: me,
                    load: function (store, records) {
                        // myDesktopApp.EventManager.fireEvent('refresh');
                        me.TTGrid.getView().refresh();
                        me.TTGrid.getSelectionModel().refresh();
                        me.updateCount();
                        //Statistical plugin
                        this.fireEvent("refresh");
827bddef   Benjamin Renard   Fix save of a fil...
580
581
582
583
584
585
586
                    },
                    prefetch: function (store, records, successful, operation, eOpts) {
                        if (operation && (operation.action == 'read'))
                        {
                            if (operation.response && operation.response.result && operation.response.result.success)
                                me.status = operation.response.result.status;
                        }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
587
588
                    }
                }
e022e5b5   Benjamin Renard   Filter parameter ...
589
            });
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
590
591
592
593
594
595
596
597
598

            me.TTGrid.reconfigure(store, columnsConfig);
            if (me.TTGrid.filters) {
                me.TTGrid.filters.bindStore(store);
            }
        }
        me.TTGrid.getSelectionModel().deselectAll();
        //
        //         	// clear filters
827bddef   Benjamin Renard   Fix save of a fil...
599
600
601
602
603
        if (me.TTGrid.filters) {
            me.TTGrid.getStore().clearFilter(true);
            me.TTGrid.filters.clearFilters();
        }

13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
        //
        // clear sort
        me.TTGrid.getStore().sorters.clear();
        //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection();

        //set cache token to the Catalog object
        me.object.set('cacheToken', result.token);
        me.setParamInfo(result.parameters);
        me.TTGrid.getStore().load();

        me.status = result.status;
        //Statistical plugin
        me.fireEvent("refresh");
    },

    /**
     * load object catalog into this view
     */
    loadObject: function () {
        // load object into form
1d7c3a74   Hacene SI HADJ MOHAND   correcting #7320
624
        this.object.set('created', this.convertUTCDateToLocalDate(this.object.get('created')));
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
        this.formPanel.getForm().loadRecord(this.object);

        this.status = null;

        if (this.object.get('fromPlugin') && (this.object.get('objName') != '')) {
            if (this.object.get('objFormat') && this.object.get('objFormat') != '') {
                //From uploaded file
                AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this);
            } else {
                //From tmp object (ie Statistics result)
                AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this);
            }
        } else {
            var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType;

            if (this.object.get('id') == '' && this.object.get('relatedTimeTableId') == '') {
                // creating new catalog
                AmdaAction.initObjectCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit, this);
            } else if (this.object.get('relatedTimeTableId') != '') {
                // Generate Catalog from Time Table
ceac8bd0   Hacene SI HADJ MOHAND   us ok
645
646
647
                var pathern = this.object.get('relatedTimeTableId').split('_')[0];
                if (pathern == 'sharedtimeTable')
			typeTT='sharedtimeTable';
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
648
649
650
651
652
653
654
655
656
657
658
                AmdaAction.initObjectCacheFromTimeTable(this.object.get('relatedTimeTableId'), typeTT, this.object.get('nbParameters'), this.onAfterInit, this);
            } else {
                //From existing TT file
                AmdaAction.initObjectCacheFromObject(this.object.get('id'), typeTT, this.onAfterInit, this);
            }
        }
        //Statistical plugin
        this.fireEvent("refresh");
    },

    checkIntervalsStatusForSave: function (onStatusOk) {
5535e93a   Erdogan Furkan   Filter(#10688)/So...
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
        if (this.status == null)
            return;

        if (this.status.nbValid <= 0)
        {
            myDesktopApp.errorMsg('Your catalog is invalid, <br>you must have at least one valid interval');
            return;
        }

        var msg = '';
        if (this.status.nbInvalid > 0)
            msg += 'There are some invalid intervals. Only valid intervals will be saved!<br/>';
        if (this.status.nbFiltered > 0)
            msg += 'There are some filtered intervals. Filtered intervals will not be saved!<br/>';
        if (msg != '')
        {
            msg += 'Do you want to continue?';
            Ext.Msg.show({
                title: 'Warning!',
                msg: msg,
                buttons: Ext.Msg.OKCANCEL,
                fn: function (btnId) {
                    if (btnId === 'cancel') {
                        // cancel the save action
                    } else {
                        onStatusOk();
                    }
                },
                scope: this,
                icon: Ext.Msg.WARNING
            });
            return;
        }

13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
693
694
695
696
697
698
699
700
701
702
703
        onStatusOk();
    },

    /*
     * save method called by Save button
     */
    saveProcess: function (toRename, onAfterSave, notDisplayMsg)
    {
        var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
        //  store / columns are the same - not needed to reconfigure grid
        this.toReconfigure = false;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
704
705
706
707
708
709
710
711
712

        // if save shared catalog
        if (module.contextNode && (module.contextNode.get('id') == 'sharedcatalog-treeRootNode'))
        {
            module.linkedNode = null;
            module.createLinkedNode();
            module.createObject(this.object.getJsonValues());
            var obj = module.linkedNode.get('object');
            // synchronisation of objects
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
713
            this.object = obj;
5535e93a   Erdogan Furkan   Filter(#10688)/So...
714
715
716
            module.linkedNode.create({notDisplayMsg: notDisplayMsg, callback: function (type,res) {
                this.updateSurveyDates(res);     
                if (onAfterSave)
827bddef   Benjamin Renard   Fix save of a fil...
717
                        onAfterSave();
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
718
719
720
                }, scope: this});
        }
        // if the name has been modified this is a creation
5535e93a   Erdogan Furkan   Filter(#10688)/So...
721
        else if (this.fclose() || this.status) {
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
            if (this.object.isModified('name') || this.object.get('fromPlugin')) {
                // if object already has an id : it's a 'rename' of an existing
                if (this.object.get('id')) {
                    // the context Node is the parent node of current edited one
                    var contextNode = module.linkedNode.parentNode;
                    // link a new node to the TimeTableModule
                    module.createLinkedNode();
                    // set the contextNode
                    module.linkedNode.set('contextNode', contextNode);
                    // create a new object linked
                    module.createObject(this.object.getJsonValues());

                    var obj = module.linkedNode.get('object');
                    // synchronisation of objects
                    this.object = obj;
                    if (toRename)
                        module.linkedNode.toRename = true;
                }
                module.linkedNode.create({callback: function () {
5535e93a   Erdogan Furkan   Filter(#10688)/So...
741
742
743
744
                        module.linkedNode.update({notDisplayMsg: notDisplayMsg, callback: function (type,res) {
                            this.updateSurveyDates(res);    
                            if (onAfterSave)
                                onAfterSave();
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
745
746
747
748
                            }, scope: this}, "", notDisplayMsg);
                    }, scope: this});
            } else {
                //update
5535e93a   Erdogan Furkan   Filter(#10688)/So...
749
750
751
752
                module.linkedNode.update({notDisplayMsg: notDisplayMsg, callback: function (type,res) {
                    this.updateSurveyDates(res);     
                    if (onAfterSave)
                        onAfterSave();
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
753
754
755
756
757
758
759
760
                    }, scope: this});
            }
        }
    },
    saveCatalog: function (onAfterSave, notDisplayMsg) {
        if (this.updateObject())
        {
            var basicForm = this.formPanel.getForm();
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
761
                // update TimeTable object which the content of form
2ff71aba   Hacene SI HADJ MOHAND   correcting survey...
762

5535e93a   Erdogan Furkan   Filter(#10688)/So...
763
764
765
766
767
768
769
770
771
772
773
774
775
776
            basicForm.updateRecord(this.object);
            var me = this;
            this.checkIntervalsStatusForSave(function () {
                //Name validation
                var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);

                if (!module)
                    return;
                module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
                {
                    if (!res) {
                        me.fieldName.validFlag = 'Error during object validation';
                        myDesktopApp.errorMsg(me.fieldName.validFlag);
                        me.fieldName.validate();
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
777
                        return;
5535e93a   Erdogan Furkan   Filter(#10688)/So...
778
                    }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
779

5535e93a   Erdogan Furkan   Filter(#10688)/So...
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
                    if (!res.valid) {
                        if (res.error) {
                            if (res.error.search('subtree') != -1) {
                                Ext.MessageBox.show({title: 'Warning',
                                    msg: res.error + '<br/>Do you want to overwrite it?',
                                    width: 300,
                                    buttons: Ext.MessageBox.OKCANCEL,
                                    fn: me.overwriteProcess,
                                    icon: Ext.MessageBox.WARNING,
                                    scope: me
                                });
                                me.fieldName.validFlag = true;
                            } else
                                me.fieldName.validFlag = res.error;
                        } else {
                            me.fieldName.validFlag = 'Invalid object name';
                            myDesktopApp.errorMsg(me.fieldName.validFlag);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
797
                        }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
798
                        me.fieldName.validate();
5535e93a   Erdogan Furkan   Filter(#10688)/So...
799
800
801
802
803
804
                        return;
                    }

                    me.fieldName.validFlag = true;
                    me.fieldName.validate();
                    me.saveProcess(false, onAfterSave, notDisplayMsg);
edd2e650   Hacene SI HADJ MOHAND   correcting 7100
805
                });
5535e93a   Erdogan Furkan   Filter(#10688)/So...
806
            });
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
        }
    },

    /**
     * overwrite metod called by Save button
     */
    overwriteProcess: function (btn) {
        if (btn == 'cancel')
            return;

        this.fieldName.clearInvalid();
        this.saveProcess(true);
    },

    /**
     * Check if changes were made before closing window
     * @return true if changes
     */
    fclose: function () {
        if (this.status == null)
            return false;

        var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0);
        return isDirty;
    },
f4b125fb   Hacene SI HADJ MOHAND   il reste a bloque...
832
833
834
835
836
837
838
839
840
841
842
843
        onChangeStartField: function(field, newValue, oldValue){
        if (field.isValid()) {
            if (field.isValid() && this.activeField == 'surveyStart') {
                // launch the update of duration fields
                var form = this.findParentByType('form').getForm();
                var stop = form.findField('surveyStop').setMinValue(newValue);
                var start = form.findField('surveyStart').getValue();
                var stop = form.findField('surveyStop').getValue();
                if (stop <= start) {
                    form.findField('surveyStart').markInvalid('Start Time  must be before Stop Time');
                }
            }
709a2d2e   Hacene SI HADJ MOHAND   il reste auto sta...
844
        }
f4b125fb   Hacene SI HADJ MOHAND   il reste a bloque...
845
     },
709a2d2e   Hacene SI HADJ MOHAND   il reste auto sta...
846
847
848
849
850
851
852
853
854
855
856
857
        onChangeStopField: function(field, newValue, oldValue)
	{
		if (field.isValid() && this.activeField =='surveyStop' ) {
			// launch the update of duration fields
                                                    var form = this.findParentByType('form').getForm();
                                                    var start = form.findField('surveyStart').getValue();
                                                    var stop =form.findField('surveyStop').getValue();
             if ( stop <= start ) {
                field.markInvalid('Stop Time  must be after Start Time');
            } 
		}
	},
42c4ccd3   Erdogan Furkan   #9660 - Done
858
859

    columnForm: function(isNew, self, me , columnInfo = null){
ce347c54   Erdogan Furkan   Done.
860

a19578d1   Erdogan Furkan   Status for parame...
861
        this.statusGrid = Ext.create('amdaUI.StatusGrid',{type:'cat',status : (columnInfo != null) ? columnInfo.status : null });
ce347c54   Erdogan Furkan   Done.
862
        var me = this;
42c4ccd3   Erdogan Furkan   #9660 - Done
863
864
865
866
867
868
869
870
871
872
873
        // Different avaible types
        var types = Ext.create('Ext.data.Store', {
        fields: ['type', 'name'],
        data : [
            {"type":2, "name":"String"},
            {"type":3, "name":"Integer"},
            {"type":0, "name":"Float"},
            {"type":1,"name":"TIme"}
        ]
        });

42c4ccd3   Erdogan Furkan   #9660 - Done
874
875
876
        // Window for the creation of the new Column
        var window = Ext.create('Ext.window.Window', {
            title: (isNew) ? 'New Column' : 'Edit Column',
ce347c54   Erdogan Furkan   Done.
877
            width: 480,
1fc076b5   Erdogan Furkan   #9660 - Adding de...
878
            height: 210,
42c4ccd3   Erdogan Furkan   #9660 - Done
879
880
881
882
883
884
            closable:false,
            modal:true,
            resizable: false,
            items: [
                {
                    xtype: 'form',
7fc31ac3   Erdogan Furkan   For now, will com...
885
886
887
888
889
890
891
892
893
                    renderTo: Ext.getBody(),
                    
                    fieldDefaults: {
                        labelAlign: 'right',
                        msgTarget: 'side'
                    },
                    defaults: {
                        xtype: 'panel',
                        bodyStyle: {background: '#dfe8f6'},
7fc31ac3   Erdogan Furkan   For now, will com...
894
895
896
897
                        border:false,
                        layout: 'anchor'
                    },
                    layout:'hbox',
42c4ccd3   Erdogan Furkan   #9660 - Done
898
899
                    id: 'simpleForm',
                    frame: true,
42c4ccd3   Erdogan Furkan   #9660 - Done
900
                    items: [{
ce347c54   Erdogan Furkan   Done.
901
                        flex:6,
7fc31ac3   Erdogan Furkan   For now, will com...
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
                        items:[{
                            // Name 
                            xtype:'textfield', 
                            fieldLabel: 'Column Name',
                            name: 'nameColumn',
                            value: (isNew) ? null : columnInfo.name,
                            allowBlank: false,
                            tooltip: 'Enter the name of the column you want to create'
                        },{
                            // Type
                            xtype: 'combobox',
                            fieldLabel: 'Data Type',
                            name:'typeColumn',
                            store:types,
                            allowBlank: false,
                            value : (isNew) ? null : columnInfo.type,
                            queryMode: 'local',
                            displayField: 'name',
                            valueField: 'type',
                            editable: false,
                            tooltip: 'Enter the type of data you want to put in this column'
                        },
                        {
                            // Size
                            xtype:'numberfield',
                            fieldLabel: 'Size',
                            name: 'sizeColumn',
                            value: (isNew) ? 1 : columnInfo.size,
                            maxValue: 3,
                            minValue: 1,
                            allowBlank: false,
                            tooltip: 'For exemple: 1 for scalar type or 3 for a vector'
                        },
                        {
                            // Name 
                            xtype:'textarea', 
                            fieldLabel: 'Description',
                            name: 'descriptionColumn',
                            height:50,
                            value: (isNew) ? null : columnInfo.description,
                            allowBlank: true,
                        }]
1fc076b5   Erdogan Furkan   #9660 - Adding de...
944
945
                    },
                    {
ce347c54   Erdogan Furkan   Done.
946
947
948
                        flex:4,
                        margin:'0 8 0 -5',
                        items:[this.statusGrid],
7fc31ac3   Erdogan Furkan   For now, will com...
949
                    }],
42c4ccd3   Erdogan Furkan   #9660 - Done
950
951
952
953
954

                    buttons: [{
                        text: 'Save',
                        handler: function() {
                            // If the form is correctly filled, we continue
ce347c54   Erdogan Furkan   Done.
955

42c4ccd3   Erdogan Furkan   #9660 - Done
956
957
                            if(this.up('form').getForm().isValid()){
                                if(isNew){
42c4ccd3   Erdogan Furkan   #9660 - Done
958
959
960
961
962
963
964
965
966
967
968
969
                                    var newColumnPrefix='added_param_id_';
                                    var nbAddedColumn= 0;
                                    Ext.each(self.TTGrid.headerCt.getGridColumns(), function(column){
                                        if(column.dataIndex.substr(0, 15) == newColumnPrefix){
                                            nbAddedColumn++;
                                        }
                                    });

                                    AmdaAction.addColumn(newColumnPrefix+nbAddedColumn,
                                                        this.up('form').getForm().findField('nameColumn').getValue(),
                                                        this.up('form').getForm().findField('typeColumn').getValue(),
                                                        this.up('form').getForm().findField('sizeColumn').getValue(),
1fc076b5   Erdogan Furkan   #9660 - Adding de...
970
                                                        this.up('form').getForm().findField('descriptionColumn').getValue(),
ce347c54   Erdogan Furkan   Done.
971
                                                        me.statusGrid.getStatusString(),
42c4ccd3   Erdogan Furkan   #9660 - Done
972
973
974
975
976
977
978
979
980
981
982
983
                                                        function(result, e){
                                        if(result){
                                            me.toReconfigure = true;
                                            me.onAfterInit(result);
                                            window.close();
                                        }
                                    });
                                }
                                else{
                                    var newName = null;
                                    var newType = null;
                                    var newSize = null;
1fc076b5   Erdogan Furkan   #9660 - Adding de...
984
                                    var newDescription = null;
ce347c54   Erdogan Furkan   Done.
985
                                    var newStatus = null;
42c4ccd3   Erdogan Furkan   #9660 - Done
986
987
988
989
990
991
992
993
994
995
996

                                    // Check if there is modifications
                                    if(this.up('form').getForm().findField('nameColumn').getValue() != columnInfo.name){
                                        newName = this.up('form').getForm().findField('nameColumn').getValue();
                                    }
                                    if(this.up('form').getForm().findField('typeColumn').getValue() != columnInfo.type){
                                        newType = this.up('form').getForm().findField('typeColumn').getValue();
                                    }
                                    if(this.up('form').getForm().findField('sizeColumn').getValue() != columnInfo.size){
                                        newSize = this.up('form').getForm().findField('sizeColumn').getValue();
                                    }
1fc076b5   Erdogan Furkan   #9660 - Adding de...
997
998
999
                                    if(this.up('form').getForm().findField('descriptionColumn').getValue() != columnInfo.description){
                                        newDescription = this.up('form').getForm().findField('descriptionColumn').getValue();
                                    }
ce347c54   Erdogan Furkan   Done.
1000
1001
1002
                                    if(me.statusGrid.getStatusString() != columnInfo.status){
                                        newStatus = me.statusGrid.getStatusString();
                                    }
42c4ccd3   Erdogan Furkan   #9660 - Done
1003

ce347c54   Erdogan Furkan   Done.
1004
                                    if(newName != null || newType != null || newSize != null || newDescription != null || newStatus != null) 
42c4ccd3   Erdogan Furkan   #9660 - Done
1005
                                    {
ce347c54   Erdogan Furkan   Done.
1006
                                        AmdaAction.editColumn(columnInfo.id, newName, newType, newSize, newDescription, newStatus, function(result, e){
42c4ccd3   Erdogan Furkan   #9660 - Done
1007
1008
1009
                                            if(result){
                                                me.toReconfigure = true;
                                                me.onAfterInit(result);
ce347c54   Erdogan Furkan   Done.
1010
                                                me.statusGrid.clearStore();
42c4ccd3   Erdogan Furkan   #9660 - Done
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
                                                window.close();
                                            }
                                        });
                                        
                                    }
                                    else{
                                        window.close();
                                    }
                                }
                            }
                        },
                    },
                    {
                        // to reset the form
                        text: 'Reset',
                        handler: function() {
                            this.up('form').getForm().reset();
ce347c54   Erdogan Furkan   Done.
1028
1029
                            me.statusGrid.clearStore();
                            me.statusGrid.parseStatus(columnInfo.status);
42c4ccd3   Erdogan Furkan   #9660 - Done
1030
1031
1032
1033
1034
1035
                        }
                    },
                    {
                        // To quit the window
                        text: 'Cancel',
                        handler: function() {
ce347c54   Erdogan Furkan   Done.
1036
                            me.statusGrid.clearStore();
42c4ccd3   Erdogan Furkan   #9660 - Done
1037
1038
1039
1040
1041
1042
1043
1044
1045
                            window.close();
                        }
                    }]
                }
            ]
        }).show();
        
    },

13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1046
1047
    init: function (config)
    {
8046f4ee   Erdogan Furkan   #7862-Done
1048
        amdaUI.CustomFilters.init();
3d95b0a6   furkan   Adding the Delete...
1049
        var me = this;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1050
        this.object = config.object;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
        this.fieldName = new Ext.form.field.Text({
            fieldLabel: 'Name',
            allowBlank: false,
            stripCharsRe: /(^\s+|\s+$)/g,
            emptyText: 'Please no spaces!',
            name: 'name',
            validateOnChange: false,
            validateOnBlur: false,
            validFlag: false,
            validator: function () {
                return this.validFlag;
            }
        });
6ab359f0   Benjamin Renard   Cleanup model fie...
1064

13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
        var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
//			clicksToEdit: 2,
            onEditComplete: function (ed, value, startValue) {
                var me = this,
                        activeColumn = me.getActiveColumn(),
                        context = me.context,
                        record;

                if (activeColumn) {
                    record = context.record;

                    me.setActiveEditor(null);
                    me.setActiveColumn(null);
                    me.setActiveRecord(null);

                    context.value = value;
                    if (!me.validateEdit()) {
                        me.editing = false;
                        return;
                    }

                    // Only update the record if the new value is different than the
                    // startValue. When the view refreshes its el will gain focus
                    if (!record.isEqual(value, startValue)) {
                        var obj = {
                            'cacheId': record.get('cacheId'),
                            'isCatalog': true,
                            'data': {}
                        };
3a8eaaff   Hacene SI HADJ MOHAND   resolue
1094
1095
1096
1097
                        if(activeColumn.dataIndex == "start" ||  activeColumn.dataIndex == "stop")
                                obj['data'][activeColumn.dataIndex] = Ext.Date.format(value, 'Y-m-d\\TH:i:s.u');
                        else
                                obj['data'][activeColumn.dataIndex] = value;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133

                        //Interval is modified on the server side
                        me.editing = true;

                        AmdaAction.modifyCacheInterval(obj, function (result, e) {
                            var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
                            if (module)
                                module.getUiContent().status = result.status;
                            if (!context.store.loading) {
                                context.grid.getSelectionModel().deselectAll();
                                context.store.reload({
                                    callback: function (records, options, success) {
                                        context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function () {
                                            me.fireEvent('edit', me, context);
                                            me.editing = false;
                                        }, me);
                                    }
                                });
                            } else {
                                me.editing = false;
                            }
                        }, this);
                    } else
                        me.editing = false;
                }
            }
        });

        var filters = {
            ftype: 'filters',
            encode: true, // json encode the filter query
            local: false,
            filters: [

            ]
        };
42c4ccd3   Erdogan Furkan   #9660 - Done
1134
        const self = this;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1135
1136
1137
1138
1139
1140
1141
        this.TTGrid = Ext.create('Ext.grid.Panel', {
            height: 530,
            features: [filters],
            columns: [],
            frame: true,
            columnLines: true,
            selModel: {pruneRemoved: false},
8ee13af1   Hacene SI HADJ MOHAND   solving 9344
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
            
          countDecimals: function (value) {
                if (Math.floor(value) === value)
                    return 0;
                return value.toString().split(".")[1].length || 0;
            },
            
            dateToString: function (value) {
                ndegits = this.countDecimals(value);
                if (ndegits <= 3) {
                    return  Ext.util.Format.number(value, '0.000');
                } else if (value < 0.1) {
                    return value.toExponential(3);
                } else {
                    return Ext.util.Format.number(value, '0.000000');
                }
            },
            
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1160
1161
            //	selType: 'cellmodel',
            plugins: [cellEditing, {ptype: 'bufferedrenderer'}],
b39df83c   Benjamin Renard   Correction of a r...
1162
            listeners: {
3d95b0a6   furkan   Adding the Delete...
1163
                afterrender: function ( ) {
1d7c3a74   Hacene SI HADJ MOHAND   correcting #7320
1164
                    this.TTGrid.headerCt.resizer.tracker.gridBugFix = true;
3d95b0a6   furkan   Adding the Delete...
1165
1166
1167
                    // Adding "Delete Column" in the menu
                    var menu = this.TTGrid.headerCt.getMenu();
                    menu.on('beforeshow',function(){
42c4ccd3   Erdogan Furkan   #9660 - Done
1168
1169
                        var deleteName='delete_column';
                        var editName= 'edit_column';
3d95b0a6   furkan   Adding the Delete...
1170
                        var isDeleteinMenu = false;
42c4ccd3   Erdogan Furkan   #9660 - Done
1171
1172
                        var isEditInMenu = false;
                        // Is there already the delete or edit item in the menu
3d95b0a6   furkan   Adding the Delete...
1173
                        Ext.each(menu.items.items, function(items){
42c4ccd3   Erdogan Furkan   #9660 - Done
1174
                            if(items.name == deleteName){
3d95b0a6   furkan   Adding the Delete...
1175
1176
                                isDeleteinMenu = true;
                            }
42c4ccd3   Erdogan Furkan   #9660 - Done
1177
1178
1179
1180
                            if(items.name == editName){
                                isEditInMenu = true;
                            }

3d95b0a6   furkan   Adding the Delete...
1181
1182
1183
1184
1185
1186
1187
1188
                        });
                        // Computing the number of parameters in the catalog
                        var nbParamColumns=0;
                        Ext.each(this.TTGrid.headerCt.getGridColumns(), function(column){
                            if(column.paramColumn){
                                nbParamColumns++
                            }
                        });
42c4ccd3   Erdogan Furkan   #9660 - Done
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205

                        // Adding the "Edit Column" if conditions satisfied
                        if(!isEditInMenu){
                            menu.add({
                                text: 'Edit Column',
                                iconCls: 'icon-parameters',
                                name: editName,
                                handler: function(item,e) {
                                    AmdaAction.getCatColumnInfo(menu.activeHeader.dataIndex,function(result, e){
                                        if(result){
                                            me.columnForm(false, self,me, result);
                                        }
                                    });
                                }
                            });
                        }

3d95b0a6   furkan   Adding the Delete...
1206
                        // Adding the "Delete Column" if conditions satisfied
42c4ccd3   Erdogan Furkan   #9660 - Done
1207
1208
                        if(!isDeleteinMenu){
                            menu.add({
3d95b0a6   furkan   Adding the Delete...
1209
                                text: 'Delete Column',
42c4ccd3   Erdogan Furkan   #9660 - Done
1210
1211
1212
                                iconCls: 'icon-delete',
                                disabled:false,
                                name: deleteName,
3d95b0a6   furkan   Adding the Delete...
1213
1214
1215
1216
1217
1218
                                handler: function(item,e) {
                                    AmdaAction.deleteColumn(menu.activeHeader.dataIndex,function(result, e){
                                        me.toReconfigure = true;
                                        me.onAfterInit(result);
                                    });
                                }
3d95b0a6   furkan   Adding the Delete...
1219
1220
                            });
                        }
42c4ccd3   Erdogan Furkan   #9660 - Done
1221
1222
1223
1224
1225
1226
1227
1228
1229

                        Ext.each(menu.items.items, function(item){
                            if(item.name == deleteName){
                                item.setDisabled(!menu.activeHeader.paramColumn || nbParamColumns <= 1);
                            }
                            if(item.name == editName){
                                item.setDisabled(!menu.activeHeader.paramColumn);
                            }
                        });
3d95b0a6   furkan   Adding the Delete...
1230
                    }, this);
1d7c3a74   Hacene SI HADJ MOHAND   correcting #7320
1231
                },
f5ed8bb2   Erdogan Furkan   #9505 - Added dur...
1232
1233
1234
1235
1236
1237
1238
1239
1240
                scope: this,
                columnschanged:function(ct,eOpts){ // Takes into count the duration changes
                    Ext.Array.each(ct.getGridColumns(), function (item, index, all) {
                        if (Ext.util.Format.substr(item.id, 0, amdaUI.CatalogUI.COL_TO_HIDE_DURATION.length) == amdaUI.CatalogUI.COL_TO_HIDE_DURATION && !item.isHidden()) {
                            var durationNumber = parseInt(Ext.util.Format.substr(item.id, amdaUI.CatalogUI.COL_TO_HIDE_DURATION.length, amdaUI.CatalogUI.COL_TO_HIDE_DURATION.length+1));
                            Ext.state.Manager.getProvider().set('cat_duration', durationNumber);
                        }
                    });
                }
b39df83c   Benjamin Renard   Correction of a r...
1241
            },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1242
1243
1244
1245
            dockedItems: [{
                    xtype: 'toolbar',
                    items: [{
                            iconCls: 'icon-add',
3d95b0a6   furkan   Adding the Delete...
1246
                            text:'New line',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
                            scope: this,
                            handler: function () {
                                cellEditing.cancelEdit();
                                var store = this.TTGrid.getStore();

                                var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
                                var row = 0;
                                if (selection)
                                    row = store.indexOf(selection) + 1;
                                this.TTGrid.getSelectionModel().deselectAll();
02e89fbe   Hacene SI HADJ MOHAND   rm_6903 ok
1257
1258

                                var me = this;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
                                AmdaAction.addCacheInterval({'index': row, 'isCatalog': true}, function (result, e) {
                                    this.status = result.status;
                                    if (!this.TTGrid.getStore().loading) {
                                        this.TTGrid.getStore().reload({
                                            callback: function (records, options, success) {
                                                me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function () {
                                                    me.TTGrid.getView().select(row);
                                                    cellEditing.startEditByPosition({row: row, column: 1});
                                                }, me);
                                            }
                                        });
                                    }
                                }, this);
                            }
3d95b0a6   furkan   Adding the Delete...
1273
1274
                        }, 
                        {
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1275
1276
                            iconCls: 'icon-delete',
                            disabled: true,
3d95b0a6   furkan   Adding the Delete...
1277
                            text:'Delete Line',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
                            itemId: 'delete',
                            scope: this,
                            handler: function () {
                                var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
                                if (selection)
                                {
                                    var rowId = selection.get('cacheId');
                                    this.TTGrid.getSelectionModel().deselectAll();
                                    AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) {
                                        this.status = result.status;
                                        if (!this.TTGrid.getStore().loading) {
                                            this.TTGrid.getStore().reload();
                                        }
                                    }, this);
                                }
                            }
3d95b0a6   furkan   Adding the Delete...
1294
1295
1296
1297
1298
1299
1300
                        },
                        '-',{
                            iconCls: 'icon-add',
                            text:'New Column(s)',
                            itemId: 'column_add',
                            scope: this,
                            handler: function () {
42c4ccd3   Erdogan Furkan   #9660 - Done
1301
1302
1303

                                me.columnForm(true, self,me);
                            }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
                        }, '->',
                        {
                            text: 'Clear Filters',
                            scope: this,
                            handler: function () {
                                this.TTGrid.getStore().clearFilter(true);
                                this.TTGrid.filters.clearFilters();
                            }
                        }]
                }]
        });
3c6689fd   Erdogan Furkan   TextArea has clic...
1315
1316
1317
1318
1319
1320
        this.codeDescripton = Ext.create('amdaUI.DescriptionField',{
            xtype: 'descriptionfield',
            height:150,
            align:'stretch',
            name: 'description',
        });
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1321
1322
        this.formPanel = Ext.create('Ext.form.Panel', {
            region: 'center',
d1dd574b   Furkan   Done, in a way
1323
            me:this,
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1324
            layout: 'hbox',
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1325
1326
1327
1328
1329
1330
            model: 'amdaModel.Catalog',
            trackResetOnLoad: true, // reset to the last loaded record
            bodyStyle: {background: '#dfe8f6'},
            defaults: {border: false, align: 'stretch', bodyStyle: {background: '#dfe8f6'}, padding: '3'},
            fieldDefaults: {labelWidth: 80, labelAlign: 'top'},
            items: [{
d1dd574b   Furkan   Done, in a way
1331
1332
1333
1334
1335
1336
1337
                xtype:'panel',
                overflowY:true,
                height:530,
                layout:'hbox',
                defaults: {border: false, align: 'stretch',bodyStyle: {background: '#dfe8f6',padding: '1'}},
                flex: 1,
                items:[{
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1338
1339
1340
1341
                    xtype: 'form',
                    flex: 1,
                    buttonAlign: 'left',
                    // title : 'Information',
d1dd574b   Furkan   Done, in a way
1342
                    layout: {type: 'vbox',  pack:'start',align: 'stretch'},
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
                    items: [
                        this.fieldName,
                        {
                            xtype: 'fieldcontainer',
                            layout: 'hbox',
                            items: [{
                                    xtype: 'datefield', fieldLabel: 'Creation date',
                                    name: 'created', disabled: true,
                                    hideTrigger: true, format: 'Y/m/d H:i:s'
                                },
                                {xtype: 'splitter'},
                                {xtype: 'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true}
                            ]
                        },
                        {
a4acaf46   Hacene SI HADJ MOHAND   IHM progess
1358
1359
1360
1361
1362
1363
1364
1365
                            xtype:'fieldset',
                            columnWidth: 0.5,
                            title: 'Survey Period',
                            collapsible: true,
                            defaultType: 'datefield',
                            defaults: {anchor: '100%'},
                            layout: 'anchor',
                            items :[{
7c236e57   Erdogan Furkan   #10576 - Pb with ...
1366
1367
1368
1369
1370
                                fieldLabel: 'Start Time',
                                name: 'surveyStart',
                                emptyText: 'YYYY/MM/DDThh:mm:ss.fff',
                                format: 'Y-m-d\\TH:i:s.u',
                                enforceMaxLength: true,
d1dd574b   Furkan   Done, in a way
1371
1372
                                disabled: true,
                                hideTrigger: true, 
7c236e57   Erdogan Furkan   #10576 - Pb with ...
1373
1374
1375
1376
1377
1378
1379
1380
1381
                                maxLength: 25,
                                labelWidth: 60,
                                labelAlign: 'left',
                                renderer: function (value) {
                                    if (value != null) {
                                        if (Ext.isDate(value)) {
                                            return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u');
                                        } else {
                                            return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u');
709a2d2e   Hacene SI HADJ MOHAND   il reste auto sta...
1382
                                        }
7c236e57   Erdogan Furkan   #10576 - Pb with ...
1383
1384
1385
1386
                                    } else {
                                        return value;
                                    }
                                },
7c236e57   Erdogan Furkan   #10576 - Pb with ...
1387
                            }, {
f3e15e49   Erdogan Furkan   #10700 - Done
1388
1389
1390
1391
1392
1393
                                fieldLabel: 'Stop Time',
                                name: 'surveyStop',
                                emptyText: 'YYYY/MM/DDThh:mm:ss.fff',
                                format: 'Y-m-d\\TH:i:s.u',
                                labelAlign: 'left',
                                enforceMaxLength: true,
d1dd574b   Furkan   Done, in a way
1394
1395
                                disabled: true,
                                hideTrigger: true, 
f3e15e49   Erdogan Furkan   #10700 - Done
1396
1397
1398
                                maxLength: 25,
                                labelWidth: 60,
                                align: 'left',
d1dd574b   Furkan   Done, in a way
1399
                            }]
a4acaf46   Hacene SI HADJ MOHAND   IHM progess
1400
1401
1402
1403
1404
1405
1406
1407
                        },
                        {
                            xtype: 'textarea',
                            name: 'contact',
                            fieldLabel: 'Contact',
                            height:50
                        },
                        {
d1dd574b   Furkan   Done, in a way
1408
1409
1410
1411
1412
1413
                            xtype:'panel',
                            resizable:true,
                            height: 165,
                            bodyStyle: {background: '#dfe8f6',padding: '1'},
                            border:false,
                            layout:'fit',
3c6689fd   Erdogan Furkan   TextArea has clic...
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
                            items:[
                                this.codeDescripton
                            ],
                            listeners:{
                                resize:function(a,b,height){
                                    if(this.codeDescripton.codeMirror)
                                        this.codeDescripton.codeMirror.setSize(null, height-20);
                                },
                                scope:this
                            },
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1424
1425
                        },
                        {
f3e15e49   Erdogan Furkan   #10700 - Done
1426
1427
1428
                            xtype: 'operationsTT',
                            margin:'5 0 0 0',
                            collapsible: true,
d1dd574b   Furkan   Done, in a way
1429
                            collapsed:false,
f3e15e49   Erdogan Furkan   #10700 - Done
1430
1431
1432
                            parent: this,
                            isCat:true,
                            id: 'operationCat'
d1dd574b   Furkan   Done, in a way
1433
1434
1435
1436
                        },
                    ],
                    
                }],
b39df83c   Benjamin Renard   Correction of a r...
1437

d1dd574b   Furkan   Done, in a way
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
                },
                {
                    xtype: 'form',
                    bodyStyle: {background: '#dfe8f6'},
                    //padding: '3',
                    flex: 2,
                    items: [this.TTGrid]
                }
            ],
            dockedItems: [
                {
                    xtype: 'toolbar',
                    dock: 'bottom',
                    ui: 'footer',
                    height: 35,
02e89fbe   Hacene SI HADJ MOHAND   rm_6903 ok
1453

d1dd574b   Furkan   Done, in a way
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
                    items: [
                        {
                            type: 'button',
                            text: 'Save',
                            width: 50,
                            scope: this,
                            handler: function ()
                            {
                                this.saveCatalog();
                            }
                        }, {
                            type: 'button',
                            text: 'Reset',
                            width: 50,
                            scope: this,
                            handler: function () {
                                var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
                                // 								module.createLinkedNode();
                                // 								module.createObject();
                                this.setObject(module.getLinkedNode().get('object'), true);
                            }
                        },
                        {
                            type: 'button',
                            text: 'Create New Catalog',
                            width: 120,
                            scope: this,
                            handler: function ()
                            {
                                var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1484

d1dd574b   Furkan   Done, in a way
1485
1486
                                if (!module)
                                    return;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1487

d1dd574b   Furkan   Done, in a way
1488
1489
                                module.createLinkedNode();
                                module.createObject();
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1490

d1dd574b   Furkan   Done, in a way
1491
                                var obj = module.linkedNode.get('object');
02e89fbe   Hacene SI HADJ MOHAND   rm_6903 ok
1492

d1dd574b   Furkan   Done, in a way
1493
                                var me = this;
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1494

d1dd574b   Furkan   Done, in a way
1495
1496
1497
1498
1499
                                Ext.Msg.prompt('Create catalog', 'Enter the number of columns:', function (btn, text) {
                                    if (btn == 'ok') {
                                        module.createLinkedNode();
                                        module.createObject();
                                        var obj = module.linkedNode.get('object');
02e89fbe   Hacene SI HADJ MOHAND   rm_6903 ok
1500

d1dd574b   Furkan   Done, in a way
1501
1502
1503
1504
                                        var nbParam = parseInt(text);
                                        if ((nbParam <= 0) || (nbParam > 100)) {
                                            nbParam = 1;
                                        }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1505

d1dd574b   Furkan   Done, in a way
1506
1507
                                        obj.set('nbParameters', nbParam);
                                        me.setObject(obj, true);
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1508
                                    }
d1dd574b   Furkan   Done, in a way
1509
1510
1511
                                }, this);

                            }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1512
                        },
d1dd574b   Furkan   Done, in a way
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
                    //statistical info
                {
                    xtype: 'toolbar',
                    dock: 'bottom',
                    ui: 'footer',
                    items: [{
                            xtype: 'button',
                            text: 'Statistical info',
                            scope: this,
                            //dock: 'bottom',
                            //ui: 'footer',
                            handler: function () {
                                this.fireEvent('info', 'catalogUI');
                            }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1527
1528
                        },
                        {
d1dd574b   Furkan   Done, in a way
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
                            type: 'button',
                            text: 'Visualize',
                            scope: this,
                            handler: function () {
                                var me = this;
                                myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
                                module.visualize(me.object);
                                });
                            }
                        },
                    ]
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1540
1541
                },
                {
d1dd574b   Furkan   Done, in a way
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
                    xtype: 'toolbar',
                    dock: 'bottom',
                    ui: 'footer',
                    items: [{
                            xtype: 'button',
                            text: 'Generate Time Table',
                            scope: this,
                            //dock: 'bottom',
                            //ui: 'footer',
                            handler: function () {
                                this.generateTT(this.object.get('id'));
                            }
                    }]
                },]
                },
                
                
                        
            ],
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
        });

        this.TTGrid.getSelectionModel().on('selectionchange', function (selModel, selections) {
            this.TTGrid.down('#delete').setDisabled(selections.length === 0);
        }, this);

        var myConf = {
            layout: 'border',
            items: [
                this.formPanel,
                {
                    xtype: 'panel',
                    region: 'south',
                    title: 'Information',
                    collapsible: true,
                    collapseMode: 'header',
                    height: 100,
                    autoHide: false,
                    bodyStyle: 'padding:5px',
                    iconCls: 'icon-information',
                    loader:
                            {
                                autoLoad: true,
                                url: helpDir + 'catalogHOWTO'
                            }
02e89fbe   Hacene SI HADJ MOHAND   rm_6903 ok
1586
                }
13f28b15   Hacene SI HADJ MOHAND   rm_7054 in progress
1587
1588
1589
1590
1591
            ],
            plugins: [{ptype: 'statisticalPlugin'}]
        };
        Ext.apply(this, Ext.apply(arguments, myConf));
    }
0fea5567   Benjamin Renard   First step for re...
1592
1593

});