ui: prune input: support opt-in recursive/max-depth field

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-19 13:34:07 +02:00
parent 26b40687b3
commit d4574bb138
1 changed files with 50 additions and 21 deletions

View File

@ -1,14 +1,15 @@
Ext.define('PBS.panel.PruneInputPanel', { Ext.define('PBS.panel.PruneInputPanel', {
extend: 'Proxmox.panel.InputPanel', extend: 'Proxmox.panel.InputPanel',
xtype: 'pbsPruneInputPanel', xtype: 'pbsPruneInputPanel',
mixins: ['Proxmox.Mixin.CBind'], mixins: ['Proxmox.Mixin.CBind'],
onlineHelp: 'maintenance_pruning', onlineHelp: 'maintenance_pruning',
// show/hide dry-run field // show/hide dry-run field FIXME: rename to canDryrun, this is confusing..
dryrun: false, dryrun: false,
canRecurse: false, // show a recursive/max-depth field
cbindData: function() { cbindData: function() {
let me = this; let me = this;
me.isCreate = !!me.isCreate; me.isCreate = !!me.isCreate;
@ -17,10 +18,19 @@ Ext.define('PBS.panel.PruneInputPanel', {
}; };
}, },
viewModel: {
data: { canRecurse: false },
},
onGetValues: function(values) { onGetValues: function(values) {
if (values.ns === '') { let me = this;
delete values.ns; if (me.ns && me.ns !== '') {
values.ns = me.ns;
} }
if (!values.recursive) {
values['max-depth'] = 0;
}
delete values.recursive;
return values; return values;
}, },
@ -49,6 +59,15 @@ Ext.define('PBS.panel.PruneInputPanel', {
deleteEmpty: '{!isCreate}', deleteEmpty: '{!isCreate}',
}, },
}, },
{
xtype: 'proxmoxcheckbox',
name: 'dry-run',
fieldLabel: gettext('Dry Run'),
cbind: {
hidden: '{!dryrun}',
disabled: '{!dryrun}',
},
},
], ],
column2: [ column2: [
{ {
@ -75,26 +94,36 @@ Ext.define('PBS.panel.PruneInputPanel', {
deleteEmpty: '{!isCreate}', deleteEmpty: '{!isCreate}',
}, },
}, },
], {
xtype: 'fieldcontainer',
columnB: [ layout: 'hbox',
fieldLabel: gettext('Recursive'),
cbind: {
hidden: '{!canRecurse}',
disabled: '{!canRecurse}',
},
items: [
{ {
xtype: 'proxmoxcheckbox', xtype: 'proxmoxcheckbox',
name: 'dry-run', name: 'recursive',
fieldLabel: gettext('Dry Run'), uncheckedValue: false,
cbind: { value: true,
hidden: '{!dryrun}', bind: {
disabled: '{!dryrun}', value: '{canRecurse}',
}, },
}, },
{ {
xtype: 'proxmoxtextfield', xtype: 'pbsNamespaceMaxDepth',
name: 'ns', name: 'max-depth',
hidden: true, padding: '0 0 0 5',
cbind: { labelWidth: 75,
value: '{ns}', deleteEmpty: false,
bind: {
disabled: '{!canRecurse}',
}, },
flex: 1,
},
],
}, },
], ],
}); });