proxmox-widget-toolkit/src/form/ExpireDate.js
Thomas Lamprecht ecabd4379c cleanly separate sources from package build, move to own folder
compared result with `diffoscope`, saw now difference

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-06 17:43:03 +02:00

35 lines
634 B
JavaScript

// treats 0 as "never expires"
Ext.define('Proxmox.form.field.ExpireDate', {
extend: 'Ext.form.field.Date',
alias: ['widget.pmxExpireDate'],
name: 'expire',
fieldLabel: gettext('Expire'),
emptyText: 'never',
format: 'Y-m-d',
submitFormat: 'U',
getSubmitValue: function() {
let me = this;
let value = me.callParent();
if (!value) value = 0;
return value;
},
setValue: function(value) {
let me = this;
if (Ext.isDefined(value)) {
if (!value) {
value = null;
} else if (!Ext.isDate(value)) {
value = new Date(value * 1000);
}
}
me.callParent([value]);
},
});