diff --git a/js/app/controllers/EpnTapModule.js b/js/app/controllers/EpnTapModule.js index a3cc104..b9e63b9 100644 --- a/js/app/controllers/EpnTapModule.js +++ b/js/app/controllers/EpnTapModule.js @@ -362,8 +362,8 @@ Ext.define('amdaDesktop.EpnTapModule', { var newTimeMin = null; var newTimeMax = null; - var timeMin = Ext.Date.parse('01/01/2100', 'd/m/Y'); - var timeMax = Ext.Date.parse('01/01/1900', 'd/m/Y'); + var timeMin = null; + var timeMax = null; var productType = this.productTypeCB.value; var targetClass = this.targetClassCB.value; @@ -380,11 +380,10 @@ Ext.define('amdaDesktop.EpnTapModule', { newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); - - if (newTimeMin !== null && newTimeMin < timeMin) { + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { timeMin = newTimeMin; } - if (newTimeMax !== null && newTimeMax > timeMax) { + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { timeMax = newTimeMax; } } @@ -400,10 +399,10 @@ Ext.define('amdaDesktop.EpnTapModule', { newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); - if (newTimeMin !== null && newTimeMin < timeMin) { + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { timeMin = newTimeMin; } - if (newTimeMax !== null && newTimeMax > timeMax) { + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { timeMax = newTimeMax; } } @@ -417,10 +416,10 @@ Ext.define('amdaDesktop.EpnTapModule', { newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); - if (newTimeMin !== null && newTimeMin < timeMin) { + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { timeMin = newTimeMin; } - if (newTimeMax !== null && newTimeMax > timeMax) { + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { timeMax = newTimeMax; } } @@ -433,24 +432,15 @@ Ext.define('amdaDesktop.EpnTapModule', { newTimeMin = Ext.Date.parse(service[1], 'd/m/Y'); newTimeMax = Ext.Date.parse(service[2], 'd/m/Y'); - if (newTimeMin !== null && newTimeMin < timeMin) { + if (newTimeMin !== null && newTimeMin < timeMin || timeMin == null) { timeMin = newTimeMin; } - if (newTimeMax !== null && newTimeMax > timeMax) { + if (newTimeMax !== null && newTimeMax > timeMax || timeMax == null) { timeMax = newTimeMax; } } } - if (timeMin < Ext.Date.parse('01/01/1970', 'd/m/Y') ) { - console.log('warning: ', timeMin, " is a too old date, replaced by 01/01/1970."); - timeMin = Ext.Date.parse('01/01/1970', 'd/m/Y'); - } - if (timeMax > Ext.Date.parse('01/01/2099', 'd/m/Y') ) { - console.log('warning: ', timeMax, " is a too high date, replaced by 01/01/2099."); - timeMax = Ext.Date.parse('01/01/2099', 'd/m/Y'); - } - this.timeSelector.setLimits(timeMin, timeMax); this.timeSelector.setInterval(timeMin, timeMax); diff --git a/js/app/views/EpnTapUI.js b/js/app/views/EpnTapUI.js index b6cf074..1ee21e3 100644 --- a/js/app/views/EpnTapUI.js +++ b/js/app/views/EpnTapUI.js @@ -449,7 +449,8 @@ Ext.define('amdaUI.EpnTapUI', { */ var createTimeSelector = function() { return Ext.create('amdaUI.IntervalUI', { - id: 'epnTapTimeSelector' + id: 'epnTapTimeSelector', + durationLimit: 99999 }); }; diff --git a/js/app/views/IntervalUI.js b/js/app/views/IntervalUI.js index ac81d75..77276f2 100644 --- a/js/app/views/IntervalUI.js +++ b/js/app/views/IntervalUI.js @@ -12,7 +12,10 @@ ****************************************************************************** */ - +/** +config: +- durationLimit: The maximum value of the duration days field (9999 by default). +*/ Ext.define('amdaUI.IntervalUI', { extend: 'Ext.container.Container', alias: 'widget.intervalSelector', @@ -24,29 +27,31 @@ Ext.define('amdaUI.IntervalUI', { }, /** - Set the start and stop date, and update the duration field. - - startDate: A Extjs Date object representing the new start time. - - stopDate: A Extjs Date object representing the new stop time. - - return: None. + Set the start and stop date, and update the duration field. + - startDate: A Extjs Date object representing the new start time. + - stopDate: A Extjs Date object representing the new stop time. + - return: None. */ - setInterval : function(startDate, stopDate) - { + setInterval: function(startDate, stopDate) { // get the search form - var form = this.findParentByType('form').getForm(); - // get start field - var startField = form.findField('startDate'); - // get stop field - var stopField = form.findField('stopDate'); + var form = this.findParentByType('form').getForm(); + // get start field + var startField = form.findField('startDate'); + // get stop field + var stopField = form.findField('stopDate'); - if (startField != null) - startField.setValue(startDate); + if (startField != null) + startField.setValue(startDate); - if (stopField != null) - stopField.setValue(stopDate); + if (stopField != null) + stopField.setValue(stopDate); - this.updateDuration(); + this.updateDuration(); }, + /** + Set the limits values of both startField and stopField date fields. + */ setLimits: function(minValue, maxValue) { var form = this.findParentByType('form').getForm(); var startField = form.findField('startDate'); @@ -66,17 +71,16 @@ Ext.define('amdaUI.IntervalUI', { }, /** - Get the start time field value. - - return: A Extjs Date object representing the start time. + Get the start time field value. + - return: A Extjs Date object representing the start time. */ - getStartTime : function() - { + getStartTime: function() { // get the search form - var form = this.findParentByType('form').getForm(); - // get start field - var startField = form.findField('startDate'); + var form = this.findParentByType('form').getForm(); + // get start field + var startField = form.findField('startDate'); - return startField.getValue(); + return startField.getValue(); }, /** @@ -114,13 +118,13 @@ Ext.define('amdaUI.IntervalUI', { var durationDays = Math.floor(diff/86400000); // set all duration values - form.findField('durationDay').setValue(Ext.String.leftPad(durationDays,4,'0')); + form.findField('durationDay').setValue(Ext.String.leftPad(durationDays, ('' + this.durationLimit).length, '0')); form.findField('durationHour').setValue(Ext.String.leftPad(Math.floor(diff/3600000 % 24),2,'0')); form.findField('durationMin').setValue(Ext.String.leftPad(Math.floor(diff/60000 % 60),2,'0')); form.findField('durationSec').setValue(Ext.String.leftPad(Math.floor(diff/1000 % 60),2,'0')); - if (durationDays > 25000) { - form.findField('durationDay').markInvalid('Maximum interval is 25000 days!'); + if (durationDays > this.durationLimit) { + form.findField('durationDay').markInvalid('Maximum interval is ' + this.durationLimit + ' days!'); } } @@ -237,7 +241,7 @@ Ext.define('amdaUI.IntervalUI', { items:[ { xtype: 'displayfield', labelWidth: 60, labelAlign: 'right', width: 60, fieldLabel: '
Duration'}, { xtype: 'component', width: 5}, - { name: 'durationDay', fieldLabel: 'Days', width: 45, maxLength: 5}, + { name: 'durationDay', fieldLabel: 'Days', width: 45, maxLength: ('' + this.durationLimit).length}, { xtype: 'component', width: 5}, { name: 'durationHour', fieldLabel: 'Hrs'}, { xtype: 'component', width: 5}, @@ -249,6 +253,8 @@ Ext.define('amdaUI.IntervalUI', { }, init : function(config) { + this.durationLimit = config.durationLimit == null ? 9999 : config.durationLimit; // Set duration limit to 9999 by default + var me = this; var myConf = { -- libgit2 0.21.2