Commit 5e85f9e68f71982e2bd6d708bbeef912b8468b1f
1 parent
72195d65
Exists in
master
and in
111 other branches
Add 'durationLimit' in intervalUI config and set it to 99999 for EPN-TAP module.
Showing
3 changed files
with
47 additions
and
50 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
@@ -362,8 +362,8 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -362,8 +362,8 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
362 | var newTimeMin = null; | 362 | var newTimeMin = null; |
363 | var newTimeMax = null; | 363 | var newTimeMax = null; |
364 | 364 | ||
365 | - var timeMin = Ext.Date.parse('01/01/2100', 'd/m/Y'); | ||
366 | - var timeMax = Ext.Date.parse('01/01/1900', 'd/m/Y'); | 365 | + var timeMin = null; |
366 | + var timeMax = null; | ||
367 | 367 | ||
368 | var productType = this.productTypeCB.value; | 368 | var productType = this.productTypeCB.value; |
369 | var targetClass = this.targetClassCB.value; | 369 | var targetClass = this.targetClassCB.value; |
@@ -380,11 +380,10 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -380,11 +380,10 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
380 | 380 | ||
381 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); | 381 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); |
382 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); | 382 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); |
383 | - | ||
384 | - if (newTimeMin !== null && newTimeMin < timeMin) { | 383 | + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { |
385 | timeMin = newTimeMin; | 384 | timeMin = newTimeMin; |
386 | } | 385 | } |
387 | - if (newTimeMax !== null && newTimeMax > timeMax) { | 386 | + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { |
388 | timeMax = newTimeMax; | 387 | timeMax = newTimeMax; |
389 | } | 388 | } |
390 | } | 389 | } |
@@ -400,10 +399,10 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -400,10 +399,10 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
400 | 399 | ||
401 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); | 400 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); |
402 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); | 401 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); |
403 | - if (newTimeMin !== null && newTimeMin < timeMin) { | 402 | + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { |
404 | timeMin = newTimeMin; | 403 | timeMin = newTimeMin; |
405 | } | 404 | } |
406 | - if (newTimeMax !== null && newTimeMax > timeMax) { | 405 | + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { |
407 | timeMax = newTimeMax; | 406 | timeMax = newTimeMax; |
408 | } | 407 | } |
409 | } | 408 | } |
@@ -417,10 +416,10 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -417,10 +416,10 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
417 | 416 | ||
418 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); | 417 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); |
419 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); | 418 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); |
420 | - if (newTimeMin !== null && newTimeMin < timeMin) { | 419 | + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { |
421 | timeMin = newTimeMin; | 420 | timeMin = newTimeMin; |
422 | } | 421 | } |
423 | - if (newTimeMax !== null && newTimeMax > timeMax) { | 422 | + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { |
424 | timeMax = newTimeMax; | 423 | timeMax = newTimeMax; |
425 | } | 424 | } |
426 | } | 425 | } |
@@ -433,24 +432,15 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -433,24 +432,15 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
433 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); | 432 | newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); |
434 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); | 433 | newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); |
435 | 434 | ||
436 | - if (newTimeMin !== null && newTimeMin < timeMin) { | 435 | + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { |
437 | timeMin = newTimeMin; | 436 | timeMin = newTimeMin; |
438 | } | 437 | } |
439 | - if (newTimeMax !== null && newTimeMax > timeMax) { | 438 | + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { |
440 | timeMax = newTimeMax; | 439 | timeMax = newTimeMax; |
441 | } | 440 | } |
442 | } | 441 | } |
443 | } | 442 | } |
444 | 443 | ||
445 | - if (timeMin < Ext.Date.parse('01/01/1970', 'd/m/Y') ) { | ||
446 | - console.log('warning: ', timeMin, " is a too old date, replaced by 01/01/1970."); | ||
447 | - timeMin = Ext.Date.parse('01/01/1970', 'd/m/Y'); | ||
448 | - } | ||
449 | - if (timeMax > Ext.Date.parse('01/01/2099', 'd/m/Y') ) { | ||
450 | - console.log('warning: ', timeMax, " is a too high date, replaced by 01/01/2099."); | ||
451 | - timeMax = Ext.Date.parse('01/01/2099', 'd/m/Y'); | ||
452 | - } | ||
453 | - | ||
454 | this.timeSelector.setLimits(timeMin, timeMax); | 444 | this.timeSelector.setLimits(timeMin, timeMax); |
455 | this.timeSelector.setInterval(timeMin, timeMax); | 445 | this.timeSelector.setInterval(timeMin, timeMax); |
456 | 446 |
js/app/views/EpnTapUI.js
@@ -449,7 +449,8 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -449,7 +449,8 @@ Ext.define('amdaUI.EpnTapUI', { | ||
449 | */ | 449 | */ |
450 | var createTimeSelector = function() { | 450 | var createTimeSelector = function() { |
451 | return Ext.create('amdaUI.IntervalUI', { | 451 | return Ext.create('amdaUI.IntervalUI', { |
452 | - id: 'epnTapTimeSelector' | 452 | + id: 'epnTapTimeSelector', |
453 | + durationLimit: 99999 | ||
453 | }); | 454 | }); |
454 | }; | 455 | }; |
455 | 456 |
js/app/views/IntervalUI.js
@@ -12,7 +12,10 @@ | @@ -12,7 +12,10 @@ | ||
12 | ****************************************************************************** | 12 | ****************************************************************************** |
13 | */ | 13 | */ |
14 | 14 | ||
15 | - | 15 | +/** |
16 | +config: | ||
17 | +- durationLimit: The maximum value of the duration days field (9999 by default). | ||
18 | +*/ | ||
16 | Ext.define('amdaUI.IntervalUI', { | 19 | Ext.define('amdaUI.IntervalUI', { |
17 | extend: 'Ext.container.Container', | 20 | extend: 'Ext.container.Container', |
18 | alias: 'widget.intervalSelector', | 21 | alias: 'widget.intervalSelector', |
@@ -24,29 +27,31 @@ Ext.define('amdaUI.IntervalUI', { | @@ -24,29 +27,31 @@ Ext.define('amdaUI.IntervalUI', { | ||
24 | }, | 27 | }, |
25 | 28 | ||
26 | /** | 29 | /** |
27 | - Set the start and stop date, and update the duration field. | ||
28 | - - startDate: A Extjs Date object representing the new start time. | ||
29 | - - stopDate: A Extjs Date object representing the new stop time. | ||
30 | - - return: None. | 30 | + Set the start and stop date, and update the duration field. |
31 | + - startDate: A Extjs Date object representing the new start time. | ||
32 | + - stopDate: A Extjs Date object representing the new stop time. | ||
33 | + - return: None. | ||
31 | */ | 34 | */ |
32 | - setInterval : function(startDate, stopDate) | ||
33 | - { | 35 | + setInterval: function(startDate, stopDate) { |
34 | // get the search form | 36 | // get the search form |
35 | - var form = this.findParentByType('form').getForm(); | ||
36 | - // get start field | ||
37 | - var startField = form.findField('startDate'); | ||
38 | - // get stop field | ||
39 | - var stopField = form.findField('stopDate'); | 37 | + var form = this.findParentByType('form').getForm(); |
38 | + // get start field | ||
39 | + var startField = form.findField('startDate'); | ||
40 | + // get stop field | ||
41 | + var stopField = form.findField('stopDate'); | ||
40 | 42 | ||
41 | - if (startField != null) | ||
42 | - startField.setValue(startDate); | 43 | + if (startField != null) |
44 | + startField.setValue(startDate); | ||
43 | 45 | ||
44 | - if (stopField != null) | ||
45 | - stopField.setValue(stopDate); | 46 | + if (stopField != null) |
47 | + stopField.setValue(stopDate); | ||
46 | 48 | ||
47 | - this.updateDuration(); | 49 | + this.updateDuration(); |
48 | }, | 50 | }, |
49 | 51 | ||
52 | + /** | ||
53 | + Set the limits values of both startField and stopField date fields. | ||
54 | + */ | ||
50 | setLimits: function(minValue, maxValue) { | 55 | setLimits: function(minValue, maxValue) { |
51 | var form = this.findParentByType('form').getForm(); | 56 | var form = this.findParentByType('form').getForm(); |
52 | var startField = form.findField('startDate'); | 57 | var startField = form.findField('startDate'); |
@@ -66,17 +71,16 @@ Ext.define('amdaUI.IntervalUI', { | @@ -66,17 +71,16 @@ Ext.define('amdaUI.IntervalUI', { | ||
66 | }, | 71 | }, |
67 | 72 | ||
68 | /** | 73 | /** |
69 | - Get the start time field value. | ||
70 | - - return: A Extjs Date object representing the start time. | 74 | + Get the start time field value. |
75 | + - return: A Extjs Date object representing the start time. | ||
71 | */ | 76 | */ |
72 | - getStartTime : function() | ||
73 | - { | 77 | + getStartTime: function() { |
74 | // get the search form | 78 | // get the search form |
75 | - var form = this.findParentByType('form').getForm(); | ||
76 | - // get start field | ||
77 | - var startField = form.findField('startDate'); | 79 | + var form = this.findParentByType('form').getForm(); |
80 | + // get start field | ||
81 | + var startField = form.findField('startDate'); | ||
78 | 82 | ||
79 | - return startField.getValue(); | 83 | + return startField.getValue(); |
80 | }, | 84 | }, |
81 | 85 | ||
82 | /** | 86 | /** |
@@ -114,13 +118,13 @@ Ext.define('amdaUI.IntervalUI', { | @@ -114,13 +118,13 @@ Ext.define('amdaUI.IntervalUI', { | ||
114 | 118 | ||
115 | var durationDays = Math.floor(diff/86400000); | 119 | var durationDays = Math.floor(diff/86400000); |
116 | // set all duration values | 120 | // set all duration values |
117 | - form.findField('durationDay').setValue(Ext.String.leftPad(durationDays,4,'0')); | 121 | + form.findField('durationDay').setValue(Ext.String.leftPad(durationDays, ('' + this.durationLimit).length, '0')); |
118 | form.findField('durationHour').setValue(Ext.String.leftPad(Math.floor(diff/3600000 % 24),2,'0')); | 122 | form.findField('durationHour').setValue(Ext.String.leftPad(Math.floor(diff/3600000 % 24),2,'0')); |
119 | form.findField('durationMin').setValue(Ext.String.leftPad(Math.floor(diff/60000 % 60),2,'0')); | 123 | form.findField('durationMin').setValue(Ext.String.leftPad(Math.floor(diff/60000 % 60),2,'0')); |
120 | form.findField('durationSec').setValue(Ext.String.leftPad(Math.floor(diff/1000 % 60),2,'0')); | 124 | form.findField('durationSec').setValue(Ext.String.leftPad(Math.floor(diff/1000 % 60),2,'0')); |
121 | 125 | ||
122 | - if (durationDays > 25000) { | ||
123 | - form.findField('durationDay').markInvalid('Maximum interval is 25000 days!'); | 126 | + if (durationDays > this.durationLimit) { |
127 | + form.findField('durationDay').markInvalid('Maximum interval is ' + this.durationLimit + ' days!'); | ||
124 | } | 128 | } |
125 | } | 129 | } |
126 | 130 | ||
@@ -237,7 +241,7 @@ Ext.define('amdaUI.IntervalUI', { | @@ -237,7 +241,7 @@ Ext.define('amdaUI.IntervalUI', { | ||
237 | items:[ | 241 | items:[ |
238 | { xtype: 'displayfield', labelWidth: 60, labelAlign: 'right', width: 60, fieldLabel: '<br>Duration'}, | 242 | { xtype: 'displayfield', labelWidth: 60, labelAlign: 'right', width: 60, fieldLabel: '<br>Duration'}, |
239 | { xtype: 'component', width: 5}, | 243 | { xtype: 'component', width: 5}, |
240 | - { name: 'durationDay', fieldLabel: 'Days', width: 45, maxLength: 5}, | 244 | + { name: 'durationDay', fieldLabel: 'Days', width: 45, maxLength: ('' + this.durationLimit).length}, |
241 | { xtype: 'component', width: 5}, | 245 | { xtype: 'component', width: 5}, |
242 | { name: 'durationHour', fieldLabel: 'Hrs'}, | 246 | { name: 'durationHour', fieldLabel: 'Hrs'}, |
243 | { xtype: 'component', width: 5}, | 247 | { xtype: 'component', width: 5}, |
@@ -249,6 +253,8 @@ Ext.define('amdaUI.IntervalUI', { | @@ -249,6 +253,8 @@ Ext.define('amdaUI.IntervalUI', { | ||
249 | }, | 253 | }, |
250 | 254 | ||
251 | init : function(config) { | 255 | init : function(config) { |
256 | + this.durationLimit = config.durationLimit == null ? 9999 : config.durationLimit; // Set duration limit to 9999 by default | ||
257 | + | ||
252 | var me = this; | 258 | var me = this; |
253 | 259 | ||
254 | var myConf = { | 260 | var myConf = { |