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