Commit bad1e728ed2fa8c98ffc2f87a42c06fb11dc17af
1 parent
c7d1e939
Exists in
master
and in
100 other branches
Ok for time zone
Showing
2 changed files
with
719 additions
and
695 deletions
Show diff stats
js/app/views/CatalogUI.js
... | ... | @@ -161,6 +161,17 @@ Ext.define('amdaUI.CatalogUI', { |
161 | 161 | timeTabNode.editInModule(); |
162 | 162 | }); |
163 | 163 | }, |
164 | + // Convert UTC date to client local date | |
165 | + convertUTCDateToLocalDate: function (date) { | |
166 | + var newDate = new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000); | |
167 | + | |
168 | + var offset = date.getTimezoneOffset() / 60; | |
169 | + var hours = date.getHours(); | |
170 | + | |
171 | + newDate.setHours(hours - offset); | |
172 | + | |
173 | + return newDate; | |
174 | + }, | |
164 | 175 | onAfterInit: function (result, e) |
165 | 176 | { |
166 | 177 | var me = this; |
... | ... | @@ -699,7 +710,7 @@ Ext.define('amdaUI.CatalogUI', { |
699 | 710 | init: function (config) |
700 | 711 | { |
701 | 712 | this.object = config.object; |
702 | - | |
713 | + this.object.set('created', this.convertUTCDateToLocalDate(this.object.get('created'))); | |
703 | 714 | this.fieldName = new Ext.form.field.Text({ |
704 | 715 | fieldLabel: 'Name', |
705 | 716 | allowBlank: false, |
... | ... |
js/app/views/TimeTableUI.js
... | ... | @@ -9,63 +9,63 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | Ext.define('amdaUI.TimeTableUI', { |
12 | - extend: 'Ext.container.Container', | |
13 | - alias: 'widget.panelTimeTable', | |
14 | - | |
15 | - requires: [ | |
16 | - 'Ext.ux.grid.FiltersFeature', | |
17 | - 'Ext.ux.grid.filter.DateFilter', | |
18 | - 'Ext.ux.grid.filter.NumericFilter', | |
19 | - 'amdaUI.OperationsTT', | |
20 | - 'amdaUI.StatisticalPlug', | |
21 | - 'Ext.grid.plugin.BufferedRenderer' | |
22 | - ], | |
23 | - | |
24 | - statics: { | |
25 | - COL_TO_HIDE : 'colToHide' | |
26 | - }, | |
27 | - | |
28 | - status: null, | |
29 | - | |
30 | - constructor: function(config) { | |
31 | - this.init(config); | |
32 | - this.callParent(arguments); | |
33 | - // load object into view | |
34 | - this.loadObject(); | |
35 | - }, | |
36 | - | |
37 | - /** | |
38 | - * set the current editing object | |
39 | - * this method will be used on timetable edition when this win is already opened | |
40 | - */ | |
41 | - setObject : function (object) | |
42 | - { | |
43 | - // set object | |
44 | - this.object = object; | |
45 | - | |
46 | - // load object into view | |
47 | - this.loadObject(); | |
48 | - | |
49 | - // show the default duration column | |
50 | - this.TTGrid.headerCt.getGridColumns(); | |
51 | - | |
52 | - Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){ | |
53 | - // if item is the default duration column | |
54 | - if ( item.id == amdaUI.TimeTableUI.COL_TO_HIDE+'2' ) { | |
55 | - // show this column | |
56 | - item.show(); | |
57 | - } | |
58 | - }); | |
12 | + extend: 'Ext.container.Container', | |
13 | + alias: 'widget.panelTimeTable', | |
14 | + | |
15 | + requires: [ | |
16 | + 'Ext.ux.grid.FiltersFeature', | |
17 | + 'Ext.ux.grid.filter.DateFilter', | |
18 | + 'Ext.ux.grid.filter.NumericFilter', | |
19 | + 'amdaUI.OperationsTT', | |
20 | + 'amdaUI.StatisticalPlug', | |
21 | + 'Ext.grid.plugin.BufferedRenderer' | |
22 | + ], | |
23 | + | |
24 | + statics: { | |
25 | + COL_TO_HIDE: 'colToHide' | |
26 | + }, | |
27 | + | |
28 | + status: null, | |
29 | + | |
30 | + constructor: function (config) { | |
31 | + this.init(config); | |
32 | + this.callParent(arguments); | |
33 | + // load object into view | |
34 | + this.loadObject(); | |
35 | + }, | |
36 | + | |
37 | + /** | |
38 | + * set the current editing object | |
39 | + * this method will be used on timetable edition when this win is already opened | |
40 | + */ | |
41 | + setObject: function (object) | |
42 | + { | |
43 | + // set object | |
44 | + this.object = object; | |
45 | + | |
46 | + // load object into view | |
47 | + this.loadObject(); | |
48 | + | |
49 | + // show the default duration column | |
50 | + this.TTGrid.headerCt.getGridColumns(); | |
51 | + | |
52 | + Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function (item, index, all) { | |
53 | + // if item is the default duration column | |
54 | + if (item.id == amdaUI.TimeTableUI.COL_TO_HIDE + '2') { | |
55 | + // show this column | |
56 | + item.show(); | |
57 | + } | |
58 | + }); | |
59 | 59 | // fire the refresh event (to statistical plugin) |
60 | 60 | this.fireEvent("refresh"); |
61 | - // global event | |
62 | - myDesktopApp.EventManager.fireEvent("refresh"); | |
63 | - }, | |
64 | - | |
65 | - /** | |
66 | - * load object timetable into this view | |
67 | - */ | |
68 | - loadObject : function(){ | |
61 | + // global event | |
62 | + myDesktopApp.EventManager.fireEvent("refresh"); | |
63 | + }, | |
64 | + | |
65 | + /** | |
66 | + * load object timetable into this view | |
67 | + */ | |
68 | + loadObject: function () { | |
69 | 69 | // load object into form |
70 | 70 | this.formPanel.getForm().loadRecord(this.object); |
71 | 71 | |
... | ... | @@ -74,351 +74,366 @@ Ext.define('amdaUI.TimeTableUI', { |
74 | 74 | // |
75 | 75 | var me = this; |
76 | 76 | |
77 | - var onAfterInit = function(result, e) { | |
78 | - if (!result || !result.success) | |
79 | - { | |
80 | - if (result.message) | |
81 | - myDesktopApp.errorMsg(result.message); | |
82 | - else | |
83 | - myDesktopApp.errorMsg('Unknown error during cache initialisation'); | |
84 | - return; | |
85 | - } | |
77 | + var onAfterInit = function (result, e) { | |
78 | + if (!result || !result.success) | |
79 | + { | |
80 | + if (result.message) | |
81 | + myDesktopApp.errorMsg(result.message); | |
82 | + else | |
83 | + myDesktopApp.errorMsg('Unknown error during cache initialisation'); | |
84 | + return; | |
85 | + } | |
86 | 86 | |
87 | - me.TTGrid.getSelectionModel().deselectAll(); | |
87 | + me.TTGrid.getSelectionModel().deselectAll(); | |
88 | 88 | |
89 | - // clear filters | |
90 | - me.TTGrid.getStore().clearFilter(true); | |
91 | - me.TTGrid.filters.clearFilters(); | |
89 | + // clear filters | |
90 | + me.TTGrid.getStore().clearFilter(true); | |
91 | + me.TTGrid.filters.clearFilters(); | |
92 | 92 | |
93 | - //clear sort | |
94 | - me.TTGrid.getStore().sorters.clear(); | |
95 | - //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); | |
93 | + //clear sort | |
94 | + me.TTGrid.getStore().sorters.clear(); | |
95 | + //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); | |
96 | 96 | |
97 | - //set cache token to the Time Table object | |
98 | - me.object.set('cacheToken', result.token); | |
97 | + //set cache token to the Time Table object | |
98 | + me.object.set('cacheToken', result.token); | |
99 | 99 | |
100 | - me.TTGrid.getStore().load(); | |
100 | + me.TTGrid.getStore().load(); | |
101 | 101 | |
102 | - me.status = result.status; | |
102 | + me.status = result.status; | |
103 | 103 | |
104 | - //Statistical plugin | |
105 | - me.fireEvent("refresh"); | |
104 | + //Statistical plugin | |
105 | + me.fireEvent("refresh"); | |
106 | 106 | }; |
107 | 107 | |
108 | 108 | if (this.object.get('fromPlugin')) |
109 | 109 | { |
110 | - if (this.object.get('objFormat') && this.object.get('objFormat') != '') | |
111 | - { | |
112 | - //From uploaded file | |
113 | - AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), false, onAfterInit); | |
114 | - } | |
115 | - else | |
116 | - { | |
117 | - //From tmp object (ie Search result) | |
118 | - AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit); | |
119 | - } | |
120 | - } | |
121 | - else if(this.object.get('relatedCatalogId') != '') | |
110 | + if (this.object.get('objFormat') && this.object.get('objFormat') != '') | |
111 | + { | |
112 | + //From uploaded file | |
113 | + AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), false, onAfterInit); | |
114 | + } else | |
115 | + { | |
116 | + //From tmp object (ie Search result) | |
117 | + AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit); | |
118 | + } | |
119 | + } else if (this.object.get('relatedCatalogId') != '') | |
120 | + { | |
121 | + var pathern = this.object.get('relatedCatalogId').split('_')[0]; | |
122 | + catType = ''; | |
123 | + if (pathern == 'cat') | |
124 | + catType = ' catalog'; | |
125 | + if (pathern == 'sharedcatalog') | |
126 | + catType = 'sharedcatalog'; | |
127 | + AmdaAction.initObjectCacheFromCatalog(this.object.get('relatedCatalogId'), catType, onAfterInit); | |
128 | + } else | |
122 | 129 | { |
123 | - var pathern=this.object.get('relatedCatalogId').split('_')[0] ; | |
124 | - catType=''; | |
125 | - if(pathern=='cat') | |
126 | - catType=' catalog' ; | |
127 | - if(pathern=='sharedcatalog') | |
128 | - catType='sharedcatalog' ; | |
129 | - AmdaAction.initObjectCacheFromCatalog(this.object.get('relatedCatalogId'), catType, onAfterInit); | |
130 | + var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id).linkedNode.data.nodeType; | |
131 | + if (this.object.get('id') == '') | |
132 | + { | |
133 | + //Init empty cache | |
134 | + AmdaAction.initObjectCache(false, 0, onAfterInit); | |
135 | + } else | |
136 | + { | |
137 | + //From existing TT file | |
138 | + AmdaAction.initObjectCacheFromObject(this.object.get('id'), typeTT, onAfterInit); | |
139 | + } | |
130 | 140 | } |
131 | - else | |
141 | + }, | |
142 | + | |
143 | + /** | |
144 | + * update this.object from form | |
145 | + */ | |
146 | + updateObject: function () | |
147 | + { | |
148 | + this.updateCount(); | |
149 | + | |
150 | + // get the basic form | |
151 | + var basicForm = this.formPanel.getForm(); | |
152 | + var updateStatus = true; | |
153 | + | |
154 | + var fieldsWithoutName = basicForm.getFields().items; | |
155 | + Ext.Array.each(fieldsWithoutName, function (item, index, allItems) { | |
156 | + if (item !== this.fieldName) { | |
157 | + if (!item.isValid()) { | |
158 | + // set update isn't allowed | |
159 | + updateStatus = false; | |
160 | + } | |
161 | + } | |
162 | + }, this); | |
163 | + // if the update is allowed | |
164 | + if (updateStatus) { | |
165 | + /// real object update | |
166 | + // update TimeTable object with the content of form | |
167 | + basicForm.updateRecord(this.object); | |
168 | + } | |
169 | + // return the update status | |
170 | + return updateStatus; | |
171 | + }, | |
172 | + | |
173 | + updateCount: function () | |
174 | + { | |
175 | + this.object.set('nbIntervals', this.TTGrid.getStore().getTotalCount()); | |
176 | + this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); | |
177 | + }, | |
178 | + | |
179 | + /* | |
180 | + * save method called by Save button | |
181 | + */ | |
182 | + saveProcess: function (toRename, onAfterSave, notDisplayMsg) | |
183 | + { | |
184 | + var timeTableModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
185 | + | |
186 | + // if the name has been modified this is a creation | |
187 | + if (timeTableModule.contextNode && (timeTableModule.contextNode.data.id == 'sharedtimeTable-treeRootNode')) | |
188 | + { | |
189 | + timeTableModule.linkedNode = null; | |
190 | + timeTableModule.createLinkedNode(); | |
191 | + timeTableModule.createObject(this.object.getJsonValues()); | |
192 | + var ttobj = timeTableModule.linkedNode.get('object'); | |
193 | + // synchronisation of objects | |
194 | + this.object = ttobj; | |
195 | + timeTableModule.linkedNode.create(); | |
196 | + } else if (this.fclose()) /*TimeTable object has been modified*/ | |
132 | 197 | { |
133 | - var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id).linkedNode.data.nodeType; | |
134 | - if (this.object.get('id') == '') | |
135 | - { | |
136 | - //Init empty cache | |
137 | - AmdaAction.initObjectCache(false,0,onAfterInit); | |
138 | - } | |
139 | - else | |
140 | - { | |
141 | - //From existing TT file | |
142 | - AmdaAction.initObjectCacheFromObject(this.object.get('id'), typeTT, onAfterInit); | |
143 | - } | |
198 | + if (this.object.isModified('name') || this.object.get('fromPlugin')) | |
199 | + { | |
200 | + // if object already has an id : it's a 'rename' of an existing TimeTable | |
201 | + if (this.object.get('id')) | |
202 | + { | |
203 | + // the context Node is the parent node of current edited one | |
204 | + var contextNode = timeTableModule.linkedNode.parentNode; | |
205 | + // link a new node to the TimeTableModule | |
206 | + timeTableModule.createLinkedNode(); | |
207 | + // set the contextNode | |
208 | + timeTableModule.linkedNode.set('contextNode', contextNode); | |
209 | + // create a new object linked | |
210 | + timeTableModule.createObject(this.object.getJsonValues()); | |
211 | + | |
212 | + var ttobj = timeTableModule.linkedNode.get('object'); | |
213 | + // synchronisation of objects | |
214 | + this.object = ttobj; | |
215 | + | |
216 | + if (toRename) | |
217 | + timeTableModule.linkedNode.toRename = true; | |
218 | + } | |
219 | + timeTableModule.linkedNode.create({callback: function ($action) { | |
220 | + if (timeTableModule.linkedNode.get('object').get('fromPlugin')) | |
221 | + timeTableModule.linkedNode.get('object').set('fromPlugin', false); | |
222 | + timeTableModule.linkedNode.update({callback: function () { | |
223 | + if (onAfterSave) | |
224 | + onAfterSave(); | |
225 | + }, scope: this}); | |
226 | + }, | |
227 | + scope: this}); | |
228 | + } else { | |
229 | + //update | |
230 | + timeTableModule.linkedNode.update({callback: function () { | |
231 | + if (onAfterSave) | |
232 | + onAfterSave(); | |
233 | + }, scope: this}); | |
234 | + } | |
144 | 235 | } |
145 | - }, | |
146 | - | |
147 | - /** | |
148 | - * update this.object from form | |
149 | - */ | |
150 | - updateObject : function() | |
151 | - { | |
152 | - this.updateCount(); | |
153 | - | |
154 | - // get the basic form | |
155 | - var basicForm = this.formPanel.getForm(); | |
156 | - var updateStatus = true; | |
157 | - | |
158 | - var fieldsWithoutName = basicForm.getFields().items; | |
159 | - Ext.Array.each(fieldsWithoutName, function(item, index,allItems){ | |
160 | - if(item !== this.fieldName) { | |
161 | - if (!item.isValid()) { | |
162 | - // set update isn't allowed | |
163 | - updateStatus = false; | |
164 | - } | |
165 | - } | |
166 | - }, this); | |
167 | - // if the update is allowed | |
168 | - if (updateStatus) { | |
169 | - /// real object update | |
170 | - // update TimeTable object with the content of form | |
171 | - basicForm.updateRecord(this.object); | |
172 | - } | |
173 | - // return the update status | |
174 | - return updateStatus; | |
175 | - }, | |
176 | - | |
177 | - updateCount : function() | |
178 | - { | |
179 | - this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); | |
180 | - this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); | |
181 | - }, | |
182 | - | |
183 | - /* | |
184 | - * save method called by Save button | |
185 | - */ | |
186 | - saveProcess : function(toRename,onAfterSave, notDisplayMsg) | |
187 | - { | |
188 | - var timeTableModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
189 | - | |
190 | - // if the name has been modified this is a creation | |
191 | - if (timeTableModule.contextNode && (timeTableModule.contextNode.data.id == 'sharedtimeTable-treeRootNode')) | |
192 | - { | |
193 | - timeTableModule.linkedNode = null; | |
194 | - timeTableModule.createLinkedNode(); | |
195 | - timeTableModule.createObject(this.object.getJsonValues()); | |
196 | - var ttobj = timeTableModule.linkedNode.get('object'); | |
197 | - // synchronisation of objects | |
198 | - this.object = ttobj; | |
199 | - timeTableModule.linkedNode.create(); | |
200 | - } | |
201 | - else if (this.fclose()) /*TimeTable object has been modified*/ | |
202 | - { | |
203 | - if (this.object.isModified('name') || this.object.get('fromPlugin')) | |
204 | - { | |
205 | - // if object already has an id : it's a 'rename' of an existing TimeTable | |
206 | - if (this.object.get('id')) | |
207 | - { | |
208 | - // the context Node is the parent node of current edited one | |
209 | - var contextNode = timeTableModule.linkedNode.parentNode; | |
210 | - // link a new node to the TimeTableModule | |
211 | - timeTableModule.createLinkedNode(); | |
212 | - // set the contextNode | |
213 | - timeTableModule.linkedNode.set('contextNode',contextNode); | |
214 | - // create a new object linked | |
215 | - timeTableModule.createObject(this.object.getJsonValues()); | |
216 | - | |
217 | - var ttobj = timeTableModule.linkedNode.get('object'); | |
218 | - // synchronisation of objects | |
219 | - this.object = ttobj; | |
220 | - | |
221 | - if (toRename) timeTableModule.linkedNode.toRename = true; | |
222 | - } | |
223 | - timeTableModule.linkedNode.create({callback : function ($action) { | |
224 | - if (timeTableModule.linkedNode.get('object').get('fromPlugin')) | |
225 | - timeTableModule.linkedNode.get('object').set('fromPlugin',false); | |
226 | - timeTableModule.linkedNode.update({ callback : function() {if (onAfterSave) onAfterSave();}, scope : this});}, | |
227 | - scope : this}); | |
228 | - } else { | |
229 | - //update | |
230 | - timeTableModule.linkedNode.update({ callback : function() {if (onAfterSave) onAfterSave();}, scope : this}); | |
231 | - } | |
232 | - } | |
233 | - }, | |
234 | - | |
235 | - /** | |
236 | - * overwrite metod called by Save button | |
237 | - */ | |
238 | - overwriteProcess : function(btn) | |
239 | - { | |
240 | - if (btn == 'cancel') return; | |
241 | - | |
242 | - this.fieldName.clearInvalid(); | |
243 | - this.saveProcess(true); | |
244 | - | |
245 | - }, | |
246 | - | |
247 | - addInterval : function(start, stop) | |
248 | - { | |
249 | - var row = this.TTGrid.getStore().getTotalCount(); | |
250 | - var me = this; | |
251 | - this.TTGrid.getSelectionModel().deselectAll(); | |
252 | - AmdaAction.addCacheInterval({'start' : start, 'stop' : stop, 'index' : row},function (result, e) { | |
253 | - this.status = result.status; | |
254 | - if (!this.TTGrid.getStore().loading) { | |
255 | - this.TTGrid.getStore().reload({ | |
256 | - callback : function(records, options, success) { | |
257 | - me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { | |
258 | - me.TTGrid.getView().select(row); | |
259 | - }, me); | |
260 | - } | |
261 | - }); | |
262 | - } | |
263 | - }, this); | |
264 | - }, | |
265 | - generateCAT : function(id) | |
266 | - { | |
267 | - if(this.fclose()){ | |
268 | - Ext.Msg.confirm('Generate CAT', 'Current Time Table has been modified.\nDo you want to save it to include these changes in the generated Catalog ?' , | |
269 | - function (btn, text){ | |
270 | - if (btn == 'yes'){ | |
271 | - // mark this.closed as true before the call to close() as that will fire the beforeclose event again | |
272 | - if(this.object.get('id') ==""){ | |
273 | - // case of creation of catalog | |
274 | - this.saveTT(this.createCAT(this.object.get('id'))); | |
275 | - }else{ | |
276 | - // case existing catalog | |
277 | - this.saveProcess(false,this.createCAT(this.object.get('id'))); | |
278 | - } | |
279 | - return; | |
280 | - } | |
281 | - }, this); | |
282 | - | |
283 | - }else{ | |
284 | - this.createCAT(this.object.get('id')); | |
285 | - return; | |
286 | - } | |
287 | - }, | |
288 | - createCAT : function(id) | |
289 | - { | |
290 | - Ext.Msg.prompt('Create catalog', 'Enter the number of columns:', function(btn, text){ | |
291 | - if (btn == 'ok'){ | |
292 | - var catObj=Ext.create('amdaModel.Catalog'); | |
293 | - var catNode=Ext.create('amdaModel.CatalogNode',{leaf : true}); | |
294 | - catObj.set('relatedTimeTableId', id); | |
295 | - creatDate=new Date(this.object.get('created')); | |
296 | - date=Ext.Date.format(creatDate,'Y-m-d\\TH:i:s'); | |
297 | - descr='Generated by CDPP/Amda Time Table Module \n'+ 'From Time Table: '+this.object.get('name')+'\nOn: '+date+'\n'; | |
298 | - catObj.set('description', descr+this.object.get('description')); | |
299 | - var nbParam = parseInt(text); | |
300 | - if ((nbParam <= 0) || (nbParam > 100)) { | |
301 | - nbParam = 1; | |
302 | - } | |
303 | - catObj.set('nbParameters', nbParam); | |
304 | - catNode.set('object',catObj); | |
305 | - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
306 | - var catRootNode = explorerTree.getRootNode().findChild('id', 'catalog-treeRootNode', true); | |
307 | - amdaModel.InteractiveNode.preloadNodes(catRootNode.getRootNode(), | |
308 | - function() | |
309 | - { | |
310 | - // edit newNode into Parameter Module with node as contextNode | |
311 | - catNode.editInModule(); | |
312 | - }); | |
313 | - } | |
314 | - }, this); | |
315 | - }, | |
316 | - saveTT : function(OnAfterSave) | |
317 | - { | |
318 | - if (this.updateObject()){ | |
319 | - var basicForm = this.formPanel.getForm(); | |
320 | - // if there's at least one record in the store of TTGrid | |
321 | - if (this.TTGrid.getStore().getTotalCount()>0) { | |
322 | - // update TimeTable object which the content of form | |
323 | - basicForm.updateRecord(this.object); | |
324 | - | |
325 | - var me = this; | |
326 | - this.checkIntervalsStatusForSave(function () { | |
327 | - //Name validation | |
328 | - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
329 | - if (!ttModule) | |
330 | - return; | |
331 | - ttModule.linkedNode.isValidName(me.fieldName.getValue(), function (res) { | |
332 | - if (!res) | |
333 | - { | |
334 | - me.fieldName.validFlag = 'Error during object validation'; | |
335 | - myDesktopApp.errorMsg(me.fieldName.validFlag); | |
336 | - me.fieldName.validate(); | |
337 | - return; | |
338 | - } | |
339 | - | |
340 | - if (!res.valid) | |
341 | - { | |
342 | - if (res.error) | |
343 | - { | |
344 | - if (res.error.search('subtree') != -1) { | |
345 | - Ext.MessageBox.show({title:'Warning', | |
346 | - msg: res.error+'<br/>Do you want to overwrite it?', | |
347 | - width: 300, | |
348 | - buttons: Ext.MessageBox.OKCANCEL, | |
349 | - fn : me.overwriteProcess, | |
350 | - icon: Ext.MessageBox.WARNING, | |
351 | - scope : me | |
352 | - }); | |
353 | - me.fieldName.validFlag = true; | |
354 | - } | |
355 | - else | |
356 | - me.fieldName.validFlag = res.error; | |
357 | - } | |
358 | - else | |
359 | - { | |
360 | - me.fieldName.validFlag = 'Invalid object name'; | |
361 | - myDesktopApp.errorMsg(me.fieldName.validFlag); | |
362 | - } | |
363 | - me.fieldName.validate(); | |
364 | - return; | |
365 | - } | |
366 | - | |
367 | - me.fieldName.validFlag = true; | |
368 | - me.fieldName.validate(); | |
369 | - me.saveProcess(false); | |
370 | - }); | |
371 | - }); | |
372 | - } else { | |
373 | - // warning: | |
374 | - Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval'); | |
375 | - } | |
376 | - } | |
377 | - }, | |
378 | - | |
379 | - init : function(config) | |
380 | - { | |
381 | - this.object = config.object; | |
382 | - | |
383 | - this.fieldName = new Ext.form.field.Text({ | |
384 | - fieldLabel: 'Name*', | |
385 | - allowBlank : false, | |
386 | - stripCharsRe: /(^\s+|\s+$)/g, | |
387 | - emptyText: 'Please no spaces!', | |
388 | - name: 'name', | |
389 | - anchor: '100%', | |
390 | - validateOnChange: false, | |
391 | - validateOnBlur: false, | |
392 | - validFlag: false, | |
393 | - validator : function() { | |
394 | - return this.validFlag; | |
395 | - } | |
396 | - }); | |
397 | - | |
398 | - this.formPanel = new Ext.form.Panel({ | |
399 | - bodyStyle: {background : '#dfe8f6'}, | |
236 | + }, | |
237 | + | |
238 | + /** | |
239 | + * overwrite metod called by Save button | |
240 | + */ | |
241 | + overwriteProcess: function (btn) | |
242 | + { | |
243 | + if (btn == 'cancel') | |
244 | + return; | |
245 | + | |
246 | + this.fieldName.clearInvalid(); | |
247 | + this.saveProcess(true); | |
248 | + | |
249 | + }, | |
250 | + | |
251 | + addInterval: function (start, stop) | |
252 | + { | |
253 | + var row = this.TTGrid.getStore().getTotalCount(); | |
254 | + var me = this; | |
255 | + this.TTGrid.getSelectionModel().deselectAll(); | |
256 | + AmdaAction.addCacheInterval({'start': start, 'stop': stop, 'index': row}, function (result, e) { | |
257 | + this.status = result.status; | |
258 | + if (!this.TTGrid.getStore().loading) { | |
259 | + this.TTGrid.getStore().reload({ | |
260 | + callback: function (records, options, success) { | |
261 | + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function () { | |
262 | + me.TTGrid.getView().select(row); | |
263 | + }, me); | |
264 | + } | |
265 | + }); | |
266 | + } | |
267 | + }, this); | |
268 | + }, | |
269 | + generateCAT: function (id) | |
270 | + { | |
271 | + if (this.fclose()) { | |
272 | + Ext.Msg.confirm('Generate CAT', 'Current Time Table has been modified.\nDo you want to save it to include these changes in the generated Catalog ?', | |
273 | + function (btn, text) { | |
274 | + if (btn == 'yes') { | |
275 | + // mark this.closed as true before the call to close() as that will fire the beforeclose event again | |
276 | + if (this.object.get('id') == "") { | |
277 | + // case of creation of catalog | |
278 | + this.saveTT(this.createCAT(this.object.get('id'))); | |
279 | + } else { | |
280 | + // case existing catalog | |
281 | + this.saveProcess(false, this.createCAT(this.object.get('id'))); | |
282 | + } | |
283 | + return; | |
284 | + } | |
285 | + }, this); | |
286 | + | |
287 | + } else { | |
288 | + this.createCAT(this.object.get('id')); | |
289 | + return; | |
290 | + } | |
291 | + }, | |
292 | + createCAT: function (id) | |
293 | + { | |
294 | + Ext.Msg.prompt('Create catalog', 'Enter the number of columns:', function (btn, text) { | |
295 | + if (btn == 'ok') { | |
296 | + var catObj = Ext.create('amdaModel.Catalog'); | |
297 | + var catNode = Ext.create('amdaModel.CatalogNode', {leaf: true}); | |
298 | + catObj.set('relatedTimeTableId', id); | |
299 | + creatDate = new Date(this.object.get('created')); | |
300 | + date = Ext.Date.format(creatDate, 'Y-m-d\\TH:i:s'); | |
301 | + descr = 'Generated by CDPP/Amda Time Table Module \n' + 'From Time Table: ' + this.object.get('name') + ' which was generated on: ' + date + '\n'; | |
302 | + catObj.set('description', descr + this.object.get('description')); | |
303 | + var nbParam = parseInt(text); | |
304 | + if ((nbParam <= 0) || (nbParam > 100)) { | |
305 | + nbParam = 1; | |
306 | + } | |
307 | + catObj.set('nbParameters', nbParam); | |
308 | + catNode.set('object', catObj); | |
309 | + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
310 | + var catRootNode = explorerTree.getRootNode().findChild('id', 'catalog-treeRootNode', true); | |
311 | + amdaModel.InteractiveNode.preloadNodes(catRootNode.getRootNode(), | |
312 | + function () | |
313 | + { | |
314 | + // edit newNode into Parameter Module with node as contextNode | |
315 | + catNode.editInModule(); | |
316 | + }); | |
317 | + } | |
318 | + }, this); | |
319 | + }, | |
320 | + saveTT: function (OnAfterSave) | |
321 | + { | |
322 | + if (this.updateObject()) { | |
323 | + var basicForm = this.formPanel.getForm(); | |
324 | + // if there's at least one record in the store of TTGrid | |
325 | + if (this.TTGrid.getStore().getTotalCount() > 0) { | |
326 | + // update TimeTable object which the content of form | |
327 | + basicForm.updateRecord(this.object); | |
328 | + | |
329 | + var me = this; | |
330 | + this.checkIntervalsStatusForSave(function () { | |
331 | + //Name validation | |
332 | + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
333 | + if (!ttModule) | |
334 | + return; | |
335 | + ttModule.linkedNode.isValidName(me.fieldName.getValue(), function (res) { | |
336 | + if (!res) | |
337 | + { | |
338 | + me.fieldName.validFlag = 'Error during object validation'; | |
339 | + myDesktopApp.errorMsg(me.fieldName.validFlag); | |
340 | + me.fieldName.validate(); | |
341 | + return; | |
342 | + } | |
343 | + | |
344 | + if (!res.valid) | |
345 | + { | |
346 | + if (res.error) | |
347 | + { | |
348 | + if (res.error.search('subtree') != -1) { | |
349 | + Ext.MessageBox.show({title: 'Warning', | |
350 | + msg: res.error + '<br/>Do you want to overwrite it?', | |
351 | + width: 300, | |
352 | + buttons: Ext.MessageBox.OKCANCEL, | |
353 | + fn: me.overwriteProcess, | |
354 | + icon: Ext.MessageBox.WARNING, | |
355 | + scope: me | |
356 | + }); | |
357 | + me.fieldName.validFlag = true; | |
358 | + } else | |
359 | + me.fieldName.validFlag = res.error; | |
360 | + } else | |
361 | + { | |
362 | + me.fieldName.validFlag = 'Invalid object name'; | |
363 | + myDesktopApp.errorMsg(me.fieldName.validFlag); | |
364 | + } | |
365 | + me.fieldName.validate(); | |
366 | + return; | |
367 | + } | |
368 | + | |
369 | + me.fieldName.validFlag = true; | |
370 | + me.fieldName.validate(); | |
371 | + me.saveProcess(false); | |
372 | + }); | |
373 | + }); | |
374 | + } else { | |
375 | + // warning: | |
376 | + Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval'); | |
377 | + } | |
378 | + } | |
379 | + }, | |
380 | + | |
381 | + // Convert UTC date to client local date | |
382 | + convertUTCDateToLocalDate: function (date) { | |
383 | + var newDate = new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000); | |
384 | + | |
385 | + var offset = date.getTimezoneOffset() / 60; | |
386 | + var hours = date.getHours(); | |
387 | + | |
388 | + newDate.setHours(hours - offset); | |
389 | + | |
390 | + return newDate; | |
391 | + }, | |
392 | + | |
393 | + init: function (config) | |
394 | + { | |
395 | + this.object = config.object; | |
396 | + this.object.set('created', this.convertUTCDateToLocalDate(this.object.get('created'))); | |
397 | + | |
398 | + this.fieldName = new Ext.form.field.Text({ | |
399 | + fieldLabel: 'Name*', | |
400 | + allowBlank: false, | |
401 | + stripCharsRe: /(^\s+|\s+$)/g, | |
402 | + emptyText: 'Please no spaces!', | |
403 | + name: 'name', | |
404 | + anchor: '100%', | |
405 | + validateOnChange: false, | |
406 | + validateOnBlur: false, | |
407 | + validFlag: false, | |
408 | + validator: function () { | |
409 | + return this.validFlag; | |
410 | + } | |
411 | + }); | |
412 | + | |
413 | + this.formPanel = new Ext.form.Panel({ | |
414 | + bodyStyle: {background: '#dfe8f6'}, | |
400 | 415 | id: 'formTimeTable', |
401 | 416 | flex: 4, |
402 | - model : 'amdaModel.TimeTable', | |
403 | - trackResetOnLoad : true, // reset to the last loaded record | |
404 | - border : false, | |
405 | - fieldDefaults: { labelWidth: 80 }, | |
417 | + model: 'amdaModel.TimeTable', | |
418 | + trackResetOnLoad: true, // reset to the last loaded record | |
419 | + border: false, | |
420 | + fieldDefaults: {labelWidth: 80}, | |
406 | 421 | items: [ |
407 | 422 | this.fieldName, |
408 | 423 | { |
409 | 424 | xtype: 'fieldcontainer', |
410 | 425 | layout: 'hbox', |
411 | - fieldLabel:'Creation date', | |
426 | + fieldLabel: 'Creation date', | |
412 | 427 | items: [ |
413 | 428 | { |
414 | - xtype:'datefield', width: 180, | |
429 | + xtype: 'datefield', width: 180, | |
415 | 430 | name: 'created', disabled: true, |
416 | 431 | hideTrigger: true, format: 'Y/m/d H:i:s' |
417 | 432 | }, |
418 | - { xtype:'component', width: 20 }, | |
419 | - { xtype:'displayfield', value: 'Intervals:', width: 50 }, | |
420 | - { xtype:'component', width: 8 }, | |
421 | - { xtype:'textfield', name: 'nbIntervals', disabled: true, width: 70 } | |
433 | + {xtype: 'component', width: 20}, | |
434 | + {xtype: 'displayfield', value: 'Intervals:', width: 50}, | |
435 | + {xtype: 'component', width: 8}, | |
436 | + {xtype: 'textfield', name: 'nbIntervals', disabled: true, width: 70} | |
422 | 437 | ] |
423 | 438 | }, |
424 | 439 | { |
... | ... | @@ -437,154 +452,152 @@ Ext.define('amdaUI.TimeTableUI', { |
437 | 452 | |
438 | 453 | }); |
439 | 454 | |
440 | - var store = Ext.create('Ext.data.Store', { | |
441 | - model: 'amdaModel.Interval', | |
442 | - autoDestroy: false, | |
443 | - pageSize : 200, | |
444 | - buffered : true, | |
445 | - autoLoad: true, | |
446 | - purgePageCount: 0, | |
447 | - remoteSort: true, | |
448 | - listeners: { | |
449 | - load: function(store,records) { | |
450 | - | |
451 | - // alert('nb of records in store:'+records.length ); | |
452 | - myDesktopApp.EventManager.fireEvent('refresh'); | |
453 | - this.TTGrid.getView().refresh(); | |
454 | - this.TTGrid.getSelectionModel().refresh(); | |
455 | - this.updateCount(); | |
456 | - //Statistical plugin | |
457 | - this.fireEvent("refresh"); | |
458 | - }, | |
459 | - prefetch : function(store, records, successful, operation, eOpts) { | |
460 | - if (operation && (operation.action == 'read')) | |
461 | - { | |
462 | - if (operation.response && operation.response.result && operation.response.result.success) | |
463 | - this.status = operation.response.result.status; | |
464 | - } | |
465 | - }, | |
466 | - remove: function(store) { | |
467 | - this.updateCount(); | |
468 | - //Statistical plugin | |
469 | - this.fireEvent("refresh"); | |
470 | - }, | |
471 | - add: function(store) { | |
472 | - this.updateCount(); | |
473 | - //Statistical plugin | |
474 | - this.fireEvent("refresh"); | |
475 | - }, | |
476 | - datachanged: function(store){ | |
477 | - this.updateCount(); | |
478 | - //Statistical plugin | |
479 | - this.fireEvent("refresh"); | |
480 | - }, | |
481 | - scope : this | |
482 | - } | |
483 | - }); | |
484 | - | |
485 | - var filters = { | |
486 | - ftype: 'filters', | |
487 | - encode: true, // json encode the filter query | |
488 | - local: false, // defaults to false (remote filte | |
489 | - filters: [ | |
490 | - { type: 'numeric', dataIndex: 'durationHour'}, | |
491 | - { type: 'numeric', dataIndex: 'durationMin'}, | |
492 | - { type: 'numeric', dataIndex: 'durationSec'}, | |
493 | - { type: 'date', dataIndex: 'start', dateFormat: 'Y-m-d'}, | |
494 | - { type: 'date', dataIndex: 'stop', dateFormat: 'Y-m-d' } | |
455 | + var store = Ext.create('Ext.data.Store', { | |
456 | + model: 'amdaModel.Interval', | |
457 | + autoDestroy: false, | |
458 | + pageSize: 200, | |
459 | + buffered: true, | |
460 | + autoLoad: true, | |
461 | + purgePageCount: 0, | |
462 | + remoteSort: true, | |
463 | + listeners: { | |
464 | + load: function (store, records) { | |
465 | + | |
466 | + // alert('nb of records in store:'+records.length ); | |
467 | + myDesktopApp.EventManager.fireEvent('refresh'); | |
468 | + this.TTGrid.getView().refresh(); | |
469 | + this.TTGrid.getSelectionModel().refresh(); | |
470 | + this.updateCount(); | |
471 | + //Statistical plugin | |
472 | + this.fireEvent("refresh"); | |
473 | + }, | |
474 | + prefetch: function (store, records, successful, operation, eOpts) { | |
475 | + if (operation && (operation.action == 'read')) | |
476 | + { | |
477 | + if (operation.response && operation.response.result && operation.response.result.success) | |
478 | + this.status = operation.response.result.status; | |
479 | + } | |
480 | + }, | |
481 | + remove: function (store) { | |
482 | + this.updateCount(); | |
483 | + //Statistical plugin | |
484 | + this.fireEvent("refresh"); | |
485 | + }, | |
486 | + add: function (store) { | |
487 | + this.updateCount(); | |
488 | + //Statistical plugin | |
489 | + this.fireEvent("refresh"); | |
490 | + }, | |
491 | + datachanged: function (store) { | |
492 | + this.updateCount(); | |
493 | + //Statistical plugin | |
494 | + this.fireEvent("refresh"); | |
495 | + }, | |
496 | + scope: this | |
497 | + } | |
498 | + }); | |
499 | + | |
500 | + var filters = { | |
501 | + ftype: 'filters', | |
502 | + encode: true, // json encode the filter query | |
503 | + local: false, // defaults to false (remote filte | |
504 | + filters: [ | |
505 | + {type: 'numeric', dataIndex: 'durationHour'}, | |
506 | + {type: 'numeric', dataIndex: 'durationMin'}, | |
507 | + {type: 'numeric', dataIndex: 'durationSec'}, | |
508 | + {type: 'date', dataIndex: 'start', dateFormat: 'Y-m-d'}, | |
509 | + {type: 'date', dataIndex: 'stop', dateFormat: 'Y-m-d'} | |
495 | 510 | ] |
496 | - }; | |
497 | - | |
498 | - var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{ | |
499 | - onEditComplete : function(ed, value, startValue) { | |
500 | - var me = this, | |
501 | - activeColumn = me.getActiveColumn(), | |
502 | - context = me.context, | |
503 | - record; | |
504 | - | |
505 | - if (activeColumn) { | |
506 | - record = context.record; | |
507 | - | |
508 | - me.setActiveEditor(null); | |
509 | - me.setActiveColumn(null); | |
510 | - me.setActiveRecord(null); | |
511 | - | |
512 | - context.value = value; | |
513 | - if (!me.validateEdit()) { | |
514 | - me.editing = false; | |
515 | - return; | |
516 | - } | |
517 | - | |
518 | - // Only update the record if the new value is different than the | |
519 | - // startValue. When the view refreshes its el will gain focus | |
520 | - if (!record.isEqual(value, startValue)) { | |
521 | - var obj = { | |
522 | - 'cacheId' : record.get('cacheId'), | |
523 | - 'isCatalog' : false, | |
524 | - 'data' : {} | |
525 | - }; | |
526 | - obj['data'][activeColumn.dataIndex] = value; | |
527 | - | |
528 | - //context.grid.getSelectionModel().deselectAll(); | |
529 | - //Interval is modified on the server side | |
530 | - me.editing = true; | |
531 | - | |
532 | - AmdaAction.modifyCacheInterval(obj, function (result, e) { | |
533 | - | |
534 | - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
535 | - if (ttModule) | |
536 | - ttModule.getUiContent().status = result.status; | |
537 | - if (!context.store.loading) { | |
538 | - context.grid.getSelectionModel().deselectAll(); | |
539 | - context.store.reload({ | |
540 | - callback : function(records, options, success) { | |
541 | - context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function() { | |
542 | - me.fireEvent('edit', me, context); | |
543 | - me.editing = false; | |
544 | - }, me); | |
545 | - } | |
546 | - }); | |
547 | - } | |
548 | - else { | |
549 | - me.editing = false; | |
550 | - } | |
551 | - }, this); | |
552 | - } | |
553 | - else | |
554 | - me.editing = false; | |
555 | - } | |
556 | - } | |
557 | - | |
558 | - }); | |
559 | - | |
560 | - this.TTGrid = Ext.create('Ext.grid.Panel', { | |
561 | - store : store, | |
562 | - features: [filters], | |
563 | - columnLines: true, | |
564 | - selModel: {pruneRemoved: false}, | |
565 | - columns: [ | |
511 | + }; | |
512 | + | |
513 | + var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { | |
514 | + onEditComplete: function (ed, value, startValue) { | |
515 | + var me = this, | |
516 | + activeColumn = me.getActiveColumn(), | |
517 | + context = me.context, | |
518 | + record; | |
519 | + | |
520 | + if (activeColumn) { | |
521 | + record = context.record; | |
522 | + | |
523 | + me.setActiveEditor(null); | |
524 | + me.setActiveColumn(null); | |
525 | + me.setActiveRecord(null); | |
526 | + | |
527 | + context.value = value; | |
528 | + if (!me.validateEdit()) { | |
529 | + me.editing = false; | |
530 | + return; | |
531 | + } | |
532 | + | |
533 | + // Only update the record if the new value is different than the | |
534 | + // startValue. When the view refreshes its el will gain focus | |
535 | + if (!record.isEqual(value, startValue)) { | |
536 | + var obj = { | |
537 | + 'cacheId': record.get('cacheId'), | |
538 | + 'isCatalog': false, | |
539 | + 'data': {} | |
540 | + }; | |
541 | + obj['data'][activeColumn.dataIndex] = value; | |
542 | + | |
543 | + //context.grid.getSelectionModel().deselectAll(); | |
544 | + //Interval is modified on the server side | |
545 | + me.editing = true; | |
546 | + | |
547 | + AmdaAction.modifyCacheInterval(obj, function (result, e) { | |
548 | + | |
549 | + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
550 | + if (ttModule) | |
551 | + ttModule.getUiContent().status = result.status; | |
552 | + if (!context.store.loading) { | |
553 | + context.grid.getSelectionModel().deselectAll(); | |
554 | + context.store.reload({ | |
555 | + callback: function (records, options, success) { | |
556 | + context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function () { | |
557 | + me.fireEvent('edit', me, context); | |
558 | + me.editing = false; | |
559 | + }, me); | |
560 | + } | |
561 | + }); | |
562 | + } else { | |
563 | + me.editing = false; | |
564 | + } | |
565 | + }, this); | |
566 | + } else | |
567 | + me.editing = false; | |
568 | + } | |
569 | + } | |
570 | + | |
571 | + }); | |
572 | + | |
573 | + this.TTGrid = Ext.create('Ext.grid.Panel', { | |
574 | + store: store, | |
575 | + features: [filters], | |
576 | + columnLines: true, | |
577 | + selModel: {pruneRemoved: false}, | |
578 | + columns: [ | |
566 | 579 | { |
567 | - xtype: 'rownumberer', | |
568 | - width: 50, | |
569 | - renderer: function(value, metaData, record, row, col, store, gridView){ | |
570 | - var msg = record.index + 1; | |
571 | - if (record.get('isNew') || record.get('isModified')) | |
572 | - { | |
573 | - msg += ' *'; | |
574 | - metaData.style = 'font-weight: bold' | |
575 | - } | |
576 | - return msg; | |
580 | + xtype: 'rownumberer', | |
581 | + width: 50, | |
582 | + renderer: function (value, metaData, record, row, col, store, gridView) { | |
583 | + var msg = record.index + 1; | |
584 | + if (record.get('isNew') || record.get('isModified')) | |
585 | + { | |
586 | + msg += ' *'; | |
587 | + metaData.style = 'font-weight: bold' | |
588 | + } | |
589 | + return msg; | |
577 | 590 | } |
578 | 591 | }, |
579 | 592 | { |
580 | - header: 'Start Time', dataIndex: 'start', width: 120, | |
581 | - editor: { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}, | |
582 | - renderer: function(value){ | |
593 | + header: 'Start Time', dataIndex: 'start', width: 120, | |
594 | + editor: {xtype: 'datefield', allowBlank: false, hideTrigger: true, format: 'Y-m-d\\TH:i:s'}, | |
595 | + renderer: function (value) { | |
583 | 596 | if (value != null) { |
584 | - if(Ext.isDate(value)){ | |
597 | + if (Ext.isDate(value)) { | |
585 | 598 | return Ext.Date.format(value, 'Y-m-d\\TH:i:s'); |
586 | 599 | } else { |
587 | - return Ext.Date.format(new Date (value), 'Y-m-d\TH:i:s'); | |
600 | + return Ext.Date.format(new Date(value), 'Y-m-d\TH:i:s'); | |
588 | 601 | } |
589 | 602 | } else { |
590 | 603 | return value; |
... | ... | @@ -593,13 +606,13 @@ Ext.define('amdaUI.TimeTableUI', { |
593 | 606 | }, |
594 | 607 | { |
595 | 608 | header: 'Stop Time', dataIndex: 'stop', width: 120, |
596 | - editor: { xtype: 'datefield', allowBlank: false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}, | |
597 | - renderer: function(value) { | |
609 | + editor: {xtype: 'datefield', allowBlank: false, hideTrigger: true, format: 'Y-m-d\\TH:i:s'}, | |
610 | + renderer: function (value) { | |
598 | 611 | if (value != null) { |
599 | - if(Ext.isDate(value)){ | |
612 | + if (Ext.isDate(value)) { | |
600 | 613 | return Ext.Date.format(value, 'Y-m-d\\TH:i:s'); |
601 | 614 | } else { |
602 | - return Ext.Date.format(new Date (value), 'Y-m-d\TH:i:s'); | |
615 | + return Ext.Date.format(new Date(value), 'Y-m-d\TH:i:s'); | |
603 | 616 | } |
604 | 617 | } else { |
605 | 618 | return value; |
... | ... | @@ -607,19 +620,19 @@ Ext.define('amdaUI.TimeTableUI', { |
607 | 620 | } |
608 | 621 | }, |
609 | 622 | { |
610 | - header: 'Duration (hour)', width: 120, dataIndex: 'durationHour', | |
611 | - id: amdaUI.TimeTableUI.COL_TO_HIDE+'1', | |
623 | + header: 'Duration (hour)', width: 120, dataIndex: 'durationHour', | |
624 | + id: amdaUI.TimeTableUI.COL_TO_HIDE + '1', | |
612 | 625 | hidden: true, |
613 | - renderer: function(value) { | |
614 | - return Ext.util.Format.number(value,'0.00'); | |
626 | + renderer: function (value) { | |
627 | + return Ext.util.Format.number(value, '0.00'); | |
615 | 628 | }, |
616 | 629 | listeners: { |
617 | - beforeshow : function(){ | |
618 | - Ext.Array.each(this.ownerCt.getGridColumns(), function(item,index,all){ | |
630 | + beforeshow: function () { | |
631 | + Ext.Array.each(this.ownerCt.getGridColumns(), function (item, index, all) { | |
619 | 632 | // if item is a column to hide automatically |
620 | - if ( Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE ) { | |
633 | + if (Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE) { | |
621 | 634 | // if item isn't the column which is being declared and is not hidden |
622 | - if ( item.id != amdaUI.TimeTableUI.COL_TO_HIDE+'1' && !item.isHidden() ){ | |
635 | + if (item.id != amdaUI.TimeTableUI.COL_TO_HIDE + '1' && !item.isHidden()) { | |
623 | 636 | // hide this column |
624 | 637 | item.hide(); |
625 | 638 | } |
... | ... | @@ -629,18 +642,18 @@ Ext.define('amdaUI.TimeTableUI', { |
629 | 642 | } |
630 | 643 | }, |
631 | 644 | { |
632 | - header: 'Duration (min)', width: 120, dataIndex: 'durationMin', | |
633 | - id: amdaUI.TimeTableUI.COL_TO_HIDE+'2', | |
634 | - renderer: function(value) { | |
635 | - return Ext.util.Format.number(value,'0.00'); | |
636 | - }, | |
645 | + header: 'Duration (min)', width: 120, dataIndex: 'durationMin', | |
646 | + id: amdaUI.TimeTableUI.COL_TO_HIDE + '2', | |
647 | + renderer: function (value) { | |
648 | + return Ext.util.Format.number(value, '0.00'); | |
649 | + }, | |
637 | 650 | listeners: { |
638 | - beforeshow : function(){ | |
639 | - Ext.Array.each(this.ownerCt.getGridColumns(), function(item,index,all){ | |
651 | + beforeshow: function () { | |
652 | + Ext.Array.each(this.ownerCt.getGridColumns(), function (item, index, all) { | |
640 | 653 | // if item is a column to hide automatically |
641 | - if ( Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE ) { | |
654 | + if (Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE) { | |
642 | 655 | // if item isn't the column which is being declared and is not hidden |
643 | - if ( item.id != amdaUI.TimeTableUI.COL_TO_HIDE+'2' && !item.isHidden() ){ | |
656 | + if (item.id != amdaUI.TimeTableUI.COL_TO_HIDE + '2' && !item.isHidden()) { | |
644 | 657 | // hide this column |
645 | 658 | item.hide(); |
646 | 659 | } |
... | ... | @@ -650,19 +663,19 @@ Ext.define('amdaUI.TimeTableUI', { |
650 | 663 | } |
651 | 664 | }, |
652 | 665 | { |
653 | - header: 'Duration (sec)', width: 120, dataIndex: 'durationSec', | |
654 | - id: amdaUI.TimeTableUI.COL_TO_HIDE+'3', | |
666 | + header: 'Duration (sec)', width: 120, dataIndex: 'durationSec', | |
667 | + id: amdaUI.TimeTableUI.COL_TO_HIDE + '3', | |
655 | 668 | hidden: true, |
656 | - renderer: function(value) { | |
657 | - return Ext.util.Format.number(value,'0.00'); | |
669 | + renderer: function (value) { | |
670 | + return Ext.util.Format.number(value, '0.00'); | |
658 | 671 | }, |
659 | 672 | listeners: { |
660 | - beforeshow : function(){ | |
661 | - Ext.Array.each(this.ownerCt.getGridColumns(), function(item,index,all){ | |
673 | + beforeshow: function () { | |
674 | + Ext.Array.each(this.ownerCt.getGridColumns(), function (item, index, all) { | |
662 | 675 | // if item is a column to hide automatically |
663 | - if ( Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE ) { | |
676 | + if (Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE) { | |
664 | 677 | // if item isn't the column which is being declared and is not hidden |
665 | - if ( item.id != amdaUI.TimeTableUI.COL_TO_HIDE+'3' && !item.isHidden() ){ | |
678 | + if (item.id != amdaUI.TimeTableUI.COL_TO_HIDE + '3' && !item.isHidden()) { | |
666 | 679 | // hide this column |
667 | 680 | item.hide(); |
668 | 681 | } |
... | ... | @@ -674,92 +687,92 @@ Ext.define('amdaUI.TimeTableUI', { |
674 | 687 | ], |
675 | 688 | frame: true, |
676 | 689 | dockedItems: [{ |
677 | - xtype: 'toolbar', | |
678 | - items: [{ | |
679 | - iconCls: 'icon-add', | |
680 | - scope: this, | |
681 | - handler: function(){ | |
682 | - cellEditing.cancelEdit(); | |
683 | - | |
684 | - var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
685 | - var row = 0; | |
686 | - if (selection) | |
687 | - row = store.indexOf(selection) + 1; | |
688 | - this.TTGrid.getSelectionModel().deselectAll(); | |
689 | - | |
690 | - var me = this; | |
691 | - AmdaAction.addCacheInterval({'index' : row}, function (result, e) { | |
692 | - this.status = result.status; | |
693 | - if (!this.TTGrid.getStore().loading) { | |
694 | - this.TTGrid.getStore().reload({ | |
695 | - callback : function(records, options, success) { | |
696 | - me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { | |
697 | - me.TTGrid.getView().select(row); | |
698 | - cellEditing.startEditByPosition({row: row, column: 1}); | |
699 | - }, me); | |
700 | - } | |
701 | - }); | |
702 | - } | |
703 | - }, this); | |
704 | - } | |
705 | - }, { | |
706 | - iconCls: 'icon-delete', | |
707 | - disabled: true, | |
708 | - itemId: 'delete', | |
709 | - scope: this, | |
710 | - handler: function(){ | |
711 | - var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
712 | - if (selection) { | |
713 | - var rowId = selection.get('cacheId'); | |
714 | - this.TTGrid.getSelectionModel().deselectAll(); | |
715 | - AmdaAction.removeTTCacheIntervalFromId(rowId, false, function (result, e) { | |
716 | - this.status = result.status; | |
717 | - if (!this.TTGrid.getStore().loading) { | |
718 | - this.TTGrid.getStore().reload(); | |
719 | - } | |
720 | - }, this); | |
690 | + xtype: 'toolbar', | |
691 | + items: [{ | |
692 | + iconCls: 'icon-add', | |
693 | + scope: this, | |
694 | + handler: function () { | |
695 | + cellEditing.cancelEdit(); | |
696 | + | |
697 | + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
698 | + var row = 0; | |
699 | + if (selection) | |
700 | + row = store.indexOf(selection) + 1; | |
701 | + this.TTGrid.getSelectionModel().deselectAll(); | |
702 | + | |
703 | + var me = this; | |
704 | + AmdaAction.addCacheInterval({'index': row}, function (result, e) { | |
705 | + this.status = result.status; | |
706 | + if (!this.TTGrid.getStore().loading) { | |
707 | + this.TTGrid.getStore().reload({ | |
708 | + callback: function (records, options, success) { | |
709 | + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function () { | |
710 | + me.TTGrid.getView().select(row); | |
711 | + cellEditing.startEditByPosition({row: row, column: 1}); | |
712 | + }, me); | |
713 | + } | |
714 | + }); | |
715 | + } | |
716 | + }, this); | |
717 | + } | |
718 | + }, { | |
719 | + iconCls: 'icon-delete', | |
720 | + disabled: true, | |
721 | + itemId: 'delete', | |
722 | + scope: this, | |
723 | + handler: function () { | |
724 | + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
725 | + if (selection) { | |
726 | + var rowId = selection.get('cacheId'); | |
727 | + this.TTGrid.getSelectionModel().deselectAll(); | |
728 | + AmdaAction.removeTTCacheIntervalFromId(rowId, false, function (result, e) { | |
729 | + this.status = result.status; | |
730 | + if (!this.TTGrid.getStore().loading) { | |
731 | + this.TTGrid.getStore().reload(); | |
732 | + } | |
733 | + }, this); | |
734 | + } | |
735 | + } | |
736 | + }, | |
737 | + '->', | |
738 | + { | |
739 | + text: 'Clear Filters', | |
740 | + scope: this, | |
741 | + handler: function () { | |
742 | + this.TTGrid.getStore().clearFilter(true); | |
743 | + this.TTGrid.filters.clearFilters(); | |
744 | + } | |
721 | 745 | } |
722 | - } | |
723 | - }, | |
724 | - '->', | |
725 | - { | |
726 | - text: 'Clear Filters', | |
727 | - scope: this, | |
728 | - handler: function () { | |
729 | - this.TTGrid.getStore().clearFilter(true); | |
730 | - this.TTGrid.filters.clearFilters(); | |
731 | - } | |
732 | - } | |
733 | - ] | |
734 | - }], | |
735 | - plugins: [ cellEditing, {ptype : 'bufferedrenderer'} ], | |
736 | - listeners : { | |
737 | - scope : this, | |
738 | - edit : function(editor,e) { | |
746 | + ] | |
747 | + }], | |
748 | + plugins: [cellEditing, {ptype: 'bufferedrenderer'}], | |
749 | + listeners: { | |
750 | + scope: this, | |
751 | + edit: function (editor, e) { | |
739 | 752 | if (e.record.get('stop') != null && e.record.get('start') != null) { |
740 | - e.record.set('durationHour', (e.record.get('stop') - e.record.get('start'))/3600000.0); | |
741 | - e.record.set('durationMin', (e.record.get('stop') - e.record.get('start'))/60000.0); | |
742 | - e.record.set('durationSec', (e.record.get('stop') - e.record.get('start'))/1000.0); | |
753 | + e.record.set('durationHour', (e.record.get('stop') - e.record.get('start')) / 3600000.0); | |
754 | + e.record.set('durationMin', (e.record.get('stop') - e.record.get('start')) / 60000.0); | |
755 | + e.record.set('durationSec', (e.record.get('stop') - e.record.get('start')) / 1000.0); | |
743 | 756 | // send refresh event to statistical plugin |
744 | 757 | this.fireEvent("refresh"); |
745 | 758 | } |
746 | 759 | } |
747 | 760 | } |
748 | - }); | |
761 | + }); | |
749 | 762 | |
750 | - this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections){ | |
751 | - this.TTGrid.down('#delete').setDisabled(selections.length === 0); | |
763 | + this.TTGrid.getSelectionModel().on('selectionchange', function (selModel, selections) { | |
764 | + this.TTGrid.down('#delete').setDisabled(selections.length === 0); | |
752 | 765 | }, this); |
753 | 766 | |
754 | - var myConf = { | |
755 | - layout: 'border', | |
756 | - defaults: { layout: 'fit', border: false }, | |
757 | - items : [ | |
767 | + var myConf = { | |
768 | + layout: 'border', | |
769 | + defaults: {layout: 'fit', border: false}, | |
770 | + items: [ | |
758 | 771 | { |
759 | 772 | xtype: 'form', |
760 | 773 | region: 'center', |
761 | 774 | buttonAlign: 'left', |
762 | - bodyStyle: {background : '#dfe8f6'}, | |
775 | + bodyStyle: {background: '#dfe8f6'}, | |
763 | 776 | padding: '5 5 5 5', |
764 | 777 | layout: {type: 'hbox', pack: 'start', align: 'stretch'}, |
765 | 778 | items: [ |
... | ... | @@ -783,108 +796,108 @@ Ext.define('amdaUI.TimeTableUI', { |
783 | 796 | padding: '0 0 5 15', |
784 | 797 | flex: 4, |
785 | 798 | layout: 'fit', |
786 | - items: [ this.TTGrid ] | |
799 | + items: [this.TTGrid] | |
787 | 800 | } |
788 | 801 | ], |
789 | - fbar:[ | |
802 | + fbar: [ | |
790 | 803 | { |
791 | 804 | xtype: 'button', |
792 | 805 | text: 'Save', |
793 | 806 | width: 65, |
794 | - scope : this, | |
807 | + scope: this, | |
795 | 808 | handler: function () { |
796 | - this.saveTT(); | |
797 | - } | |
798 | - },{ | |
809 | + this.saveTT(); | |
810 | + } | |
811 | + }, { | |
799 | 812 | xtype: 'button', |
800 | 813 | text: 'Reset', |
801 | 814 | width: 65, |
802 | 815 | scope: this, |
803 | - handler: function() { | |
804 | - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
805 | - ttModule.createLinkedNode(); | |
806 | - ttModule.createObject(); | |
807 | - this.setObject(ttModule.getLinkedNode().get('object')); | |
816 | + handler: function () { | |
817 | + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); | |
818 | + ttModule.createLinkedNode(); | |
819 | + ttModule.createObject(); | |
820 | + this.setObject(ttModule.getLinkedNode().get('object')); | |
808 | 821 | } |
809 | - },{ | |
822 | + }, { | |
810 | 823 | xtype: 'button', |
811 | 824 | text: 'Generate Catalog', |
812 | 825 | width: 120, |
813 | 826 | scope: this, |
814 | - handler: function() { | |
827 | + handler: function () { | |
815 | 828 | this.generateCAT(this.object.get('id')); |
816 | 829 | } |
817 | 830 | } |
818 | 831 | ] |
819 | 832 | }, |
820 | 833 | { |
821 | - xtype: 'panel', region: 'south', | |
822 | - title: 'Information', | |
823 | - collapsible: true, | |
824 | - collapseMode: 'header', | |
825 | - height: 100, | |
826 | - autoHide: false, | |
827 | - iconCls: 'icon-information', | |
828 | - bodyStyle: 'padding:5px', | |
829 | - loader: { | |
830 | - autoLoad: true, | |
831 | - url: helpDir+'timetableHOWTO' | |
832 | - } | |
834 | + xtype: 'panel', region: 'south', | |
835 | + title: 'Information', | |
836 | + collapsible: true, | |
837 | + collapseMode: 'header', | |
838 | + height: 100, | |
839 | + autoHide: false, | |
840 | + iconCls: 'icon-information', | |
841 | + bodyStyle: 'padding:5px', | |
842 | + loader: { | |
843 | + autoLoad: true, | |
844 | + url: helpDir + 'timetableHOWTO' | |
845 | + } | |
833 | 846 | } |
834 | 847 | ], |
835 | - plugins: [ {ptype: 'statisticalPlugin'} ] | |
836 | - }; | |
837 | - | |
838 | - Ext.apply (this , Ext.apply (arguments, myConf)); | |
839 | - }, | |
840 | - | |
841 | - checkIntervalsStatusForSave : function(onStatusOk) { | |
842 | - if (this.status == null) | |
843 | - return; | |
844 | - | |
845 | - if (this.status.nbValid <= 0) | |
846 | - { | |
847 | - myDesktopApp.errorMsg('Your time table is invalid, <br>you must have at least one valid interval'); | |
848 | - return; | |
849 | - } | |
850 | - | |
851 | - var msg = ''; | |
852 | - if (this.status.nbInvalid > 0) | |
853 | - msg += 'There are some invalid intervals. Only valid intervals will be saved!<br/>'; | |
854 | - if (this.status.nbFiltered > 0) | |
855 | - msg += 'There are some filtered intervals. Filtered intervals will not be saved!<br/>'; | |
856 | - if (msg != '') | |
857 | - { | |
858 | - msg += 'Do you want to continue?'; | |
859 | - Ext.Msg.show({ | |
860 | - title:'Warning!', | |
861 | - msg: msg, | |
862 | - buttons: Ext.Msg.OKCANCEL, | |
863 | - fn: function(btnId){ | |
864 | - if (btnId==='cancel'){ | |
865 | - // cancel the save action | |
866 | - } else { | |
867 | - onStatusOk(); | |
868 | - } | |
869 | - }, | |
870 | - scope: this, | |
871 | - icon: Ext.Msg.WARNING | |
872 | - }); | |
873 | - return; | |
874 | - } | |
875 | - | |
876 | - onStatusOk(); | |
877 | - }, | |
878 | - | |
879 | - /** | |
880 | - * Check if changes were made before closing window | |
881 | - * @return true if changes | |
882 | - */ | |
883 | - fclose : function() { | |
884 | - if (this.status == null) | |
885 | - return false; | |
886 | - | |
887 | - var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); | |
888 | - return isDirty; | |
889 | - } | |
848 | + plugins: [{ptype: 'statisticalPlugin'}] | |
849 | + }; | |
850 | + | |
851 | + Ext.apply(this, Ext.apply(arguments, myConf)); | |
852 | + }, | |
853 | + | |
854 | + checkIntervalsStatusForSave: function (onStatusOk) { | |
855 | + if (this.status == null) | |
856 | + return; | |
857 | + | |
858 | + if (this.status.nbValid <= 0) | |
859 | + { | |
860 | + myDesktopApp.errorMsg('Your time table is invalid, <br>you must have at least one valid interval'); | |
861 | + return; | |
862 | + } | |
863 | + | |
864 | + var msg = ''; | |
865 | + if (this.status.nbInvalid > 0) | |
866 | + msg += 'There are some invalid intervals. Only valid intervals will be saved!<br/>'; | |
867 | + if (this.status.nbFiltered > 0) | |
868 | + msg += 'There are some filtered intervals. Filtered intervals will not be saved!<br/>'; | |
869 | + if (msg != '') | |
870 | + { | |
871 | + msg += 'Do you want to continue?'; | |
872 | + Ext.Msg.show({ | |
873 | + title: 'Warning!', | |
874 | + msg: msg, | |
875 | + buttons: Ext.Msg.OKCANCEL, | |
876 | + fn: function (btnId) { | |
877 | + if (btnId === 'cancel') { | |
878 | + // cancel the save action | |
879 | + } else { | |
880 | + onStatusOk(); | |
881 | + } | |
882 | + }, | |
883 | + scope: this, | |
884 | + icon: Ext.Msg.WARNING | |
885 | + }); | |
886 | + return; | |
887 | + } | |
888 | + | |
889 | + onStatusOk(); | |
890 | + }, | |
891 | + | |
892 | + /** | |
893 | + * Check if changes were made before closing window | |
894 | + * @return true if changes | |
895 | + */ | |
896 | + fclose: function () { | |
897 | + if (this.status == null) | |
898 | + return false; | |
899 | + | |
900 | + var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); | |
901 | + return isDirty; | |
902 | + } | |
890 | 903 | }); |
... | ... |