|
@ -163,7 +163,9 @@ Ext.define('Ext.ux.form.field.DateTime', { |
|
|
|
|
|
|
|
|
dateField: null, |
|
|
dateField: null, |
|
|
|
|
|
|
|
|
timeField: null, |
|
|
hourField: null, |
|
|
|
|
|
minuteField: null, |
|
|
|
|
|
ampmField: null, |
|
|
|
|
|
|
|
|
initComponent: function(){ |
|
|
initComponent: function(){ |
|
|
var me = this |
|
|
var me = this |
|
@ -183,10 +185,59 @@ Ext.define('Ext.ux.form.field.DateTime', { |
|
|
}, me.dateConfig)); |
|
|
}, me.dateConfig)); |
|
|
me.items.push(me.dateField); |
|
|
me.items.push(me.dateField); |
|
|
|
|
|
|
|
|
|
|
|
me.hourField = Ext.create('Ext.form.field.Number', { |
|
|
|
|
|
maxWidth: 20, |
|
|
|
|
|
allowBlank: false, |
|
|
|
|
|
allowOnlyWhitespace: false, |
|
|
|
|
|
blankText: "Hour cannot be blank.", |
|
|
|
|
|
allowDecimals: false, |
|
|
|
|
|
maxValue: 12, |
|
|
|
|
|
minValue: 1, |
|
|
|
|
|
maxLength: 2, |
|
|
|
|
|
enforceMaxLength: 2, |
|
|
|
|
|
hideTrigger: true, |
|
|
|
|
|
submitValue:false, |
|
|
|
|
|
flex:1, |
|
|
|
|
|
fieldStyle: "text-align:right;", |
|
|
|
|
|
isFormField:false, //exclude from field query's
|
|
|
|
|
|
}); |
|
|
|
|
|
me.items.push(me.hourField); |
|
|
|
|
|
|
|
|
|
|
|
me.colon = Ext.create('Ext.draw.Text', { |
|
|
|
|
|
text: ':', |
|
|
|
|
|
padding: '3 3 0 3' |
|
|
|
|
|
}); |
|
|
|
|
|
me.items.push(me.colon); |
|
|
|
|
|
|
|
|
|
|
|
me.minuteField = Ext.create('Ext.form.field.Number', { |
|
|
|
|
|
validateOnBlur: false, |
|
|
|
|
|
maxWidth: 30, |
|
|
|
|
|
allowBlank: false, |
|
|
|
|
|
allowOnlyWhitespace: false, |
|
|
|
|
|
blankText: "Minutes cannot be blank.", |
|
|
|
|
|
allowDecimals: false, |
|
|
|
|
|
maxValue: 59, |
|
|
|
|
|
minValue: 0, |
|
|
|
|
|
maxLength: 2, |
|
|
|
|
|
enforceMaxLength: 2, |
|
|
|
|
|
hideTrigger: true, |
|
|
|
|
|
submitValue:false, |
|
|
|
|
|
flex:1, |
|
|
|
|
|
isFormField:false, //exclude from field query's
|
|
|
|
|
|
}); |
|
|
|
|
|
me.items.push(me.minuteField); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
me.ampmField = Ext.create('Ext.form.ComboBox', { |
|
|
|
|
|
maxWidth: 45, |
|
|
|
|
|
value: 'PM', |
|
|
|
|
|
store: ['AM', 'PM'], |
|
|
|
|
|
forceSelection: true, |
|
|
|
|
|
flex:1, |
|
|
|
|
|
editable: false |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//me.timeField = Ext.create('Ext.form.field.Text', {width: 20});
|
|
|
me.items.push(me.ampmField); |
|
|
me.timeField = Ext.create('app.view.form.field.TimeField'); |
|
|
|
|
|
me.items.push(me.timeField); |
|
|
|
|
|
|
|
|
|
|
|
for (; i < me.items.length; i++) { |
|
|
for (; i < me.items.length; i++) { |
|
|
me.items[i].on('focus', Ext.bind(me.onItemFocus, me)); |
|
|
me.items[i].on('focus', Ext.bind(me.onItemFocus, me)); |
|
@ -241,8 +292,15 @@ Ext.define('Ext.ux.form.field.DateTime', { |
|
|
getValue: function(){ |
|
|
getValue: function(){ |
|
|
var value = null |
|
|
var value = null |
|
|
,date = this.dateField.getSubmitValue() |
|
|
,date = this.dateField.getSubmitValue() |
|
|
,time = this.timeField.getSubmitValue() |
|
|
,time = null |
|
|
,format; |
|
|
,format; |
|
|
|
|
|
|
|
|
|
|
|
hour = this.hourField.getValue(); |
|
|
|
|
|
minute = this.minuteField.getValue(); |
|
|
|
|
|
ampm = this.ampmField.getValue(); |
|
|
|
|
|
time = Ext.Date.parse(hour + " " + minute + " " + ampm, 'g i A'); |
|
|
|
|
|
time = Ext.Date.format(time, this.timeSubmitFormat); |
|
|
|
|
|
|
|
|
if (date){ |
|
|
if (date){ |
|
|
if (time){ |
|
|
if (time){ |
|
|
format = this.getFormat(); |
|
|
format = this.getFormat(); |
|
@ -267,14 +325,22 @@ Ext.define('Ext.ux.form.field.DateTime', { |
|
|
|
|
|
|
|
|
setValue: function(value){ |
|
|
setValue: function(value){ |
|
|
if (Ext.isString(value)){ |
|
|
if (Ext.isString(value)){ |
|
|
|
|
|
dt = new Date(value); |
|
|
value = Ext.Date.parse(value, this.getFormat()); //this.dateTimeFormat
|
|
|
value = Ext.Date.parse(value, this.getFormat()); //this.dateTimeFormat
|
|
|
this.dateField.setValue(value); |
|
|
this.dateField.setValue(value); |
|
|
this.timeField.setValue(value); |
|
|
|
|
|
|
|
|
hour = Ext.Date.format(dt, 'g'); |
|
|
|
|
|
minute = Ext.Date.format(dt, 'i'); |
|
|
|
|
|
ampm = Ext.Date.format(dt, 'A'); |
|
|
|
|
|
|
|
|
|
|
|
this.hourField.setValue(hour); |
|
|
|
|
|
this.minuteField.setRawValue(minute); |
|
|
|
|
|
this.ampmField.setValue(ampm); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
getFormat: function(){ |
|
|
getFormat: function(){ |
|
|
value = (this.dateField.submitFormat || this.dateField.format) + " " + (this.timeField.submitFormat || this.timeField.format); |
|
|
value = (this.dateField.submitFormat || this.dateField.format) + " " + (this.timeSubmitFormat || this.timeFormat); |
|
|
return value; |
|
|
return value; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|