ui: sync: add reduced max-depth selector
that allows setting the limit based on sync namespace prefix lengths. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
87be232d1c
commit
9dde8cd625
@ -31,3 +31,16 @@ Ext.define('PBS.form.NamespaceMaxDepth', {
|
||||
},
|
||||
});
|
||||
|
||||
Ext.define('PBS.form.NamespaceMaxDepthReduced', {
|
||||
extend: 'PBS.form.NamespaceMaxDepth',
|
||||
alias: 'widget.pbsNamespaceMaxDepthReduced',
|
||||
|
||||
setLimit: function(maxPrefixLength) {
|
||||
let me = this;
|
||||
if (maxPrefixLength !== undefined) {
|
||||
me.maxValue = 7-maxPrefixLength;
|
||||
} else {
|
||||
me.maxValue = 7;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -32,6 +32,28 @@ Ext.define('PBS.window.SyncJobEdit', {
|
||||
return { };
|
||||
},
|
||||
|
||||
calcMaxDepthLimit: function() {
|
||||
let maxPrefixLength = 0;
|
||||
let view = this.controller.getView();
|
||||
let nsSelector = view.down('pbsNamespaceSelector[name=ns]');
|
||||
let ns = nsSelector.getValue();
|
||||
if (ns !== undefined && ns !== null) {
|
||||
maxPrefixLength = (ns.match(/\//g) || []).length + 1;
|
||||
}
|
||||
|
||||
let remoteNsSelector = view.down('pbsRemoteNamespaceSelector[name=remote-ns]');
|
||||
let remoteNs = remoteNsSelector.getValue();
|
||||
|
||||
if (remoteNs !== undefined && remoteNs !== null) {
|
||||
let remotePrefixLength = (remoteNs.match(/\//g) || []).length + 1;
|
||||
if (remotePrefixLength > maxPrefixLength) {
|
||||
maxPrefixLength = remotePrefixLength;
|
||||
}
|
||||
}
|
||||
|
||||
return maxPrefixLength;
|
||||
},
|
||||
|
||||
controller: {
|
||||
xclass: 'Ext.app.ViewController',
|
||||
control: {
|
||||
@ -92,6 +114,14 @@ Ext.define('PBS.window.SyncJobEdit', {
|
||||
cbind: {
|
||||
datastore: '{datastore}',
|
||||
},
|
||||
listeners: {
|
||||
change: function(field, value) {
|
||||
let me = this;
|
||||
let maxDepthField = me.up('pbsSyncJobEdit').down('field[name=max-depth]');
|
||||
maxDepthField.setLimit(me.up('pbsSyncJobEdit').calcMaxDepthLimit());
|
||||
maxDepthField.validate();
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldLabel: gettext('Local Owner'),
|
||||
@ -172,11 +202,14 @@ Ext.define('PBS.window.SyncJobEdit', {
|
||||
let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]');
|
||||
let remoteStore = remoteStoreField.getValue();
|
||||
me.up('tabpanel').down('pbsGroupFilter').setRemoteNamespace(remote, remoteStore, value);
|
||||
let maxDepthField = me.up('pbsSyncJobEdit').down('field[name=max-depth]');
|
||||
maxDepthField.setLimit(me.up('pbsSyncJobEdit').calcMaxDepthLimit());
|
||||
maxDepthField.validate();
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
xtype: 'pbsNamespaceMaxDepth',
|
||||
xtype: 'pbsNamespaceMaxDepthReduced',
|
||||
name: 'max-depth',
|
||||
fieldLabel: gettext('Max. Depth'),
|
||||
deleteEmpty: true,
|
||||
|
Loading…
Reference in New Issue
Block a user