Commit c713e292e70d38649884ced6f115e2d61eff0888
1 parent
52692f19
Exists in
master
and in
109 other branches
fix eslint warnings
Showing
3 changed files
with
676 additions
and
524 deletions
Show diff stats
js/.eslintrc.yml
... | ... | @@ -10,6 +10,11 @@ rules: |
10 | 10 | semi: [error, always] |
11 | 11 | max-len: [error, code: 120] |
12 | 12 | max-lines: [warn, 600] |
13 | + max-params: [warn, 3] | |
14 | + complexity: [warn, 20] | |
15 | + no-ternary: off | |
16 | + no-plusplus: off | |
17 | + multiline-ternary: off | |
13 | 18 | linebreak-style: [error, unix] |
14 | 19 | quotes: [error, single] |
15 | 20 | strict: [error, global] |
... | ... | @@ -26,6 +31,9 @@ rules: |
26 | 31 | id-length: off |
27 | 32 | no-magic-numbers: off |
28 | 33 | no-invalid-this: off |
34 | + no-extra-parens: [error, all, nestedBinaryExpressions: false] | |
35 | + camelcase: warn | |
36 | + max-depth: warn | |
29 | 37 | |
30 | 38 | # ES3/5 compatibility: |
31 | 39 | prefer-template: off |
... | ... | @@ -33,3 +41,4 @@ rules: |
33 | 41 | prefer-arrow-callback: off |
34 | 42 | object-shorthand: off |
35 | 43 | prefer-rest-params: off |
44 | + prefer-destructuring: off | ... | ... |
js/app/models/InteractiveNode.js
... | ... | @@ -8,36 +8,64 @@ |
8 | 8 | * @version $Id: InteractiveNode.js 2683 2014-12-02 10:58:53Z elena $ |
9 | 9 | */ |
10 | 10 | |
11 | +/* global amdaUI, AmdaAction, myDesktopApp, amdaPlotObj, amdaModel*/ | |
12 | + | |
11 | 13 | Ext.define('amdaModel.InteractiveNode', { |
12 | 14 | extend: 'amdaModel.AmdaNode', |
13 | 15 | |
14 | - requires: [ | |
15 | - 'amdaPlotObj.PlotRequestObject' | |
16 | - ], | |
16 | + requires: ['amdaPlotObj.PlotRequestObject'], | |
17 | 17 | |
18 | 18 | fields: [ |
19 | - {name: 'contextNode', type: 'amdaModel.AmdaNode', persist: false}, | |
20 | - {name: 'objectDataModel', type: 'string', persist: false}, | |
21 | - {name: 'object', type: 'object', persist: false}, | |
22 | - {name: 'moduleId', type: 'string', persist: false}, | |
23 | - {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, | |
24 | - {name: 'disable', type: 'boolean', defaultValue: false, persist: false} | |
19 | + { | |
20 | + name: 'contextNode', | |
21 | + type: 'amdaModel.AmdaNode', | |
22 | + persist: false | |
23 | + }, | |
24 | + { | |
25 | + name: 'objectDataModel', | |
26 | + type: 'string', | |
27 | + persist: false | |
28 | + }, | |
29 | + { | |
30 | + name: 'object', | |
31 | + type: 'object', | |
32 | + persist: false | |
33 | + }, | |
34 | + { | |
35 | + name: 'moduleId', | |
36 | + type: 'string', | |
37 | + persist: false | |
38 | + }, | |
39 | + { | |
40 | + name: 'filtered', | |
41 | + type: 'boolean', | |
42 | + defaultValue: false, | |
43 | + persist: false | |
44 | + }, | |
45 | + { | |
46 | + name: 'disable', | |
47 | + type: 'boolean', | |
48 | + defaultValue: false, | |
49 | + persist: false | |
50 | + } | |
25 | 51 | ], |
26 | 52 | |
27 | 53 | statics: { |
28 | 54 | preloadNodes: function (node, onready) { |
29 | - var me = this; | |
55 | + var nodesToLoad; | |
30 | 56 | |
31 | - var nodesToLoad = []; | |
57 | + nodesToLoad = []; | |
32 | 58 | nodesToLoad.push(node); |
33 | - this.preloadTreeNode(node, nodesToLoad, function (node) { | |
59 | + this.preloadTreeNode(node, nodesToLoad, function () { | |
34 | 60 | var isFinish = true; |
35 | - nodesToLoad.forEach(function (element, index, array) { | |
36 | - if (!element.isLoaded()) | |
61 | + nodesToLoad.forEach(function (element) { | |
62 | + if (!element.isLoaded()) { | |
37 | 63 | isFinish = false; |
64 | + } | |
38 | 65 | }); |
39 | - if (isFinish && onready) | |
66 | + if (isFinish && onready) { | |
40 | 67 | onready.call(); |
68 | + } | |
41 | 69 | }); |
42 | 70 | }, |
43 | 71 | |
... | ... | @@ -52,22 +80,24 @@ Ext.define('amdaModel.InteractiveNode', { |
52 | 80 | } |
53 | 81 | }); |
54 | 82 | |
55 | - if (onloaded) | |
83 | + if (onloaded) { | |
56 | 84 | onloaded.call(me, node); |
85 | + } | |
57 | 86 | return; |
58 | 87 | } |
59 | 88 | |
60 | 89 | node.store.load({ |
61 | 90 | node: node, |
62 | - callback: function (records, operation, successful) { | |
91 | + callback: function (records) { | |
63 | 92 | records.forEach(function (record) { |
64 | 93 | if (!record.isLoaded() && !record.isLeaf()) { |
65 | 94 | nodesToLoad.push(record); |
66 | 95 | me.preloadTreeNode(record, nodesToLoad, onloaded); |
67 | 96 | } |
68 | 97 | }); |
69 | - if (onloaded) | |
98 | + if (onloaded) { | |
70 | 99 | onloaded.call(me, node); |
100 | + } | |
71 | 101 | } |
72 | 102 | }); |
73 | 103 | } |
... | ... | @@ -76,49 +106,61 @@ Ext.define('amdaModel.InteractiveNode', { |
76 | 106 | onReady: null, |
77 | 107 | |
78 | 108 | constructor: function (config) { |
109 | + var suffix; | |
79 | 110 | this.callParent(arguments); |
80 | 111 | this.set('nodeType', this.self.nodeType); |
81 | 112 | this.set('ownerTreeId', amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); |
82 | - if (this.get('id')) { // TODO why sometimes (delete in remote interoper tree) this.get('id') = undefined ? | |
83 | - // if id of this node have root category suffix | |
84 | - if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) { | |
85 | - // set the expanded property to true | |
113 | + // TODO why sometimes (delete in remote interoper tree) this.get('id') = undefined ? | |
114 | + if (this.get('id')) { | |
115 | + // If id of this node have root category suffix | |
116 | + suffix = amdaUI.ExplorerUI.CAT_SUFFIX; | |
117 | + if (Ext.util.Format.substr(this.get('id'), -suffix.length, this.get('id').length) === suffix) { | |
118 | + // Set the expanded property to true | |
86 | 119 | this.set('expanded', true); |
87 | 120 | } |
88 | 121 | } |
89 | 122 | }, |
90 | 123 | |
91 | 124 | /** |
92 | - * this method is overriden into ExecutableNode to return true | |
125 | + * This method is overriden into ExecutableNode to return true | |
126 | + * @returns {boolean} true if node is executable | |
93 | 127 | */ |
94 | 128 | isExecutable: function () { |
95 | 129 | return false; |
96 | 130 | }, |
97 | 131 | |
98 | 132 | /** |
99 | - * open Module with THIS NODE | |
133 | + * Open Module with THIS NODE | |
134 | + * @param {object} contextNode Context node | |
135 | + * @param {function} onReady onRady callback function | |
136 | + * @returns {void} | |
100 | 137 | */ |
101 | 138 | editInModule: function (contextNode, onReady) { |
102 | - // set the contextNode of this node | |
103 | - this.set('contextNode', contextNode); | |
104 | - // parameter module | |
105 | 139 | var me = this; |
140 | + // Set the contextNode of this node | |
141 | + this.set('contextNode', contextNode); | |
142 | + // Parameter module | |
106 | 143 | myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { |
107 | 144 | // If the node to edit is not already linked to this module |
108 | 145 | if (module.getLinkedNode() != me) { |
109 | - // set relative node into parameter Module | |
146 | + // Set relative node into parameter Module | |
110 | 147 | module.setLinkedNode(me); |
111 | 148 | if (contextNode == null) { |
112 | - // set the root node as contextNode | |
149 | + // Set the root node as contextNode | |
113 | 150 | contextNode = me.getRootNode(); |
114 | 151 | } |
115 | 152 | module.setContextNode(contextNode); |
116 | 153 | |
117 | 154 | } else if (module.getLinkedNode() != null) { |
118 | - //TODO the node to edit is already edited | |
119 | - // myDesktopApp.warningMsg('This object is being edited'); | |
120 | - //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' | |
121 | - //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' | |
155 | + | |
156 | + /* | |
157 | + * TODO the node to edit is already edited | |
158 | + * myDesktopApp.warningMsg('This object is being edited'); | |
159 | + * Sol1: msg alert: "warning this node is already edited! If you want to get the original, | |
160 | + * please press the 'reset' button"->'OK' | |
161 | + * Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your | |
162 | + * modification?"->'Confirm','Cancel' | |
163 | + */ | |
122 | 164 | } |
123 | 165 | // Opening parameter window |
124 | 166 | module.createWindow(onReady); |
... | ... | @@ -127,6 +169,9 @@ Ext.define('amdaModel.InteractiveNode', { |
127 | 169 | |
128 | 170 | /** |
129 | 171 | * Method to rename the workspace node |
172 | + * @param {string} value The new name | |
173 | + * @param {function} callBackFn Callback function | |
174 | + * @returns {void} | |
130 | 175 | */ |
131 | 176 | rename: function (value, callBackFn) { |
132 | 177 | var dataToSend = { |
... | ... | @@ -142,6 +187,9 @@ Ext.define('amdaModel.InteractiveNode', { |
142 | 187 | |
143 | 188 | /** |
144 | 189 | * Method to rename the workspace node when D&D |
190 | + * @param {string} parentId The parent ID | |
191 | + * @param {function} callBackFn callback function | |
192 | + * @returns {void} | |
145 | 193 | */ |
146 | 194 | renameDD: function (parentId, callBackFn) { |
147 | 195 | var dataToSend = { |
... | ... | @@ -156,18 +204,24 @@ Ext.define('amdaModel.InteractiveNode', { |
156 | 204 | }, |
157 | 205 | |
158 | 206 | /** |
159 | - * validation method on name (used in module forms) | |
160 | - * @param name the name to validate | |
161 | - * @returns | |
207 | + * Validation method on name (used in module forms) | |
208 | + * @param {string} name the name to validate | |
209 | + * @param {function} callBackFn Callback function | |
210 | + * @returns {void} | |
162 | 211 | */ |
163 | 212 | isValidName: function (name, callBackFn) { |
164 | - var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isLeaf()}; | |
213 | + var dataToSend = { | |
214 | + name: name, | |
215 | + nodeType: this.get('nodeType'), | |
216 | + leaf: this.isLeaf() | |
217 | + }; | |
165 | 218 | AmdaAction.validNameObject(dataToSend, callBackFn); |
166 | 219 | }, |
167 | 220 | |
168 | 221 | /** |
169 | - * Method to persist modifications of an AmdaObject by Server side and update the workspace | |
170 | - * node linked to a Module | |
222 | + * Method to persist modifications of an AmdaObject by Server side and update the workspace node linked to a Module | |
223 | + * @param {object} opt ... | |
224 | + * @returns {void} | |
171 | 225 | */ |
172 | 226 | update: function (opt) { |
173 | 227 | AmdaAction.modifyObject(this.get('object').getJsonValues(true), function (res, e) { |
... | ... | @@ -175,20 +229,18 @@ Ext.define('amdaModel.InteractiveNode', { |
175 | 229 | if (e.status) { |
176 | 230 | if (res.id) { |
177 | 231 | if (!this.get('contextNode')) { |
178 | - // set the root node of 'Derived Parameters' tree as contextNode | |
232 | + // Set the root node of 'Derived Parameters' tree as contextNode | |
179 | 233 | this.set('contextNode', this.getRootNode()); |
180 | 234 | } |
181 | 235 | this.get('contextNode').expand(false, false); |
182 | 236 | this.myGetOwnerTree().getSelectionModel().select(this); |
183 | 237 | |
184 | - if (opt) { | |
185 | - var scope = opt.scope ? opt.scope : this; | |
186 | - if (opt.callback) | |
187 | - opt.callback.call(scope, 'update'); | |
238 | + if (opt && opt.callback) { | |
239 | + opt.callback.call(opt.scope ? opt.scope : this, 'update'); | |
188 | 240 | } |
189 | 241 | |
190 | 242 | Ext.Msg.alert('Complete', 'Object ' + this.get('object').get('name') + ' has been modified'); |
191 | - // fix the modifications for object | |
243 | + // Fix the modifications for object | |
192 | 244 | this.get('object').commit(); |
193 | 245 | |
194 | 246 | if (res.info) { |
... | ... | @@ -198,33 +250,33 @@ Ext.define('amdaModel.InteractiveNode', { |
198 | 250 | if (this.get('nodeType') == 'myDataParam') { |
199 | 251 | if (res.isSpectra) { |
200 | 252 | this.set('iconCls', 'icon-spectra'); |
201 | - } | |
202 | - else { | |
203 | - if (res.size > 1) this.set('iconCls', 'icon-unknowntype'); | |
253 | + } else if (res.size > 1) { | |
254 | + this.set('iconCls', 'icon-unknowntype'); | |
204 | 255 | } |
205 | 256 | } |
206 | 257 | |
207 | - // update my data on possibble mask change | |
258 | + // Update my data on possibble mask change | |
208 | 259 | if (res.updateMyData) { |
209 | 260 | this.updateMyData(); |
210 | 261 | this.updateMask(res.mask); |
211 | 262 | } |
212 | - // reload object into the view of corresponding Module | |
263 | + // Reload object into the view of corresponding Module | |
213 | 264 | var me = this; |
214 | 265 | myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { |
215 | 266 | module.getUiContent().setObject(me.get('object')); |
216 | 267 | }); |
217 | - } | |
218 | - else { | |
219 | - //TODO proper error message handling | |
220 | - // error code from server; but e.status==true | |
221 | - // revert all modifications since last load or commit | |
268 | + } else { | |
269 | + | |
270 | + /* | |
271 | + *TODO proper error message handling | |
272 | + * error code from server; but e.status==true | |
273 | + * revert all modifications since last load or commit | |
274 | + */ | |
222 | 275 | this.get('object').reject(); |
223 | 276 | myDesktopApp.errorMsg(res.error); |
224 | 277 | } |
225 | - } | |
226 | - else { | |
227 | - // revert all modifications since last load or commit | |
278 | + } else { | |
279 | + // Revert all modifications since last load or commit | |
228 | 280 | this.get('object').reject(); |
229 | 281 | myDesktopApp.errorMsg(e.message); |
230 | 282 | } |
... | ... | @@ -232,114 +284,122 @@ Ext.define('amdaModel.InteractiveNode', { |
232 | 284 | }, |
233 | 285 | |
234 | 286 | /** |
235 | - * Method to create a new AmdaObject by server side and create the workspace node linked to a Module | |
236 | - * under its contextNode or the root node corresponding to this nodeType category | |
287 | + * Method to create a new AmdaObject by server side and create the workspace node linked to a Module under its | |
288 | + * contextNode or the root node corresponding to this nodeType category. | |
289 | + * @param {object} opt ... | |
290 | + * @returns {void} | |
237 | 291 | */ |
238 | 292 | create: function (opt) { |
239 | - if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { | |
240 | - // set the root node of 'Derived Parameters' tree as contextNode | |
293 | + var contextId; | |
294 | + if (!this.get('contextNode') || this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode' || | |
295 | + this.get('contextNode').data.id == 'sharedcatalog-treeRootNode') { | |
296 | + // Set the root node of 'Derived Parameters' tree as contextNode | |
241 | 297 | this.set('contextNode', this.getRootNode()); |
242 | 298 | } |
243 | - // call the Ext.Direct method to create parameter | |
244 | - AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function (res, e) { | |
245 | - //success | |
299 | + // Call the Ext.Direct method to create parameter | |
300 | + contextId = this.get('contextNode').get('id'); | |
301 | + AmdaAction.createObject(this.get('object').getJsonValues(false), contextId, function (res, e) { | |
302 | + var myRoot, updateNode; | |
303 | + // Success | |
246 | 304 | if (e.status) { |
247 | - // if correct response received | |
248 | - if (res.id) { //if (res.id || res.error == 'NAME_EXISTS') { | |
249 | - // 'save as' case ; delete old node if it exists | |
305 | + // If correct response received | |
306 | + if (res.id) { | |
307 | + // If (res.id || res.error == 'NAME_EXISTS') { | |
250 | 308 | if (this.toRename) { |
309 | + // 'save as' case ; delete old node if it exists | |
251 | 310 | this.toRename = false; |
252 | - var myRoot = this.getRootNode(); | |
253 | - // search the same named node to override | |
254 | - var updateNode = myRoot.findChild('text', this.get('object').get('name'), true); | |
255 | - // destroy the overrided node | |
256 | - updateNode.parentNode.removeChild(updateNode);//TODO ??if destroy==true => too many recursions.... | |
311 | + myRoot = this.getRootNode(); | |
312 | + // Search the same named node to override | |
313 | + updateNode = myRoot.findChild('text', this.get('object').get('name'), true); | |
314 | + // Destroy the overrided node | |
315 | + updateNode.parentNode.removeChild(updateNode); | |
316 | + // TODO ??if destroy==true => too many recursions.... | |
257 | 317 | updateNode.destroy(); |
258 | 318 | } |
259 | - // set text of this node | |
319 | + // Set text of this node | |
260 | 320 | this.set('text', this.get('object').get('name')); |
261 | - //set id of this node | |
321 | + // Set id of this node | |
262 | 322 | this.set('id', res.id); |
263 | 323 | this.internalId = res.id; |
264 | - // set id of node's object | |
324 | + // Set id of node's object | |
265 | 325 | this.get('object').set('id', res.id); |
266 | 326 | |
267 | 327 | if (res.created) { |
268 | - // set the created date | |
328 | + // Set the created date | |
269 | 329 | this.get('object').set('created', res.created); |
270 | 330 | } |
271 | 331 | |
272 | 332 | if (res.info) { |
273 | - // set the tooltip | |
333 | + // Set the tooltip | |
274 | 334 | this.set('info', res.info); |
275 | - //set globalStart & global Stop to be used for time selection | |
335 | + // Set globalStart & global Stop to be used for time selection | |
276 | 336 | if (this.get('nodeType') == 'myDataParam') { |
277 | - var startStop = res.info.split("<br/>"); | |
278 | - var globalStart = startStop[1].substr(0, 19); | |
279 | - var globalStop = startStop[1].substr(20); | |
337 | + var startStop = res.info.split('<br/>'); | |
338 | + this.set('globalStart', startStop[1].substr(0, 19)); | |
339 | + this.set('globalStop', startStop[1].substr(20)); | |
280 | 340 | |
281 | - this.set('globalStart', globalStart); | |
282 | - this.set('globalStop', globalStop); | |
283 | - | |
284 | - if (res.mask) | |
341 | + if (res.mask) { | |
285 | 342 | this.set('linkedMask', res.mask); |
286 | - if (res.size) | |
343 | + } | |
344 | + if (res.size) { | |
287 | 345 | this.set('size', res.size); |
346 | + } | |
288 | 347 | |
289 | 348 | if (res.isSpectra) { |
290 | 349 | this.set('iconCls', 'icon-spectra'); |
291 | - } | |
292 | - else { | |
293 | - if (res.size > 1) | |
294 | - this.set('iconCls', 'icon-unknowntype'); | |
350 | + } else if (res.size > 1) { | |
351 | + this.set('iconCls', 'icon-unknowntype'); | |
295 | 352 | } |
296 | 353 | } |
297 | 354 | } |
298 | - //TODO do we need this commission ??? | |
299 | - // fix the modifications for object | |
355 | + | |
356 | + /* | |
357 | + *TODO do we need this commission ??? | |
358 | + * fix the modifications for object | |
359 | + */ | |
300 | 360 | this.get('object').commit(); |
301 | - // if ownerTree panel is not active | |
361 | + // If ownerTree panel is not active | |
302 | 362 | if (this.myGetOwnerTree().ownerCt.getActiveTab() !== this.myGetOwnerTree()) { |
303 | - // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view | |
363 | + // Set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view | |
304 | 364 | this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); |
305 | 365 | } |
306 | 366 | |
307 | 367 | Ext.Msg.alert('Complete', 'New object ' + this.get('object').get('name') + ' has been created'); |
308 | - // expand the contextNode | |
368 | + // Expand the contextNode | |
309 | 369 | this.get('contextNode').expand(false, function () { |
310 | 370 | if (!this.get('contextNode').findChild('text', this.get('text'))) { |
311 | - // create node in tree as child of contextNode | |
371 | + // Create node in tree as child of contextNode | |
312 | 372 | this.get('contextNode').appendChild(this); |
313 | 373 | } |
314 | - // select the new node | |
374 | + // Select the new node | |
315 | 375 | this.myGetOwnerTree().getSelectionModel().select(this); |
316 | - if (opt) { | |
317 | - var scope = opt.scope ? opt.scope : this; | |
318 | - if (opt.callback) | |
319 | - opt.callback.call(scope, 'create'); | |
376 | + if (opt && opt.callback) { | |
377 | + opt.callback.call(opt.scope ? opt.scope : this, 'create'); | |
320 | 378 | } |
321 | 379 | }, this); |
322 | 380 | |
323 | - // myDataParamNode - update MyData subtree | |
324 | - //TODO put this in mydataparamnode | |
381 | + /* | |
382 | + * MyDataParamNode - update MyData subtree | |
383 | + *TODO put this in mydataparamnode | |
384 | + */ | |
325 | 385 | if (res.updateMyData) { |
326 | 386 | this.updateMyData(); |
327 | 387 | this.updateMask(res.mask); |
328 | 388 | } |
329 | 389 | |
330 | 390 | } |
331 | - // error code from server; but e.status==true | |
391 | + // Error code from server; but e.status==true | |
332 | 392 | else { |
333 | 393 | myDesktopApp.errorMsg(res.error); |
334 | - // revert all modifications since last load or commit | |
394 | + // Revert all modifications since last load or commit | |
335 | 395 | this.get('object').reject(); |
336 | 396 | } |
337 | 397 | } |
338 | - // failure: e.status == false | |
398 | + // Failure: e.status == false | |
339 | 399 | else { |
340 | - // revert all modifications since last load or commit | |
400 | + // Revert all modifications since last load or commit | |
341 | 401 | this.get('object').reject(); |
342 | - //TODO: this.destroy(); | |
402 | + // TODO: this.destroy(); | |
343 | 403 | myDesktopApp.errorMsg(e.message); |
344 | 404 | } |
345 | 405 | }, this); |
... | ... | @@ -347,36 +407,46 @@ Ext.define('amdaModel.InteractiveNode', { |
347 | 407 | |
348 | 408 | /** |
349 | 409 | * Generic part of Context Menu |
350 | - * | |
410 | + * @returns {*[]|*} Menu items | |
351 | 411 | */ |
352 | 412 | allMenuItems: function () { |
353 | - var src = this.self.objectName; | |
354 | - var menuItems = [ | |
413 | + var menuItems, src; | |
414 | + | |
415 | + src = this.self.objectName; | |
416 | + menuItems = [ | |
355 | 417 | { |
356 | 418 | fnId: 'root-createLeaf', |
357 | 419 | text: 'Create ' + src |
358 | - }, { | |
420 | + }, | |
421 | + { | |
359 | 422 | fnId: 'root-createDir', |
360 | 423 | text: 'Create Folder' |
361 | - }, { | |
424 | + }, | |
425 | + { | |
362 | 426 | fnId: 'dire-createLeaf', |
363 | 427 | text: 'Create ' + src |
364 | - }, { | |
428 | + }, | |
429 | + { | |
365 | 430 | fnId: 'dire-createDir', |
366 | 431 | text: 'Create Folder' |
367 | - }, { | |
432 | + }, | |
433 | + { | |
368 | 434 | fnId: 'dire-renameNode', |
369 | 435 | text: 'Rename Folder' |
370 | - }, { | |
436 | + }, | |
437 | + { | |
371 | 438 | fnId: 'dire-deleteNode', |
372 | 439 | text: 'Delete Folder' |
373 | - }, { | |
440 | + }, | |
441 | + { | |
374 | 442 | fnId: 'leaf-editLeaf', |
375 | 443 | text: 'Edit ' + src |
376 | - }, { | |
444 | + }, | |
445 | + { | |
377 | 446 | fnId: 'leaf-renameNode', |
378 | 447 | text: 'Rename ' + src |
379 | - }, { | |
448 | + }, | |
449 | + { | |
380 | 450 | fnId: 'leaf-deleteNode', |
381 | 451 | text: 'Delete ' + src |
382 | 452 | } |
... | ... | @@ -385,13 +455,12 @@ Ext.define('amdaModel.InteractiveNode', { |
385 | 455 | }, |
386 | 456 | |
387 | 457 | allMenuMultiItems: function () { |
388 | - var menuMulti = [ | |
458 | + return [ | |
389 | 459 | { |
390 | 460 | fnId: 'mult-deleteMulti', |
391 | 461 | text: 'Delete selected ' + this.self.objectName + 's' |
392 | 462 | } |
393 | 463 | ]; |
394 | - return menuMulti; | |
395 | 464 | }, |
396 | 465 | |
397 | 466 | getAllContextMenuItems: function () { |
... | ... | @@ -402,20 +471,24 @@ Ext.define('amdaModel.InteractiveNode', { |
402 | 471 | return this.allMenuMultiItems(); |
403 | 472 | }, |
404 | 473 | |
474 | + // FIXME: duplicate declaration ↓ ↑ | |
475 | + | |
405 | 476 | /** |
406 | - * default implementation | |
407 | - * no menu display if there's no override of this function | |
477 | + * Default implementation: no menu display if there's no override of this function | |
478 | + * @returns {null} Items | |
408 | 479 | */ |
409 | 480 | getMultiContextMenuItems: function () { |
410 | 481 | return null; |
411 | 482 | }, |
412 | 483 | |
413 | 484 | /** |
414 | - * Context Menu Actions | |
415 | - * | |
485 | + * Context Menu Actions | |
486 | + * @param {object} menu The menu | |
487 | + * @param {object} item the item | |
488 | + * @returns {void} | |
416 | 489 | */ |
417 | - onMenuItemClick: function (menu, item, event) { | |
418 | - // fnId parsing : | |
490 | + onMenuItemClick: function (menu, item) { | |
491 | + // FnId parsing : | |
419 | 492 | var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); |
420 | 493 | |
421 | 494 | switch (fnId) { |
... | ... | @@ -445,36 +518,41 @@ Ext.define('amdaModel.InteractiveNode', { |
445 | 518 | break; |
446 | 519 | default: |
447 | 520 | break; |
448 | - } // switch end | |
521 | + } | |
449 | 522 | }, |
450 | 523 | |
451 | 524 | getTimeFromNode: function (node) { |
452 | - var startString = String(node.get('globalStart')); | |
453 | - var stopString = String(node.get('globalStop')); | |
454 | - | |
455 | - var startDate = new Date(startString.replace(/\-/g, '\/').replace(/[T|Z]/g, ' ')); | |
456 | - var stopDate = new Date(stopString.replace(/\-/g, '\/').replace(/[T|Z]/g, ' ')); | |
525 | + var startDate, stopDate, timeObj; | |
526 | + startDate = new Date(String(node.get('globalStart')).replace(/-/g, '/').replace(/[T|Z]/g, ' ')); | |
527 | + stopDate = new Date(String(node.get('globalStop')).replace(/-/g, '/').replace(/[T|Z]/g, ' ')); | |
457 | 528 | |
458 | 529 | if (stopDate - startDate > 86400000) { |
459 | - var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); | |
460 | - // var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; | |
461 | - var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d'), stop: Ext.Date.format(stopDate, 'Y/m/d')}; | |
462 | - } | |
463 | - else { | |
464 | - var timeObj = {start: node.get('globalStart'), stop: node.get('globalStop')}; | |
530 | + // 'timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; | |
531 | + timeObj = { | |
532 | + start: Ext.Date.format(Ext.Date.add(stopDate, Ext.Date.DAY, -1), 'Y/m/d'), | |
533 | + stop: Ext.Date.format(stopDate, 'Y/m/d') | |
534 | + }; | |
535 | + } else { | |
536 | + timeObj = { | |
537 | + start: node.get('globalStart'), | |
538 | + stop: node.get('globalStop') | |
539 | + }; | |
465 | 540 | } |
466 | 541 | return timeObj; |
467 | 542 | }, |
468 | 543 | |
469 | 544 | createPlot: function (node) { |
470 | - if (node.get('disable')) return; | |
545 | + if (node.get('disable')) { | |
546 | + return; | |
547 | + } | |
471 | 548 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { |
472 | 549 | if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { |
473 | 550 | var request = Ext.create(amdaPlotObj.PlotRequestObject.$className); |
474 | 551 | var newNode = Ext.create(amdaModel.PlotNode.$className, {object: request}); |
475 | - // edit newNode into Plot Module with node as contextNode | |
552 | + // Edit newNode into Plot Module with node as contextNode | |
476 | 553 | newNode.editInModule(); |
477 | - if ((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { | |
554 | + if (node.get('globalStart') != null && node.get('globalStop') != null && | |
555 | + node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { | |
478 | 556 | module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); |
479 | 557 | } |
480 | 558 | } |
... | ... | @@ -483,7 +561,9 @@ Ext.define('amdaModel.InteractiveNode', { |
483 | 561 | }, |
484 | 562 | |
485 | 563 | createDownload: function (node) { |
486 | - if (node.get('disable')) return; | |
564 | + if (node.get('disable')) { | |
565 | + return; | |
566 | + } | |
487 | 567 | |
488 | 568 | if (node.get('notyet')) { |
489 | 569 | myDesktopApp.warningMsg('Sorry! access to this parameter is restricted.'); |
... | ... | @@ -491,143 +571,163 @@ Ext.define('amdaModel.InteractiveNode', { |
491 | 571 | } |
492 | 572 | |
493 | 573 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { |
574 | + var paramName, request; | |
494 | 575 | if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { |
495 | - var request = Ext.create(amdaModel.Download.$className); | |
576 | + request = Ext.create(amdaModel.Download.$className); | |
496 | 577 | amdaModel.DownloadNode.set('object', request); |
497 | - // singleton! | |
578 | + // Singleton! | |
498 | 579 | amdaModel.DownloadNode.editInModule(); |
499 | - if ((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { | |
580 | + if (node.get('globalStart') != null && node.get('globalStop') != null && | |
581 | + node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { | |
500 | 582 | module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); |
501 | 583 | } |
502 | 584 | } |
503 | - var paramName; | |
504 | - var components = null; | |
505 | 585 | switch (node.$className) { |
506 | - case 'amdaModel.AliasNode' : | |
507 | - paramName = "#" + node.get('text'); | |
586 | + case 'amdaModel.AliasNode': | |
587 | + paramName = '#' + node.get('text'); | |
508 | 588 | break; |
509 | - case 'amdaModel.DerivedParamNode' : | |
510 | - paramName = "ws_" + node.get('text'); | |
589 | + case 'amdaModel.DerivedParamNode': | |
590 | + paramName = 'ws_' + node.get('text'); | |
511 | 591 | break; |
512 | - case 'amdaModel.MyDataParamNode' : | |
592 | + case 'amdaModel.MyDataParamNode': | |
513 | 593 | paramName = 'wsd_' + node.get('text'); |
514 | 594 | break; |
515 | - default : | |
516 | - if (node.get('alias') != "") | |
517 | - paramName = "#" + node.get('alias'); | |
518 | - else | |
595 | + default: | |
596 | + if (node.get('alias') != '') { | |
597 | + paramName = '#' + node.get('alias'); | |
598 | + } else { | |
519 | 599 | paramName = node.get('id'); |
600 | + } | |
520 | 601 | } |
521 | -// var component_info = node.get('component_info'); | |
522 | -// if (component_info && component_info.parentId) { | |
523 | -// //It's a component | |
524 | -// paramName = component_info.parentId; | |
525 | -// components = []; | |
526 | -// if (component_info.index1) | |
527 | -// components['index1'] = component_info.index1; | |
528 | -// if (component_info.index2) | |
529 | -// components['index2'] = component_info.index2; | |
530 | -// } | |
531 | - module.addParam(paramName, true, node.get('needsArgs'), components); | |
602 | + | |
603 | + /* | |
604 | + * Var component_info = node.get('component_info'); | |
605 | + * If (component_info && component_info.parentId) { | |
606 | + * // It's a component | |
607 | + * ParamName = component_info.parentId; | |
608 | + * Components = []; | |
609 | + * If (component_info.index1) | |
610 | + * Components['index1'] = component_info.index1; | |
611 | + * If (component_info.index2) | |
612 | + * Components['index2'] = component_info.index2; | |
613 | + * } | |
614 | + */ | |
615 | + module.addParam(paramName, true, node.get('needsArgs'), null); | |
532 | 616 | }); |
533 | 617 | }, |
534 | 618 | |
535 | 619 | deleteNode: function () { |
536 | - // if the target is a directory | |
537 | - if (!this.isLeaf()) { | |
538 | - // determine if this directory is empty before launching the delete confirmation method | |
539 | - this.isNotEmptyDir(this.confirmDirectoryDeletion); | |
540 | - // else (the target is a leaf) | |
541 | - } else { | |
542 | - // no confirmation prompt for leaves | |
620 | + // If the target is a directory | |
621 | + if (this.isLeaf()) { | |
622 | + // No confirmation prompt for leaves | |
543 | 623 | this.confirmDirectoryDeletion(false); |
624 | + } else { | |
625 | + // Determine if this directory is empty before launching the delete confirmation method | |
626 | + this.isNotEmptyDir(this.confirmDirectoryDeletion); | |
627 | + // Else (the target is a leaf) | |
544 | 628 | } |
545 | 629 | }, |
546 | 630 | |
547 | 631 | /** |
548 | - * this method return if node has Childs even if it was not already loaded | |
632 | + * This method return if node has Childs even if it was not already loaded | |
633 | + * @param {function} callbackFn Callback function | |
634 | + * @returns {void} | |
549 | 635 | */ |
550 | 636 | isNotEmptyDir: function (callbackFn) { |
551 | - var hasChilds; | |
552 | - // if node not already loaded | |
553 | - if (!this.isLoaded()) { | |
554 | - // call directFunction to load this node | |
555 | - AmdaAction.getTree({node: this.get('id'), nodeType: this.get('nodeType')}, function (res, e) { | |
556 | - callbackFn.call(this, res.length > 0 ? true : false); | |
557 | - }, this); | |
558 | - } | |
559 | - else { | |
637 | + // If node not already loaded | |
638 | + if (this.isLoaded()) { | |
560 | 639 | callbackFn.call(this, this.hasChildNodes()); |
640 | + } else { | |
641 | + // Call directFunction to load this node | |
642 | + AmdaAction.getTree({ | |
643 | + node: this.get('id'), | |
644 | + nodeType: this.get('nodeType') | |
645 | + }, function (res) { | |
646 | + callbackFn.call(this, res.length > 0); | |
647 | + }, this); | |
561 | 648 | } |
562 | 649 | }, |
563 | 650 | |
564 | 651 | /** |
565 | - * this method is used to display a confirmation message | |
652 | + * This method is used to display a confirmation message | |
653 | + * @param {boolean} isNotEmptyDir true if the directory is not empty. | |
654 | + * @returns {void} | |
566 | 655 | */ |
567 | 656 | confirmDirectoryDeletion: function (isNotEmptyDir) { |
568 | - // if this is a non-empty directory | |
657 | + var ConfirmMsg = 'The target is a non-empty directory!<br>Do you want to continue and also delete its content?'; | |
658 | + // If this is a non-empty directory | |
569 | 659 | if (isNotEmptyDir) { |
570 | 660 | // Prompt to the user if he also wants to delete its content |
571 | - Ext.Msg.confirm('non-empty directory', 'The target is a non-empty directory!<br>Do you want to continue and also delete its content?', function (btn, text) { | |
661 | + Ext.Msg.confirm('non-empty directory', ConfirmMsg, function (btn, text) { | |
572 | 662 | if (btn == 'yes') { |
573 | - // do delete | |
663 | + // Do delete | |
574 | 664 | this.realDelete(); |
575 | 665 | } |
576 | 666 | }, this); |
577 | - } | |
578 | - else { | |
667 | + } else { | |
579 | 668 | this.realDelete(); |
580 | 669 | } |
581 | 670 | }, |
582 | 671 | |
583 | 672 | /* |
584 | - * Call the extDirect method to delete parameter | |
585 | - * Callback method needed to execute node deletion in tree if id in result or to show error msg | |
586 | - */ | |
673 | + * Call the extDirect method to delete parameter | |
674 | + * Callback method needed to execute node deletion in tree if id in result or to show error msg | |
675 | + */ | |
587 | 676 | realDelete: function () { |
588 | 677 | AmdaAction.deleteObject({ |
589 | 678 | id: this.get('id'), |
590 | 679 | leaf: this.isLeaf(), |
591 | 680 | nodeType: this.get('nodeType') |
592 | 681 | }, function (res, e) { |
593 | - //TODO proper errors handling | |
594 | - // node deletion in tree | |
595 | - if (res) { // if success | |
682 | + var me, moduleId; | |
683 | + me = this; | |
684 | + | |
685 | + // Node deletion in tree - TODO proper errors handling | |
686 | + | |
687 | + // If success | |
688 | + if (res) { | |
596 | 689 | if (res.id) { |
597 | - //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | |
690 | + | |
691 | + /* | |
692 | + * Ext.Msg.show({ | |
693 | + * title:'Warning', | |
694 | + * msg: 'Requests with parameter '+node.data.text+' are deleted', | |
695 | + * icon: Ext.MessageBox.ERROR, | |
696 | + * buttons: Ext.Msg.OK | |
697 | + * }); | |
698 | + */ | |
598 | 699 | if (this.parentNode) { |
599 | 700 | if (this.isLeaf()) { |
600 | - var moduleId = this.get('moduleId'); | |
601 | - // if really interactive node | |
701 | + moduleId = this.get('moduleId'); | |
702 | + // If really interactive node | |
602 | 703 | if (moduleId) { |
603 | - var me = this; | |
604 | 704 | myDesktopApp.getLoadedModule(moduleId, true, function (module) { |
605 | - var editedNode = module.getLinkedNode(); | |
606 | - // file node is not linked directly to the module | |
607 | - var isThisFile = false; | |
705 | + var editedNode, isThisFile, linkedNodes, newNode, tabPanel; | |
706 | + editedNode = module.getLinkedNode(); | |
707 | + // File node is not linked directly to the module | |
708 | + isThisFile = false; | |
608 | 709 | |
609 | - if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') | |
610 | - if (editedNode.get('fileObject').get('fileName') == me.get('text')) | |
710 | + if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') { | |
711 | + if (editedNode.get('fileObject').get('fileName') == me.get('text')) { | |
611 | 712 | isThisFile = true; |
713 | + } | |
714 | + } | |
612 | 715 | |
613 | 716 | if (me.$className == 'amdaModel.DerivedParamNode') { |
614 | - var obj = { | |
615 | - paramId: 'ws_' + me.get('text') | |
616 | - }; | |
617 | - AmdaAction.compilParamDelete(obj); | |
717 | + AmdaAction.compilParamDelete({paramId: 'ws_' + me.get('text')}); | |
618 | 718 | } |
619 | 719 | |
620 | 720 | if (editedNode === me || isThisFile) { |
621 | - var newNode = Ext.ModelManager.create({leaf: true}, me.$className); | |
622 | - // several tabs could be connected to one node | |
721 | + newNode = Ext.ModelManager.create({leaf: true}, me.$className); | |
722 | + // Several tabs could be connected to one node | |
623 | 723 | if (moduleId === myDesktopApp.dynamicModules.plot.id) { |
624 | - var linkedNodes = module.linkedNodes; | |
724 | + linkedNodes = module.linkedNodes; | |
625 | 725 | |
626 | 726 | if (linkedNodes) { |
627 | 727 | linkedNodes.each(function (key, value) { |
628 | 728 | if (value === me) { |
629 | 729 | linkedNodes.replace(key, newNode); |
630 | - var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | |
730 | + tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | |
631 | 731 | tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); |
632 | 732 | } |
633 | 733 | }, me); |
... | ... | @@ -638,141 +738,151 @@ Ext.define('amdaModel.InteractiveNode', { |
638 | 738 | }); |
639 | 739 | } |
640 | 740 | } |
641 | - //update mask info in myData | |
741 | + // Update mask info in myData | |
642 | 742 | if (res.maskDesc && !res.maskDeleted) { |
643 | 743 | this.parentNode.set('info', res.maskDesc); |
644 | 744 | this.updateMyDataParam(res.mask, res.maskDesc); |
645 | 745 | } |
646 | 746 | this.remove(); |
647 | 747 | } |
648 | - //TODO Several special node-dependent actions - to move to node functions.. | |
649 | - // nodes of another nodeType to be deleted as they depend on deleted node | |
748 | + | |
749 | + /* | |
750 | + *TODO Several special node-dependent actions - to move to node functions.. | |
751 | + * nodes of another nodeType to be deleted as they depend on deleted node | |
752 | + */ | |
650 | 753 | if (res.params) { |
651 | 754 | this.deleteDependence(res.params); |
652 | - //TODO reset | |
755 | + // TODO reset | |
653 | 756 | } |
654 | - // mask was deleted or updated - to update mydata tree | |
757 | + // Mask was deleted or updated - to update mydata tree | |
655 | 758 | if (res.maskDeleted) { |
656 | 759 | this.updateMyData(); |
657 | 760 | } |
658 | - } | |
659 | - else { | |
761 | + } else { | |
660 | 762 | myDesktopApp.warningMsg(res.error); |
661 | 763 | } |
662 | - } | |
663 | - else { | |
764 | + } else { | |
664 | 765 | myDesktopApp.errorMsg(e.message); |
665 | 766 | } |
666 | 767 | }, this); |
667 | 768 | }, |
668 | 769 | |
669 | - /* | |
670 | - * Delete musti selection | |
671 | - */ | |
770 | + /** | |
771 | + * Delete multi selection | |
772 | + * @returns {void} | |
773 | + */ | |
672 | 774 | deleteMulti: function () { |
673 | 775 | var selection = this.myGetOwnerTree().getSelectionModel().selected.items; |
674 | - alert(selection.length + ' to delete!'); | |
776 | + Ext.alert(selection.length + ' to delete!'); | |
675 | 777 | Ext.Array.each(selection, function (item, index, allItems) { |
676 | 778 | item.deleteNode(); |
677 | - }) | |
779 | + }); | |
678 | 780 | }, |
679 | 781 | |
680 | - /* | |
681 | - * Create Folder | |
682 | - */ | |
782 | + /** | |
783 | + * Create Folder | |
784 | + * @returns {void} | |
785 | + */ | |
683 | 786 | createDir: function () { |
684 | 787 | var me = this; |
685 | 788 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), function () { |
686 | 789 | var newNode = Ext.create(me.$className, |
687 | 790 | { |
688 | - leaf: false, nodeType: me.get('nodeType'), | |
791 | + leaf: false, | |
792 | + nodeType: me.get('nodeType'), | |
689 | 793 | text: amdaModel.AmdaNode.NEW_DIR_NAME, |
690 | 794 | children: [], |
691 | 795 | parentId: me.get('id') |
692 | 796 | }); |
693 | 797 | |
694 | - // insert the new node as a child of node | |
798 | + // Insert the new node as a child of node | |
695 | 799 | me.insertChild(0, newNode); |
696 | - // start text edition on this new directory node | |
800 | + // Start text edition on this new directory node | |
697 | 801 | me.expand(false); |
698 | 802 | newNode.expand(false); |
699 | 803 | |
700 | - // select the new node | |
804 | + // Select the new node | |
701 | 805 | me.myGetOwnerTree().getSelectionModel().select(newNode); |
702 | - // call the renameNode method for this new node | |
806 | + // Call the renameNode method for this new node | |
703 | 807 | newNode.renameNode(true); |
704 | 808 | }); |
705 | 809 | }, |
706 | 810 | |
707 | 811 | /* |
708 | - * | |
709 | - */ | |
812 | + * | |
813 | + */ | |
710 | 814 | createLeaf: function (contextNode) { |
711 | - // create new node with the same type than the contextNode | |
815 | + // Create new node with the same type than the contextNode | |
712 | 816 | var newNode = Ext.create(contextNode.$className, {leaf: true}); |
713 | 817 | |
714 | - // load the rootNode and recursively all its child nodes | |
818 | + // Load the rootNode and recursively all its child nodes | |
715 | 819 | amdaModel.InteractiveNode.preloadNodes(contextNode.getRootNode(), function () { |
716 | - // edit newNode into Parameter Module with node as contextNode | |
820 | + // Edit newNode into Parameter Module with node as contextNode | |
717 | 821 | newNode.editInModule(contextNode); |
718 | 822 | }); |
719 | 823 | }, |
720 | 824 | |
721 | 825 | renameNode: function (deleteOnFailure) { |
826 | + var item, me; | |
827 | + me = this; | |
722 | 828 | if (this.myGetOwnerTree()) { |
723 | - // load the rootNode and recursively all its child nodes if not already loaded | |
724 | - var me = this; | |
829 | + // Load the rootNode and recursively all its child nodes if not already loaded | |
725 | 830 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), function () { |
726 | - // fire the edition event on tree | |
727 | - var item = me.myGetOwnerTree().getSelectionModel().selected.items[0]; | |
831 | + // Fire the edition event on tree | |
832 | + item = me.myGetOwnerTree().getSelectionModel().selected.items[0]; | |
728 | 833 | item.deleteOnFailure = deleteOnFailure; |
729 | 834 | me.myGetOwnerTree().fireEvent('edition', me.myGetOwnerTree().view, item); |
730 | 835 | }); |
731 | - } | |
732 | - else { | |
836 | + } else { | |
733 | 837 | myDesktopApp.errorMsg('tree is undefined'); |
734 | 838 | } |
735 | 839 | }, |
736 | 840 | |
737 | - /* | |
738 | - * load the rootNode and recursively all its child nodes | |
739 | - * to know all names of DerivedParameters | |
740 | - */ | |
841 | + /** | |
842 | + * Load the rootNode and recursively all its child nodes to know all names of DerivedParameters | |
843 | + * @param {function} onReady On ready callback function | |
844 | + * @returns {void} | |
845 | + */ | |
741 | 846 | editLeaf: function (onReady) { |
742 | 847 | var me = this; |
743 | 848 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), function () { |
744 | 849 | if (me.get('object')) { |
745 | - // launch edition of parameter into parameter module | |
850 | + // Launch edition of parameter into parameter module | |
746 | 851 | me.editInModule(null, onReady); |
747 | - } | |
748 | - else { | |
749 | - // call the ext method to get the details of parameter | |
750 | - // the edition of real parameter is done into callback method getObjectCallback | |
751 | - if (onReady) | |
852 | + } else { | |
853 | + | |
854 | + /* | |
855 | + * Call the ext method to get the details of parameter | |
856 | + * the edition of real parameter is done into callback method getObjectCallback | |
857 | + */ | |
858 | + if (onReady) { | |
752 | 859 | me.onReady = onReady; |
860 | + } | |
753 | 861 | |
754 | 862 | AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); |
755 | 863 | } |
756 | 864 | }); |
757 | 865 | }, |
758 | 866 | |
759 | - /* | |
760 | - * | |
761 | - */ | |
867 | + /** | |
868 | + * Get object callback | |
869 | + * @param {object} result The result | |
870 | + * @param {object} remoteEvent ... | |
871 | + * @returns {void} | |
872 | + */ | |
762 | 873 | getObjectCallback: function (result, remoteEvent) { |
763 | 874 | var t = remoteEvent.getTransaction(); |
764 | 875 | |
765 | 876 | if (result) { |
766 | 877 | var paramObj = Ext.create(this.get('objectDataModel'), result); |
767 | - // set parameter into node | |
878 | + // Set parameter into node | |
768 | 879 | this.set('object', paramObj); |
769 | 880 | // Edition of parameter into parameter Module |
770 | 881 | this.editInModule(null, this.onReady); |
771 | - } | |
772 | - else { | |
882 | + } else { | |
773 | 883 | // EXCEPTION : parameter not found !? |
774 | - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | |
775 | - + this.get('name') + "' found!"); | |
884 | + myDesktopApp.errorMsg(t.action + '.' + t.method + ' : No parameter \'' + | |
885 | + this.get('name') + '\' found!'); | |
776 | 886 | } |
777 | 887 | } |
778 | 888 | }); | ... | ... |
js/app/views/ExplorerUI.js
... | ... | @@ -11,6 +11,8 @@ |
11 | 11 | * @author CDA |
12 | 12 | */ |
13 | 13 | |
14 | +/* global AmdaAction, amdaModel, myDesktopApp, amdaUI, MyTreeEditor */ | |
15 | + | |
14 | 16 | Ext.define('amdaUI.TreeToolColumn', { |
15 | 17 | extend: 'Ext.tree.Column', |
16 | 18 | alias: 'widget.treetoolcolumn', |
... | ... | @@ -18,52 +20,57 @@ Ext.define('amdaUI.TreeToolColumn', { |
18 | 20 | /** |
19 | 21 | * Add more tools here. These will be on the prototype for all TreeToolColumns |
20 | 22 | */ |
21 | - tools: { | |
22 | - 'info': 'js/resources/images/16x16/info_mini.png' | |
23 | - }, | |
23 | + tools: {info: 'js/resources/images/16x16/info_mini.png'}, | |
24 | 24 | |
25 | 25 | initComponent: function () { |
26 | 26 | var me = this; |
27 | + | |
27 | 28 | me.addEvents('toolclick'); |
28 | 29 | me.callParent(); |
29 | 30 | me.on('toolclick', me.toolHandler, me); |
30 | 31 | }, |
31 | 32 | |
32 | 33 | renderer: function (value, metaData, record, rowIdx, colIdx, store, view) { |
33 | - var toolCol = view.getHeaderAtIndex(colIdx); | |
34 | - | |
35 | - if (!toolCol.toolIsVisible(record)) return value; | |
36 | - | |
37 | - var toolId = 'tool-' + rowIdx + '-' + colIdx, | |
38 | - toolImg = toolCol.tools[toolCol.tool], | |
39 | - imgHtml = Ext.DomHelper.markup({ | |
40 | - id: toolId, | |
41 | - tag: 'img', | |
42 | - tooltype: toolCol.tool, | |
43 | - src: toolImg, | |
44 | - style: 'cursor:hand;' | |
45 | - }); | |
34 | + var imgHtml, | |
35 | + toolCol = view.getHeaderAtIndex(colIdx); | |
36 | + | |
37 | + if (!toolCol.toolIsVisible(record)) { | |
38 | + return value; | |
39 | + } | |
40 | + | |
41 | + imgHtml = Ext.DomHelper.markup({ | |
42 | + id: 'tool-' + rowIdx + '-' + colIdx, | |
43 | + tag: 'img', | |
44 | + tooltype: toolCol.tool, | |
45 | + src: toolCol.tools[toolCol.tool], | |
46 | + style: 'cursor:hand;' | |
47 | + }); | |
46 | 48 | |
47 | 49 | return value + ' ' + imgHtml; |
48 | 50 | }, |
49 | 51 | |
50 | 52 | processEvent: function (type, view, cell, recordIndex, cellIndex, e) { |
51 | - if (type === "click" && e.target.tagName === "IMG") { | |
52 | - var tooltype = e.target.getAttribute("tooltype"); | |
53 | - if (tooltype) | |
54 | - return this.fireEvent("toolclick", view, cell, recordIndex, cellIndex, e); | |
53 | + var toolType; | |
54 | + | |
55 | + if (type === 'click' && e.target.tagName === 'IMG') { | |
56 | + toolType = e.target.getAttribute('tooltype'); | |
57 | + if (toolType) { | |
58 | + return this.fireEvent('toolclick', view, cell, recordIndex, cellIndex, e); | |
59 | + } | |
55 | 60 | } |
56 | 61 | return this.fireEvent.apply(this, arguments); |
57 | 62 | }, |
58 | 63 | |
59 | 64 | /** |
60 | - * Override this when you add columns to the tree... see example below | |
65 | + * Override this when you add columns to the tree... see example below: | |
66 | + * | |
67 | + * ToolHandler: function() { | |
68 | + * Alert("override this"); | |
69 | + * } | |
70 | + * | |
71 | + * @returns {boolean} False | |
61 | 72 | */ |
62 | -// toolHandler: function() { | |
63 | -// alert("override this"); | |
64 | -// }, | |
65 | - | |
66 | - toolIsVisible: function (record) { | |
73 | + toolIsVisible: function () { | |
67 | 74 | return false; |
68 | 75 | } |
69 | 76 | }); |
... | ... | @@ -101,9 +108,10 @@ Ext.define('amdaUI.ExplorerUI', { |
101 | 108 | }, |
102 | 109 | |
103 | 110 | initComponent: function (config) { |
104 | - var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
111 | + var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id), | |
112 | + myConf; | |
105 | 113 | |
106 | - var myConf = { | |
114 | + myConf = { | |
107 | 115 | split: true, |
108 | 116 | width: '100%', |
109 | 117 | height: '100%', |
... | ... | @@ -111,16 +119,14 @@ Ext.define('amdaUI.ExplorerUI', { |
111 | 119 | border: true, |
112 | 120 | header: false, |
113 | 121 | defaults: { |
114 | - // applied to each contained panel | |
122 | + // Applied to each contained panel | |
115 | 123 | containerScroll: true |
116 | 124 | }, |
117 | 125 | stateful: true, |
118 | - //stateId: 'tp1', | |
126 | + // StateId: 'tp1', | |
119 | 127 | stateEvents: ['tabchange'], |
120 | 128 | getState: function () { |
121 | - return { | |
122 | - activeTab: this.items.findIndex('id', this.getActiveTab().id) | |
123 | - }; | |
129 | + return {activeTab: this.items.findIndex('id', this.getActiveTab().id)}; | |
124 | 130 | }, |
125 | 131 | applyState: function (s) { |
126 | 132 | this.setActiveTab(s.activeTab); |
... | ... | @@ -144,14 +150,10 @@ Ext.define('amdaUI.ExplorerUI', { |
144 | 150 | scope: this, |
145 | 151 | select: function (combo, records) { |
146 | 152 | AmdaAction.setCrtFilterId({id: records[0].get('id')}, function (result, e) { |
147 | - var t = e.getTransaction(); | |
148 | 153 | if (e.status) { |
149 | - if (result) { | |
150 | - var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
151 | - if (explorerModule) | |
152 | - explorerModule.setCrtFilter(); | |
153 | - } | |
154 | - else | |
154 | + if (result && explorerModule) { | |
155 | + explorerModule.setCrtFilter(); | |
156 | + } else { | |
155 | 157 | Ext.Msg.show({ |
156 | 158 | title: 'Filter', |
157 | 159 | msg: 'Cannot apply filter', |
... | ... | @@ -159,8 +161,8 @@ Ext.define('amdaUI.ExplorerUI', { |
159 | 161 | icon: Ext.Msg.ERROR, |
160 | 162 | buttons: Ext.Msg.OK |
161 | 163 | }); |
162 | - } | |
163 | - else { | |
164 | + } | |
165 | + } else { | |
164 | 166 | // FAILURE |
165 | 167 | Ext.Msg.show({ |
166 | 168 | title: 'Error System', |
... | ... | @@ -176,8 +178,11 @@ Ext.define('amdaUI.ExplorerUI', { |
176 | 178 | { |
177 | 179 | text: '', |
178 | 180 | iconCls: 'icon-parameters', |
179 | - tooltip: {text: 'Edit Filter', align: 'bl-tl'}, | |
180 | - handler: function (t) { | |
181 | + tooltip: { | |
182 | + text: 'Edit Filter', | |
183 | + align: 'bl-tl' | |
184 | + }, | |
185 | + handler: function () { | |
181 | 186 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.filters.id, true, function (module) { |
182 | 187 | module.createWindow(); |
183 | 188 | }); |
... | ... | @@ -186,12 +191,15 @@ Ext.define('amdaUI.ExplorerUI', { |
186 | 191 | { |
187 | 192 | text: '', |
188 | 193 | iconCls: 'icon-remover', |
189 | - tooltip: {text: 'Reset Filter', align: 'bl-tl'}, | |
190 | - handler: function (t) { | |
191 | - var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
194 | + tooltip: { | |
195 | + text: 'Reset Filter', | |
196 | + align: 'bl-tl' | |
197 | + }, | |
198 | + handler: function () { | |
192 | 199 | explorerModule.resetFilter(); |
193 | 200 | } |
194 | - }, '-', | |
201 | + }, | |
202 | + '-', | |
195 | 203 | { |
196 | 204 | xtype: 'displayfield', |
197 | 205 | fieldLabel: 'SortBy', |
... | ... | @@ -200,7 +208,10 @@ Ext.define('amdaUI.ExplorerUI', { |
200 | 208 | { |
201 | 209 | text: 'Name', |
202 | 210 | scope: this, |
203 | - tooltip: {text: 'Sort out AMDA DataBase Data by Mission Name', align: 'bl-tl'}, | |
211 | + tooltip: { | |
212 | + text: 'Sort out AMDA DataBase Data by Mission Name', | |
213 | + align: 'bl-tl' | |
214 | + }, | |
204 | 215 | pressed: true, |
205 | 216 | enableToggle: true, |
206 | 217 | toggleGroup: 'sorting', |
... | ... | @@ -209,8 +220,9 @@ Ext.define('amdaUI.ExplorerUI', { |
209 | 220 | tree.getStore().sort([ |
210 | 221 | { |
211 | 222 | sorterFn: function (o1, o2) { |
212 | - if (o1.get('nodeType') !== 'localParam') | |
223 | + if (o1.get('nodeType') !== 'localParam') { | |
213 | 224 | return; |
225 | + } | |
214 | 226 | |
215 | 227 | return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1; |
216 | 228 | } |
... | ... | @@ -222,7 +234,10 @@ Ext.define('amdaUI.ExplorerUI', { |
222 | 234 | { |
223 | 235 | text: 'Target', |
224 | 236 | scope: this, |
225 | - tooltip: {text: 'Sort out AMDA DataBase Data by Mission Main Target', align: 'bl-tl'}, | |
237 | + tooltip: { | |
238 | + text: 'Sort out AMDA DataBase Data by Mission Main Target', | |
239 | + align: 'bl-tl' | |
240 | + }, | |
226 | 241 | enableToggle: true, |
227 | 242 | toggleGroup: 'sorting', |
228 | 243 | handler: function () { |
... | ... | @@ -238,6 +253,7 @@ Ext.define('amdaUI.ExplorerUI', { |
238 | 253 | }, |
239 | 254 | |
240 | 255 | initTree: function (treeType) { |
256 | + var menu, store, tree, treeId; | |
241 | 257 | switch (treeType) { |
242 | 258 | case amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE: |
243 | 259 | treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID; |
... | ... | @@ -253,7 +269,7 @@ Ext.define('amdaUI.ExplorerUI', { |
253 | 269 | break; |
254 | 270 | } |
255 | 271 | |
256 | - var store = Ext.create('Ext.data.TreeStore', { | |
272 | + store = Ext.create('Ext.data.TreeStore', { | |
257 | 273 | root: { |
258 | 274 | expanded: true, |
259 | 275 | nodeType: treeType |
... | ... | @@ -263,25 +279,24 @@ Ext.define('amdaUI.ExplorerUI', { |
263 | 279 | { |
264 | 280 | direction: 'ASC', |
265 | 281 | sorterFn: function (o1, o2) { |
266 | - if (o1.get('nodeType') !== 'localParam') | |
282 | + if (o1.get('nodeType') !== 'localParam') { | |
267 | 283 | return; |
284 | + } | |
268 | 285 | |
269 | 286 | return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1; |
270 | 287 | } |
271 | 288 | } |
272 | 289 | ], |
273 | 290 | listeners: { |
274 | - beforeload: function (store, operation) { | |
275 | - store.proxy.extraParams = { | |
276 | - nodeType: operation.node.get('nodeType') | |
277 | - }; | |
291 | + beforeload: function (_store, operation) { | |
292 | + _store.proxy.extraParams = {nodeType: operation.node.get('nodeType')}; | |
278 | 293 | } |
279 | 294 | } |
280 | 295 | }); |
281 | 296 | |
282 | - var menu = new Ext.menu.Menu(); | |
297 | + menu = new Ext.menu.Menu(); | |
283 | 298 | |
284 | - var tree = Ext.create('Ext.tree.Panel', { | |
299 | + tree = Ext.create('Ext.tree.Panel', { | |
285 | 300 | id: treeId, |
286 | 301 | title: treeType, |
287 | 302 | store: store, |
... | ... | @@ -289,7 +304,7 @@ Ext.define('amdaUI.ExplorerUI', { |
289 | 304 | animate: false, |
290 | 305 | hideHeaders: true, |
291 | 306 | selModel: Ext.create('Ext.selection.TreeModel', { |
292 | - // ignoreRightMouseSelection: true, | |
307 | + // IgnoreRightMouseSelection: true, | |
293 | 308 | mode: 'MULTI' |
294 | 309 | }), |
295 | 310 | viewConfig: { |
... | ... | @@ -297,7 +312,7 @@ Ext.define('amdaUI.ExplorerUI', { |
297 | 312 | ptype: 'treeviewdragdrop', |
298 | 313 | enableDrag: true, |
299 | 314 | enableDrop: true, |
300 | - //TODO - BRE - Wait a fix for drag&drop issue | |
315 | + // TODO - BRE - Wait a fix for drag&drop issue | |
301 | 316 | ddGroup: 'explorerTree', |
302 | 317 | pluginId: 'ddplugin', |
303 | 318 | |
... | ... | @@ -326,8 +341,7 @@ Ext.define('amdaUI.ExplorerUI', { |
326 | 341 | // Respect the allowDrop field on Tree nodes |
327 | 342 | if (position === 'append' && targetNode.get('allowDrop') === false) { |
328 | 343 | return false; |
329 | - } | |
330 | - else if (position != 'append' && targetNode.parentNode.get('allowDrop') === false) { | |
344 | + } else if (position != 'append' && targetNode.parentNode.get('allowDrop') === false) { | |
331 | 345 | return false; |
332 | 346 | } |
333 | 347 | // If the target record is in the dragged dataset, then invalid drop |
... | ... | @@ -335,54 +349,61 @@ Ext.define('amdaUI.ExplorerUI', { |
335 | 349 | return false; |
336 | 350 | } |
337 | 351 | // |
338 | - if (dataLength > 1) | |
352 | + if (dataLength > 1) { | |
339 | 353 | return false; |
354 | + } | |
340 | 355 | |
341 | 356 | var draggedRecord = draggedRecords[0]; |
342 | 357 | // |
343 | 358 | switch (targetNode.data.nodeType) { |
344 | - case 'localParam' : | |
345 | - case 'remoteParam' : | |
346 | - case 'remoteSimuParam' : | |
347 | - case 'myData' : | |
359 | + case 'localParam': | |
360 | + case 'remoteParam': | |
361 | + case 'remoteSimuParam': | |
362 | + case 'myData': | |
348 | 363 | return false; |
349 | - default : | |
350 | - if (draggedRecord.data.id == targetNode.data.nodeType + '-treeRootNode') | |
364 | + default: | |
365 | + if (draggedRecord.data.id == targetNode.data.nodeType + '-treeRootNode') { | |
351 | 366 | return false; |
352 | - if ((position == 'before') && (targetNode.data.id == targetNode.data.nodeType + '-treeRootNode')) | |
367 | + } | |
368 | + if (position == 'before' && targetNode.data.id == targetNode.data.nodeType + '-treeRootNode') { | |
353 | 369 | return false; |
354 | - return (draggedRecord.data.nodeType == targetNode.data.nodeType); | |
370 | + } | |
371 | + return draggedRecord.data.nodeType == targetNode.data.nodeType; | |
355 | 372 | } |
356 | 373 | return false; |
357 | 374 | }, |
358 | 375 | onViewRender: function (view) { |
359 | 376 | var me = this; |
360 | 377 | |
361 | - view.on('itemupdate', function (record, index, node, opts) { | |
362 | - var forceHide = false; | |
363 | - var crtRec = record.parentNode; | |
378 | + view.on('itemupdate', function (record) { | |
379 | + var forceHide = false, | |
380 | + crtRec = record.parentNode; | |
381 | + | |
364 | 382 | while (crtRec && !forceHide) { |
365 | - if (crtRec.get('filtered')) | |
383 | + if (crtRec.get('filtered')) { | |
366 | 384 | forceHide = crtRec.get('filtered'); |
385 | + } | |
367 | 386 | crtRec = crtRec.parentNode; |
368 | 387 | } |
369 | 388 | tree.setNodesVisibility(record, forceHide); |
370 | 389 | tree.applyDisableToNode(record); |
371 | 390 | }); |
372 | 391 | |
373 | - view.on('itemadd', function (records, index, node, opts) { | |
392 | + view.on('itemadd', function (records) { | |
374 | 393 | Ext.each(records, function (rec) { |
375 | 394 | tree.applyFilterToNode(rec); |
376 | 395 | tree.applyDisableToNode(rec); |
377 | 396 | }); |
378 | 397 | }); |
379 | 398 | |
380 | - view.on('afteritemexpand', function (record, index, node, opts) { | |
381 | - var forceHide = false; | |
382 | - var crtRec = record.parentNode; | |
399 | + view.on('afteritemexpand', function (record) { | |
400 | + var crtRec, forceHide; | |
401 | + forceHide = false; | |
402 | + crtRec = record.parentNode; | |
383 | 403 | while (crtRec && !forceHide) { |
384 | - if (crtRec.get('filtered')) | |
404 | + if (crtRec.get('filtered')) { | |
385 | 405 | forceHide = crtRec.get('filtered'); |
406 | + } | |
386 | 407 | crtRec = crtRec.parentNode; |
387 | 408 | |
388 | 409 | } |
... | ... | @@ -419,21 +440,24 @@ Ext.define('amdaUI.ExplorerUI', { |
419 | 440 | beforedrop: function (node, data, overModel, dropPosition) { |
420 | 441 | var parentId; |
421 | 442 | switch (dropPosition) { |
422 | - case 'append' : | |
423 | - if (overModel.isLeaf()) | |
443 | + case 'append': | |
444 | + if (overModel.isLeaf()) { | |
424 | 445 | parentId = overModel.parentNode.get('id'); |
425 | - else | |
446 | + } else { | |
426 | 447 | parentId = overModel.get('id'); |
448 | + } | |
427 | 449 | |
428 | 450 | if (!overModel.isExpanded() && overModel.isExpandable()) { |
429 | 451 | myDesktopApp.warningMsg('Please open the folder before node adding'); |
430 | 452 | return false; |
431 | 453 | } |
432 | 454 | break; |
433 | - case 'before' : | |
434 | - case 'after' : | |
455 | + case 'before': | |
456 | + case 'after': | |
435 | 457 | parentId = overModel.parentNode.get('id'); |
436 | 458 | break; |
459 | + default: | |
460 | + break; | |
437 | 461 | } |
438 | 462 | |
439 | 463 | Ext.each(data.records, function (rec) { |
... | ... | @@ -449,8 +473,7 @@ Ext.define('amdaUI.ExplorerUI', { |
449 | 473 | |
450 | 474 | return false; |
451 | 475 | } |
452 | - } | |
453 | - else { | |
476 | + } else { | |
454 | 477 | Ext.Msg.show({ |
455 | 478 | title: 'Drop is impossible', |
456 | 479 | msg: 'Cannot connect to the server', |
... | ... | @@ -469,66 +492,60 @@ Ext.define('amdaUI.ExplorerUI', { |
469 | 492 | }, |
470 | 493 | listeners: { |
471 | 494 | itemmouseenter: function (view, record, item) { |
472 | - if (record.get('isParameter')) { | |
473 | - var el = Ext.get(item), | |
474 | - td = el.down('td > div'); | |
475 | - td.setStyle('cursor', 'crosshair'); | |
476 | - } | |
477 | - else { | |
478 | - var el = Ext.get(item), | |
479 | - td = el.down('td > div'); | |
480 | - td.setStyle('cursor', 'pointer'); | |
481 | - } | |
495 | + Ext.get(item).down('td > div').setStyle('cursor', record.get('isParameter') ? 'pointer' : 'crosshair'); | |
482 | 496 | }, |
483 | 497 | |
484 | 498 | itemcontextmenu: function (view, rec, item, index, e) { |
499 | + var menuItems; | |
500 | + | |
485 | 501 | // Add record to selection model |
486 | 502 | view.ownerCt.getSelectionModel().select(rec); |
487 | 503 | |
488 | - // block other events | |
504 | + // Block other events | |
489 | 505 | e.stopEvent(); |
490 | 506 | |
491 | - // clear menu items | |
507 | + // Clear menu items | |
492 | 508 | menu.removeAll(); |
493 | - var menuItems; | |
494 | 509 | |
495 | - // if it's a single selection | |
510 | + // If it's a single selection | |
496 | 511 | if (view.ownerCt.getSelectionModel().selected.length === 1) { |
497 | - // get items menu corresponding to right clicked record | |
512 | + // Get items menu corresponding to right clicked record | |
498 | 513 | menuItems = rec.getContextMenuItems(this); |
499 | 514 | |
500 | 515 | } else if (view.ownerCt.getSelectionModel().selected.length > 1) { |
501 | - // get items menu corresponding to right clicked record | |
516 | + // Get items menu corresponding to right clicked record | |
502 | 517 | menuItems = rec.getContextMenuMultiItems(this); |
503 | 518 | } |
504 | - // if there's at least one item menu | |
519 | + // If there's at least one item menu | |
505 | 520 | if (menuItems && menuItems.length) { |
506 | - // add the items | |
521 | + // Add the items | |
507 | 522 | menu.add(menuItems); |
508 | - // add listener on right clicked record | |
509 | - var onRecordClick = function (menu, item, e, eOpts) { | |
523 | + | |
524 | + // Add listener on right clicked record | |
525 | + var onRecordClick = function (menu, item, e) { | |
510 | 526 | if (this.myGetOwnerTree().getSelectionModel().isSelected(this)) { |
511 | - //Dispatch click event to the record | |
527 | + // Dispatch click event to the record | |
512 | 528 | this.onMenuItemClick(menu, item, e); |
513 | 529 | } |
514 | - //Remove old click listener | |
530 | + // Remove old click listener | |
515 | 531 | menu.removeListener('click', onRecordClick, this); |
516 | 532 | }; |
517 | 533 | |
518 | 534 | menu.addListener('click', onRecordClick, rec); |
519 | - // then show menu | |
535 | + // Then show menu | |
520 | 536 | menu.showAt(e.getXY()); |
521 | 537 | } |
522 | 538 | }, |
523 | 539 | |
524 | 540 | itemdblclick: function (view, record, item, index, event) { |
541 | + var zmgr, winId; | |
542 | + | |
525 | 543 | event.stopEvent(); |
526 | - // first check if it is for SAVE-START-STOP plugin... | |
544 | + // First check if it is for SAVE-START-STOP plugin... | |
527 | 545 | if (Ext.PluginManager.getCount() > 0 && |
528 | 546 | record.get('nodeType') == amdaModel.TimeTableNode.nodeType && record.isLeaf()) { |
529 | - var zmgr = myDesktopApp.desktop.getDesktopZIndexManager(); | |
530 | - var winActive = zmgr.getActive(); | |
531 | - var winId = winActive.getId(); | |
547 | + zmgr = myDesktopApp.desktop.getDesktopZIndexManager(); | |
548 | + winId = zmgr.getActive().getId(); | |
532 | 549 | if (winId == 'explorer-win') { |
533 | 550 | zmgr.eachTopDown(function (win) { |
534 | 551 | var id = win.getId(); |
... | ... | @@ -540,58 +557,56 @@ Ext.define('amdaUI.ExplorerUI', { |
540 | 557 | } |
541 | 558 | } |
542 | 559 | |
543 | - if (record.get('nodeType') == 'remoteParam' && !record.isLeaf() | |
544 | - && !record.get('isParameter')) { | |
560 | + if (record.get('nodeType') == 'remoteParam' && !record.isLeaf() && | |
561 | + !record.get('isParameter')) { | |
545 | 562 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { |
546 | 563 | module.createWindow(record.getBaseId()); |
547 | 564 | }); |
548 | 565 | } |
549 | 566 | |
550 | - if (record.isLeaf() || record.data.isParameter) | |
567 | + if (record.isLeaf() || record.data.isParameter) { | |
551 | 568 | switch (record.get('nodeType')) { |
552 | - case 'myData' : | |
553 | - case 'myDataParam' : | |
554 | - case 'derivedParam' : | |
555 | - case 'timeTable' : | |
556 | - case 'sharedtimeTable' : | |
557 | - case 'sharedcatalog' : | |
558 | - case 'catalog' : | |
559 | - case 'request' : | |
560 | - case 'condition' : | |
569 | + case 'myData': | |
570 | + case 'myDataParam': | |
571 | + case 'derivedParam': | |
572 | + case 'timeTable': | |
573 | + case 'sharedtimeTable': | |
574 | + case 'sharedcatalog': | |
575 | + case 'catalog': | |
576 | + case 'request': | |
577 | + case 'condition': | |
561 | 578 | record.editLeaf(); |
562 | 579 | break; |
563 | - case 'localParam' : | |
580 | + case 'localParam': | |
564 | 581 | case 'remoteParam': |
565 | 582 | case 'remoteSimuParam': |
566 | 583 | record.createAlias(record); |
567 | 584 | break; |
568 | - case 'bkgWorks' : | |
585 | + case 'bkgWorks': | |
569 | 586 | if (!record.get('object')) { |
570 | 587 | AmdaAction.getObject(record.get('id'), record.get('nodeType'), record.getObjectCallback, record); |
588 | + } else if (record.get('status') == 'done') { | |
589 | + // IsInteractive = true, isNewTab = false | |
590 | + record.editNode(true, false); | |
591 | + } else { | |
592 | + myDesktopApp.infoMsg('Job Status: ' + record.get('status')); | |
571 | 593 | } |
572 | - else { | |
573 | - if (record.get('status') == 'done') { | |
574 | - var isInteractive = false; | |
575 | - var isNewTab = true; | |
576 | - record.editNode(isNewTab, isInteractive); | |
577 | - } | |
578 | - else { | |
579 | - myDesktopApp.infoMsg('Job Status: ' + record.get('status')); | |
580 | - } | |
581 | - } | |
594 | + break; | |
595 | + default: | |
582 | 596 | break; |
583 | 597 | } |
598 | + } | |
584 | 599 | }, |
585 | 600 | |
586 | - beforeselect: function (view, node, index, options) { | |
587 | - // if there's at least one node already selected | |
588 | - if (view.selected.length | |
589 | - //AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf | |
590 | - && (node.get('nodeType') !== view.selected.items[0].get('nodeType') || !view.selected.items[0].isLeaf()) | |
601 | + beforeselect: function (view, node) { | |
602 | + // If there's at least one node already selected | |
603 | + if (view.selected.length && | |
604 | + // AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf | |
605 | + (node.get('nodeType') !== view.selected.items[0].get('nodeType') || !view.selected.items[0].isLeaf()) || | |
591 | 606 | // OR the node which is beeing selected has no nodeType OR it isn't a leaf OR |
592 | - || !node.get('nodeType') || !node.isLeaf() | |
607 | + !node.get('nodeType') || !node.isLeaf() | |
593 | 608 | ) { |
594 | - // clear old selection | |
609 | + // Clear old selection | |
595 | 610 | view.deselectAll(); |
596 | 611 | } |
597 | 612 | }, |
... | ... | @@ -604,20 +619,23 @@ Ext.define('amdaUI.ExplorerUI', { |
604 | 619 | // Each grid row causes its own seperate show and hide. |
605 | 620 | delegate: view.itemSelector, |
606 | 621 | dismissDelay: 0, |
607 | - // showDelay: 100, | |
608 | - // anchor: 'left', | |
609 | - // Moving within the row should not hide the tip. | |
622 | + | |
623 | + /* | |
624 | + * ShowDelay: 100, | |
625 | + * anchor: 'left', | |
626 | + * Moving within the row should not hide the tip. | |
627 | + */ | |
610 | 628 | trackMouse: true, |
611 | 629 | autoRender: true, |
612 | 630 | listeners: { |
613 | 631 | // Change content dynamically depending on which element triggered the show. |
614 | - beforeshow: function updateTipBody(tip) { | |
632 | + beforeshow: function updateTipBody (tip) { | |
633 | + var info; | |
615 | 634 | if (view.getRecord(tip.triggerElement)) { |
616 | - var info = view.getRecord(tip.triggerElement).get('info'); | |
635 | + info = view.getRecord(tip.triggerElement).get('info'); | |
617 | 636 | if (!info || info == '') { |
618 | 637 | tip.addCls('hide'); |
619 | - } | |
620 | - else { | |
638 | + } else { | |
621 | 639 | tip.removeCls('hide'); |
622 | 640 | tip.update(info); |
623 | 641 | } |
... | ... | @@ -626,61 +644,63 @@ Ext.define('amdaUI.ExplorerUI', { |
626 | 644 | } |
627 | 645 | }); |
628 | 646 | }, |
629 | - // if remote base is empty - open interoperability module | |
647 | + // If remote base is empty - open interoperability module | |
630 | 648 | itemexpand: function (node) { |
631 | - if (node.get('nodeType') == amdaModel.RemoteParamNode.nodeType | |
632 | - && node.getDepth() == 3 && !node.hasChildNodes()) { | |
649 | + if (node.get('nodeType') == amdaModel.RemoteParamNode.nodeType && | |
650 | + node.getDepth() == 3 && !node.hasChildNodes()) { | |
633 | 651 | node.addData(); |
634 | 652 | } |
635 | 653 | }, |
636 | 654 | scope: this |
637 | 655 | }, |
638 | 656 | |
639 | - hideHeaders: true, | |
640 | - // must define a column with a field to enable editor | |
657 | + // Must define a column with a field to enable editor | |
641 | 658 | columns: [ |
642 | 659 | { |
643 | 660 | xtype: 'treetoolcolumn', |
644 | 661 | text: 'Name', |
645 | 662 | flex: 1, |
646 | 663 | dataIndex: 'text', |
647 | - tool: 'info', // this references the "tools" object on the prototype | |
664 | + // This references the "tools" object on the prototype | |
665 | + tool: 'info', | |
648 | 666 | toolHandler: function (view, cell, recordIndex, cellIndex, e) { |
649 | - var tooltype = e.target.getAttribute("tooltype"); | |
650 | 667 | var record = view.store.getAt(recordIndex); |
651 | - switch (tooltype) { | |
652 | - case 'info' : | |
668 | + switch (e.target.getAttribute('tooltype')) { | |
669 | + case 'info': | |
653 | 670 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function (module) { |
654 | 671 | module.createWindow(record.get('help'), record.get('text')); |
655 | 672 | }); |
656 | 673 | break; |
674 | + default: | |
675 | + break; | |
657 | 676 | } |
658 | 677 | }, |
659 | 678 | toolIsVisible: function (record) { |
660 | 679 | |
661 | 680 | switch (record.get('nodeType')) { |
662 | - case 'localParam' : | |
663 | - case 'remoteParam' : | |
664 | - case 'remoteSimuParam' : | |
665 | - | |
681 | + case 'localParam': | |
682 | + case 'remoteParam': | |
683 | + case 'remoteSimuParam': | |
666 | 684 | return record.get('help') != ''; |
685 | + default: | |
686 | + break; | |
667 | 687 | } |
668 | 688 | return false; |
669 | 689 | }, |
670 | 690 | field: { |
671 | 691 | validFlag: true, |
672 | 692 | listeners: { |
673 | - change: function (field, newValue, oldValue, eOpts) { | |
674 | - var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
675 | - var explUI = explModule.getUiContent(); | |
676 | - var activeTreePanel = explUI.getActiveTab(); | |
693 | + change: function (field, newValue) { | |
694 | + var editedNode, explModule; | |
695 | + | |
696 | + explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
697 | + editedNode = explModule.getUiContent().getActiveTab().getSelectionModel().selected.items[0]; | |
677 | 698 | |
678 | - var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; | |
679 | 699 | if (editedNode) { |
680 | 700 | editedNode.isValidName(newValue, function (res) { |
681 | 701 | var validFlag = true; |
682 | 702 | if (newValue === amdaModel.AmdaNode.NEW_DIR_NAME) { |
683 | - validFlag = 'Field is not modified' | |
703 | + validFlag = 'Field is not modified'; | |
684 | 704 | } else if (!res) { |
685 | 705 | validFlag = 'Error during object validation'; |
686 | 706 | } else if (!res.valid) { |
... | ... | @@ -728,8 +748,9 @@ Ext.define('amdaUI.ExplorerUI', { |
728 | 748 | setNodesVisibility: function (node, forceHide) { |
729 | 749 | var isFiltered = node.get('filtered'); |
730 | 750 | |
731 | - for (var i = 0; i < node.childNodes.length; i++) | |
751 | + for (var i = 0; i < node.childNodes.length; i++) { | |
732 | 752 | this.setNodesVisibility(node.childNodes[i], forceHide || isFiltered); |
753 | + } | |
733 | 754 | |
734 | 755 | this.setNodeVisibility(node, !(forceHide || isFiltered)); |
735 | 756 | }, |
... | ... | @@ -742,34 +763,37 @@ Ext.define('amdaUI.ExplorerUI', { |
742 | 763 | if (isVisible) { |
743 | 764 | viewNode.show(); |
744 | 765 | this.applyDisableToNode(record); |
745 | - } | |
746 | - else | |
766 | + } else { | |
747 | 767 | viewNode.hide(); |
768 | + } | |
748 | 769 | } |
749 | 770 | }, |
750 | 771 | |
751 | 772 | applyFilterToNode: function (node) { |
752 | - if (!node) | |
773 | + var filter, isFiltered, pos; | |
774 | + | |
775 | + if (!node) { | |
753 | 776 | return; |
777 | + } | |
754 | 778 | |
755 | - var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
779 | + filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
756 | 780 | |
757 | 781 | switch (node.get('nodeType')) { |
758 | - case 'localParam' : | |
759 | - if (!filter || !filter['param']) { | |
760 | - //no filter applied | |
782 | + case 'localParam': | |
783 | + if (!filter || !filter.param) { | |
784 | + // No filter applied | |
761 | 785 | node.set('filtered', false); |
762 | 786 | return; |
763 | 787 | } |
764 | - var pos = node.get('depth') - 3; //depth from local param root node | |
788 | + // Depth from local param root node | |
789 | + pos = node.get('depth') - 3; | |
765 | 790 | if (pos < 0 || pos > 2) { |
766 | 791 | node.set('filtered', false); |
767 | 792 | return; |
768 | 793 | } |
769 | - var isFiltered = true; | |
770 | - for (var i = 0; i < filter['param'].length; i++) { | |
771 | - s = filter['param'][i].split(';'); | |
772 | - if (node.get('id') == s[pos]) { | |
794 | + isFiltered = true; | |
795 | + for (var i = 0; i < filter.param.length; i++) { | |
796 | + if (node.get('id') == filter.param[i].split(';')[pos]) { | |
773 | 797 | isFiltered = false; |
774 | 798 | break; |
775 | 799 | } |
... | ... | @@ -777,53 +801,52 @@ Ext.define('amdaUI.ExplorerUI', { |
777 | 801 | node.set('filtered', isFiltered); |
778 | 802 | break; |
779 | 803 | |
780 | - case 'remoteSimuParam' : | |
781 | - if (!filter || !filter['simu']) { | |
782 | - //no filter applied | |
804 | + case 'remoteSimuParam': | |
805 | + if (!filter || !filter.simu) { | |
806 | + // No filter applied | |
783 | 807 | node.set('filtered', false); |
784 | 808 | return; |
785 | 809 | } |
786 | - var pos = node.get('depth') - 3; //depth from remote param root node | |
787 | - | |
810 | + // Depth from remote param root node | |
811 | + pos = node.get('depth') - 3; | |
788 | 812 | if (pos < 0 || pos > 5) { |
789 | 813 | node.set('filtered', false); |
790 | 814 | return; |
791 | 815 | } |
792 | - var isFiltered = true; | |
793 | - | |
794 | - for (var i = 0; i < filter['simu'].length; i++) { | |
795 | - s = filter['simu'][i].split(';'); | |
796 | - | |
797 | - if (node.get('id') == s[pos]) { | |
816 | + isFiltered = true; | |
817 | + for (var i = 0; i < filter.simu.length; i++) { | |
818 | + if (node.get('id') == filter.simu[i].split(';')[pos]) { | |
798 | 819 | isFiltered = false; |
799 | 820 | break; |
800 | 821 | } |
801 | 822 | } |
802 | 823 | node.set('filtered', isFiltered); |
803 | 824 | break; |
804 | - /*case 'alias' : | |
805 | - if (!this.localParamFilter.result || this.localParamFilter.id == "" || | |
806 | - !node.isLeaf()) { | |
807 | - //no filter applied | |
808 | - node.set('filtered',false); | |
809 | - return; | |
810 | - } | |
811 | - var crtParam = node.get('id'); | |
812 | - crtParam = crtParam.replace('alias_',''); | |
813 | - crtParam = crtParam.replace(/_/g,':'); | |
814 | - var isFiltered = true; | |
815 | - for (var i = 0; i < this.localParamFilter.result.length; i++) { | |
816 | - s = this.localParamFilter.result[i].split(';'); | |
817 | - console.log(s[2]); | |
818 | - if (crtParam == s[2]) { | |
819 | - isFiltered = false; | |
820 | - break; | |
821 | - } | |
822 | - } | |
823 | - node.set('filtered',isFiltered); | |
824 | - break;*/ | |
825 | - default : | |
826 | - return; | |
825 | + | |
826 | + /* | |
827 | + * Case 'alias': | |
828 | + * if (!this.localParamFilter.result || this.localParamFilter.id == "" || !node.isLeaf()) { | |
829 | + * // No filter applied | |
830 | + * node.set('filtered',false); | |
831 | + * return; | |
832 | + * } | |
833 | + * var crtParam = node.get('id'); | |
834 | + * crtParam = crtParam.replace('alias_',''); | |
835 | + * crtParam = crtParam.replace(/_/g,':'); | |
836 | + * var isFiltered = true; | |
837 | + * for (var i = 0; i < this.localParamFilter.result.length; i++) { | |
838 | + * s = this.localParamFilter.result[i].split(';'); | |
839 | + * console.log(s[2]); | |
840 | + * if (crtParam == s[2]) { | |
841 | + * isFiltered = false; | |
842 | + * break; | |
843 | + * } | |
844 | + * } | |
845 | + * node.set('filtered',isFiltered); | |
846 | + * break; | |
847 | + */ | |
848 | + default: | |
849 | + | |
827 | 850 | } |
828 | 851 | }, |
829 | 852 | |
... | ... | @@ -835,8 +858,10 @@ Ext.define('amdaUI.ExplorerUI', { |
835 | 858 | }, |
836 | 859 | |
837 | 860 | applyDisableToNode: function (node) { |
838 | - var crtNode = node; | |
839 | - var disable = false; | |
861 | + var crtNode, disable, viewNode; | |
862 | + | |
863 | + crtNode = node; | |
864 | + disable = false; | |
840 | 865 | |
841 | 866 | do { |
842 | 867 | if (crtNode.get('disable')) { |
... | ... | @@ -847,7 +872,7 @@ Ext.define('amdaUI.ExplorerUI', { |
847 | 872 | } while (crtNode); |
848 | 873 | |
849 | 874 | |
850 | - var viewNode = Ext.fly(tree.getView().getNode(node)); | |
875 | + viewNode = Ext.fly(tree.getView().getNode(node)); | |
851 | 876 | if (disable) { |
852 | 877 | node.set('disable', true); |
853 | 878 | viewNode.setStyle('opacity', 0.5); |
... | ... | @@ -861,47 +886,53 @@ Ext.define('amdaUI.ExplorerUI', { |
861 | 886 | }, |
862 | 887 | |
863 | 888 | updateFilter: function () { |
864 | - var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
889 | + var aliasNode, filter, keys, localNode, remoteNode, tree; | |
865 | 890 | |
866 | - var keys = []; | |
891 | + filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
892 | + | |
893 | + keys = []; | |
867 | 894 | for (var f in filter) { |
868 | - if (hasOwnProperty.call(filter, f)) | |
895 | + if (hasOwnProperty.call(filter, f)) { | |
869 | 896 | keys.push(f); |
897 | + } | |
870 | 898 | } |
871 | 899 | |
872 | - var tree = this.query('#' + amdaUI.ExplorerUI.RESRC_TAB.TREE_ID)[0]; | |
900 | + tree = this.query('#' + amdaUI.ExplorerUI.RESRC_TAB.TREE_ID)[0]; | |
873 | 901 | tree.getView().refresh(); |
874 | 902 | |
875 | 903 | for (var i = 0; i < keys.length; i++) { |
876 | - if (keys[i] == "_empty_") | |
904 | + if (keys[i] == '_empty_') { | |
877 | 905 | continue; |
906 | + } | |
878 | 907 | |
879 | 908 | switch (keys[i]) { |
880 | - case 'param' : | |
881 | - //apply filter to local datasets | |
882 | - var localNode = tree.getRootNode().findChild('id', 'myLocalData-treeRootNode', true); | |
909 | + case 'param': | |
910 | + // Apply filter to local datasets | |
911 | + localNode = tree.getRootNode().findChild('id', 'myLocalData-treeRootNode', true); | |
883 | 912 | tree.applyFilterToNodes(localNode); |
884 | 913 | tree.setNodesVisibility(localNode, false); |
885 | 914 | tree.applyDisableToNode(localNode); |
886 | 915 | |
887 | - //apply filter to aliases | |
888 | - var aliasNode = tree.getRootNode().findChild('id', 'alias-treeRootNode', true); | |
916 | + // Apply filter to aliases | |
917 | + aliasNode = tree.getRootNode().findChild('id', 'alias-treeRootNode', true); | |
889 | 918 | tree.applyFilterToNodes(aliasNode); |
890 | 919 | tree.setNodesVisibility(aliasNode, false); |
891 | 920 | tree.applyDisableToNode(aliasNode); |
892 | 921 | break; |
893 | 922 | |
894 | - case 'simu' : | |
895 | - //apply filter to simulation datasets (in remote data) | |
896 | - var remoteNode = tree.getRootNode().findChild('id', 'myRemoteSimuData-treeRootNode', true); | |
923 | + case 'simu': | |
924 | + // Apply filter to simulation datasets (in remote data) | |
925 | + remoteNode = tree.getRootNode().findChild('id', 'myRemoteSimuData-treeRootNode', true); | |
897 | 926 | tree.applyFilterToNodes(remoteNode); |
898 | 927 | tree.setNodesVisibility(remoteNode, false); |
899 | 928 | tree.applyDisableToNode(remoteNode); |
900 | 929 | break; |
930 | + default: | |
931 | + break; | |
901 | 932 | } |
902 | 933 | } |
903 | 934 | |
904 | - this.dockedItems.getAt(1).items.items[0].select(filter['name']); | |
935 | + this.dockedItems.getAt(1).items.items[0].select(filter.name); | |
905 | 936 | } |
906 | 937 | }); |
907 | 938 | |
... | ... | @@ -910,18 +941,21 @@ Ext.define('MyTreeEditor', { |
910 | 941 | extend: 'Ext.grid.plugin.CellEditing', |
911 | 942 | alias: 'editing.treeeditor', |
912 | 943 | |
913 | - // initialization method of plugin | |
944 | + // Initialization method of plugin | |
914 | 945 | init: function (cmp) { |
915 | 946 | var me = this; |
916 | 947 | me.hostCmp = cmp; |
917 | - // on parent event | |
948 | + // On parent event | |
918 | 949 | me.hostCmp.on({ |
919 | - // on edition event | |
950 | + // On edition event | |
920 | 951 | edition: { |
921 | 952 | delay: 50, |
922 | 953 | fn: function (view, record, item, index, e) { |
923 | - // view.getHeaderAtIndex(0).field.validFlag = 'Not modified'; | |
924 | - // call the start edition method | |
954 | + | |
955 | + /* | |
956 | + * View.getHeaderAtIndex(0).field.validFlag = 'Not modified'; | |
957 | + * call the start edition method | |
958 | + */ | |
925 | 959 | me.startEdit(record, view.getHeaderAtIndex(0)); |
926 | 960 | }, |
927 | 961 | scope: me |
... | ... | @@ -932,6 +966,7 @@ Ext.define('MyTreeEditor', { |
932 | 966 | |
933 | 967 | /** |
934 | 968 | * Cancel any active editing. |
969 | + * @returns {void} | |
935 | 970 | */ |
936 | 971 | cancelEdit: function () { |
937 | 972 | var me = this, |
... | ... | @@ -949,8 +984,8 @@ Ext.define('MyTreeEditor', { |
949 | 984 | }, |
950 | 985 | |
951 | 986 | /** |
952 | - * overwrite the initEditTriggers to disable edition on click/dblclick | |
953 | - * and to add custom | |
987 | + * Overwrite the initEditTriggers to disable edition on click/dblclick and to add custom | |
988 | + * @returns {void} | |
954 | 989 | */ |
955 | 990 | initEditTriggers: function () { |
956 | 991 | var me = this, |
... | ... | @@ -958,22 +993,22 @@ Ext.define('MyTreeEditor', { |
958 | 993 | |
959 | 994 | me.on({ |
960 | 995 | edit: function (editor, event) { |
961 | - // if there is a modification | |
996 | + // If there is a modification | |
962 | 997 | if (event.originalValue !== event.value) { |
963 | - // delegate rename action on model | |
998 | + // Delegate rename action on model | |
964 | 999 | event.record.rename(event.value, function (result) { |
965 | - // if a result has been returned : success | |
1000 | + // If a result has been returned : success | |
966 | 1001 | if (result) { |
967 | - // delegate commit action to delete modification flag | |
1002 | + // Delegate commit action to delete modification flag | |
968 | 1003 | event.record.commit(); |
969 | 1004 | var rec = event.record.data; |
970 | - // in case of directory | |
1005 | + // In case of directory | |
971 | 1006 | if (!rec.leaf) { |
972 | - // set folder's ID returned by server | |
1007 | + // Set folder's ID returned by server | |
973 | 1008 | rec.id = result.id; |
974 | 1009 | } |
975 | - } else { // in case of transaction error | |
976 | - // reset originalValue | |
1010 | + } else { | |
1011 | + // In case of transaction error, reset originalValue | |
977 | 1012 | event.record.value = event.originalValue; |
978 | 1013 | event.record.set('text', event.originalValue); |
979 | 1014 | event.record.commit(); |
... | ... | @@ -983,7 +1018,7 @@ Ext.define('MyTreeEditor', { |
983 | 1018 | } |
984 | 1019 | }); |
985 | 1020 | |
986 | - // enable Enter key and Esc Key | |
1021 | + // Enable Enter key and Esc Key | |
987 | 1022 | view.on('render', function () { |
988 | 1023 | me.keyNav = Ext.create('Ext.util.KeyNav', view.el, { |
989 | 1024 | enter: me.onEnterKey, |
... | ... | @@ -992,26 +1027,24 @@ Ext.define('MyTreeEditor', { |
992 | 1027 | }); |
993 | 1028 | }, me, {single: true}); |
994 | 1029 | }, |
995 | - //overwrite the getEditing context because we do not need the rowId | |
1030 | + // Overwrite the getEditing context because we do not need the rowId | |
996 | 1031 | getEditingContext: function (record, columnHeader) { |
997 | 1032 | var me = this, |
998 | 1033 | grid = me.grid, |
999 | - store = grid.store, | |
1000 | 1034 | colIdx, |
1001 | - view = grid.getView(), | |
1002 | 1035 | value; |
1003 | 1036 | |
1004 | - // getting colIdx and real columnHeader | |
1037 | + // Getting colIdx and real columnHeader | |
1005 | 1038 | if (Ext.isNumber(columnHeader)) { |
1006 | 1039 | colIdx = columnHeader; |
1007 | 1040 | columnHeader = grid.headerCt.getHeaderAtIndex(colIdx); |
1008 | 1041 | } else { |
1009 | 1042 | colIdx = columnHeader.getIndex(); |
1010 | 1043 | } |
1011 | - // getting current value | |
1044 | + // Getting current value | |
1012 | 1045 | value = record.get(columnHeader.dataIndex); |
1013 | 1046 | |
1014 | - // return editing context | |
1047 | + // Return editing context | |
1015 | 1048 | return { |
1016 | 1049 | grid: grid, |
1017 | 1050 | record: record, | ... | ... |