mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-21 18:09:18 +00:00
form/DateTimeField.js - new widget to select Date with Time
This commit is contained in:
parent
16f921d7b8
commit
2e7bd1dcba
1
Makefile
1
Makefile
@ -24,6 +24,7 @@ JSSRC= \
|
|||||||
data/TimezoneStore.js \
|
data/TimezoneStore.js \
|
||||||
form/IntegerField.js \
|
form/IntegerField.js \
|
||||||
form/TextField.js \
|
form/TextField.js \
|
||||||
|
form/DateTimeField.js \
|
||||||
form/Checkbox.js \
|
form/Checkbox.js \
|
||||||
form/KVComboBox.js \
|
form/KVComboBox.js \
|
||||||
form/ComboGrid.js \
|
form/ComboGrid.js \
|
||||||
|
62
form/DateTimeField.js
Normal file
62
form/DateTimeField.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
Ext.define('Proxmox.DateTimeField', {
|
||||||
|
extend: 'Ext.form.FieldContainer',
|
||||||
|
xtype: 'promxoxDateTimeField',
|
||||||
|
|
||||||
|
layout: 'hbox',
|
||||||
|
|
||||||
|
referenceHolder: true,
|
||||||
|
|
||||||
|
submitFormat: 'U',
|
||||||
|
|
||||||
|
getValue: function() {
|
||||||
|
var me = this;
|
||||||
|
var d = me.lookupReference('dateentry').getValue();
|
||||||
|
|
||||||
|
if (d === undefined || d === null) { return null; }
|
||||||
|
|
||||||
|
var t = me.lookupReference('timeentry').getValue();
|
||||||
|
|
||||||
|
if (t === undefined || t === null) { return null; }
|
||||||
|
|
||||||
|
var offset = (t.getHours()*3600+t.getMinutes()*60)*1000;
|
||||||
|
|
||||||
|
return new Date(d.getTime() + offset);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSubmitValue: function() {
|
||||||
|
var me = this;
|
||||||
|
var format = me.submitFormat;
|
||||||
|
var value = me.getValue();
|
||||||
|
|
||||||
|
return value ? Ext.Date.format(value, format) : null;
|
||||||
|
},
|
||||||
|
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
xtype: 'datefield',
|
||||||
|
editable: false,
|
||||||
|
reference: 'dateentry',
|
||||||
|
flex: 1,
|
||||||
|
format: 'Y-m-d'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
xtype: 'timefield',
|
||||||
|
reference: 'timeentry',
|
||||||
|
format: 'H:i',
|
||||||
|
width: 80,
|
||||||
|
value: '00:00',
|
||||||
|
increment: 60
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
initComponent: function() {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
me.callParent();
|
||||||
|
|
||||||
|
var value = me.value || new Date();
|
||||||
|
|
||||||
|
me.lookupReference('dateentry').setValue(value);
|
||||||
|
me.lookupReference('timeentry').setValue(value);
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user