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;
+ }
+ },
});
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: {
datastore: '{datastore}',
},
listeners: {
- change: function(field, value) {
+ change: function(field, localNs) {
let me = this;
- let maxDepthField = me.up('pbsSyncJobEdit').down('field[name=max-depth]');
- maxDepthField.setLimit(me.up('pbsSyncJobEdit').calcMaxDepthLimit());
+ let view = me.up('pbsSyncJobEdit');
+
+ let remoteNs = view.down('pbsRemoteNamespaceSelector[name=remote-ns]').getValue();
+ let maxDepthField = view.down('field[name=max-depth]');
+ maxDepthField.setLimit(localNs, remoteNs);
maxDepthField.validate();
},
},
name: 'remote-ns',
disabled: true,
listeners: {
- change: function(field, value) {
+ change: function(field, remoteNs) {
let me = this;
- let remoteField = me.up('pbsSyncJobEdit').down('field[name=remote]');
- let remote = remoteField.getValue();
- 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());
+ let view = me.up('pbsSyncJobEdit');
+
+ let remote = view.down('field[name=remote]').getValue();
+ let remoteStore = view.down('field[name=remote-store]').getValue();
+ me.up('tabpanel').down('pbsGroupFilter').setRemoteNamespace(remote, remoteStore, remoteNs);
+
+ let localNs = view.down('pbsNamespaceSelector[name=ns]').getValue();
+ let maxDepthField = view.down('field[name=max-depth]');
+ maxDepthField.setLimit(localNs, remoteNs);
maxDepthField.validate();
},
},