ui: move max NS prefix length logic to reduced max-depth selector
for better re-usability in the future and it felt a bit odd to have such specific logic in the sync job edit directly Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -22,6 +22,7 @@ Ext.define('pbs-groups', {
|
||||
Ext.define('PBS.form.GroupSelector', {
|
||||
extend: 'Proxmox.form.ComboGrid',
|
||||
alias: 'widget.pbsGroupSelector',
|
||||
mixins: ['Proxmox.Mixin.CBind'],
|
||||
|
||||
allowBlank: false,
|
||||
autoSelect: false,
|
||||
|
@ -35,12 +35,27 @@ 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;
|
||||
}
|
||||
},
|
||||
calcMaxPrefixLength: function(ns1, ns2) {
|
||||
let maxPrefixLength = 0;
|
||||
if (ns1 !== undefined && ns1 !== null) {
|
||||
maxPrefixLength = (ns1.match(/[/]/g) || []).length + (ns1 === '' ? 0 : 1);
|
||||
}
|
||||
if (ns2 !== undefined && ns2 !== null) {
|
||||
let ns2PrefixLength = (ns2.match(/[/]/g) || []).length + (ns2 === '' ? 0 : 1);
|
||||
if (ns2PrefixLength > maxPrefixLength) {
|
||||
maxPrefixLength = ns2PrefixLength;
|
||||
}
|
||||
}
|
||||
return maxPrefixLength;
|
||||
},
|
||||
|
||||
setLimit: function(ns1, ns2) {
|
||||
let me = this;
|
||||
let maxPrefixLength = me.calcMaxPrefixLength(ns1, ns2);
|
||||
if (maxPrefixLength !== undefined) {
|
||||
me.maxValue = 7 - maxPrefixLength;
|
||||
} else {
|
||||
me.maxValue = 7;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user