ui: add calendar event selector
modelled after the PVE one, but we are not 1:1 compatible and need deleteEmpty support. For now let's just have some duplicate code, but we should try to move this to widget toolkit ASAP. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
06a94edcf6
commit
41e4388005
@ -8,6 +8,7 @@ JSSRC= \
|
||||
form/UserSelector.js \
|
||||
form/RemoteSelector.js \
|
||||
form/DataStoreSelector.js \
|
||||
form/CalendarEvent.js \
|
||||
data/RunningTasksStore.js \
|
||||
button/TaskButton.js \
|
||||
config/UserView.js \
|
||||
|
64
www/form/CalendarEvent.js
Normal file
64
www/form/CalendarEvent.js
Normal file
@ -0,0 +1,64 @@
|
||||
Ext.define('PBS.data.CalendarEventExamples', {
|
||||
extend: 'Ext.data.Store',
|
||||
alias: 'store.calendarEventExamples',
|
||||
|
||||
field: ['value', 'text'],
|
||||
data: [
|
||||
//FIXME { value: '*/30', text: Ext.String.format(gettext("Every {0} minutes"), 30) },
|
||||
{ value: 'hourly', text: gettext("Every hour") },
|
||||
//FIXME { value: '*/2:00', text: gettext("Every two hours") },
|
||||
{ value: '2,22:30', text: gettext("Every day") + " 02:30, 22:30" },
|
||||
{ value: 'daily', text: gettext("Every day") + " 00:00" },
|
||||
{ value: 'mon..fri', text: gettext("Monday to Friday") + " 00:00" },
|
||||
//FIXME{ value: 'mon..fri */1:00', text: gettext("Monday to Friday") + ': ' + gettext("hourly") },
|
||||
{ value: 'sat 18:15', text: gettext("Every Saturday") + " 18:15" },
|
||||
//FIXME{ value: 'monthly', text: gettext("Every 1st of Month") + " 00:00" }, // not yet possible..
|
||||
],
|
||||
});
|
||||
|
||||
Ext.define('PBS.form.CalendarEvent', {
|
||||
extend: 'Ext.form.field.ComboBox',
|
||||
xtype: 'pbsCalendarEvent',
|
||||
|
||||
editable: true,
|
||||
|
||||
valueField: 'value',
|
||||
displayField: 'text',
|
||||
queryMode: 'local',
|
||||
|
||||
config: {
|
||||
deleteEmpty: true,
|
||||
},
|
||||
// overide framework function to implement deleteEmpty behaviour
|
||||
getSubmitData: function() {
|
||||
let me = this, data = null;
|
||||
if (!me.disabled && me.submitValue) {
|
||||
let val = me.getSubmitValue();
|
||||
if (val !== null && val !== '' && val !== '__default__') {
|
||||
data = {};
|
||||
data[me.getName()] = val;
|
||||
} else if (me.getDeleteEmpty()) {
|
||||
data = {};
|
||||
data.delete = me.getName();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
|
||||
store: {
|
||||
type: 'calendarEventExamples',
|
||||
},
|
||||
|
||||
tpl: [
|
||||
'<ul class="x-list-plain"><tpl for=".">',
|
||||
'<li role="option" class="x-boundlist-item">{text}</li>',
|
||||
'</tpl></ul>',
|
||||
],
|
||||
|
||||
displayTpl: [
|
||||
'<tpl for=".">',
|
||||
'{value}',
|
||||
'</tpl>',
|
||||
],
|
||||
});
|
@ -15,6 +15,9 @@ Ext.define('PBS.DataStoreEdit', {
|
||||
let baseurl = '/api2/extjs/config/datastore';
|
||||
|
||||
me.isCreate = !name;
|
||||
if (!me.isCreate) {
|
||||
me.defaultFocus = 'textfield[name=comment]';
|
||||
}
|
||||
me.url = name ? baseurl + '/' + name : baseurl;
|
||||
me.method = name ? 'PUT' : 'POST';
|
||||
me.autoLoad = !!name;
|
||||
@ -51,17 +54,19 @@ Ext.define('PBS.DataStoreEdit', {
|
||||
],
|
||||
column2: [
|
||||
{
|
||||
xtype: 'proxmoxtextfield',
|
||||
xtype: 'pbsCalendarEvent',
|
||||
name: 'gc-schedule',
|
||||
fieldLabel: gettext("GC Schedule"),
|
||||
emptyText: gettext('none'),
|
||||
cbind: {
|
||||
deleteEmpty: '{!isCreate}',
|
||||
},
|
||||
},
|
||||
{
|
||||
xtype: 'proxmoxtextfield',
|
||||
xtype: 'pbsCalendarEvent',
|
||||
name: 'prune-schedule',
|
||||
fieldLabel: gettext("Prune Schedule"),
|
||||
emptyText: gettext('none'),
|
||||
cbind: {
|
||||
deleteEmpty: '{!isCreate}',
|
||||
},
|
||||
|
@ -68,7 +68,7 @@ Ext.define('PBS.window.SyncJobEdit', {
|
||||
},
|
||||
{
|
||||
fieldLabel: gettext('Schedule'),
|
||||
xtype: 'proxmoxtextfield',
|
||||
xtype: 'pbsCalendarEvent',
|
||||
name: 'schedule',
|
||||
emptyText: gettext('none'),
|
||||
cbind: {
|
||||
|
Loading…
Reference in New Issue
Block a user