]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: rbd: storage: obsolete strange getBinds binding assembly
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 15 Nov 2018 12:20:10 +0000 (13:20 +0100)
committerDominik Csapak <d.csapak@proxmox.com>
Mon, 19 Nov 2018 09:40:49 +0000 (10:40 +0100)
this was added for our (also in other places used):
> xtype: me.isCreate ? 'pveCephPoolSelector' : 'displayfield',
construct. But as displayfield does not has a submitValue setter we
cannot bind it generally.

So add such a setter with a small override and declare the bindings
direct when declaring the items, less side effects and all the
configurations for an item stays in the same place.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/Toolkit.js
www/manager6/storage/RBDEdit.js

index 0c9364bd60e282db418cd1e0d8ead6cad5efb4da..55b127c5f85725bed2bbf7fe1b9270d4ac5f5c2b 100644 (file)
@@ -27,3 +27,12 @@ Ext.apply(Ext.form.field.VTypes, {
     IP64AddressListText: gettext('Example') + ': 192.168.1.1,192.168.1.2',
     IP64AddressListMask: /[A-Fa-f0-9\,\:\.\;\ ]/
 });
+
+Ext.define('PVE.form.field.Display', {
+    override: 'Ext.form.field.Display',
+
+    setSubmitValue: function(value) {
+       // do nothing, this is only to allow generalized  bindings for the:
+       // `me.isCreate ? 'textfield' : 'displayfield'` cases we have.
+    }
+});
index 22efef1002fefca1501010a65e3f338d3f981ef2..c38759dfb1f134ccdbbc1db68bd155be87975648 100644 (file)
@@ -98,28 +98,16 @@ Ext.define('PVE.storage.RBDInputPanel', {
        }
        me.type = 'rbd';
 
-       var getBinds = function (activeIfPVECeph, hide) {
-           var bind = {
-               disabled: activeIfPVECeph ? '{!pveceph}' : '{pveceph}'
-           };
-
-           // displayfield has no submitValue and bind mixin cannot handle that
-           if (me.isCreate) {
-               bind.submitValue = activeIfPVECeph ? '{pveceph}' : '{!pveceph}';
-           }
-           if (hide) {
-               bind.hidden = activeIfPVECeph ? '{!pveceph}' : '{pveceph}';
-           }
-
-           return bind;
-       };
-
        me.column1 = [
            {
                xtype: me.isCreate ? 'pveCephPoolSelector' : 'displayfield',
                nodename: me.nodename,
                name: 'pool',
-               bind: getBinds(true, true),
+               bind: {
+                   disabled: '{!pveceph}',
+                   submitValue: '{pveceph}',
+                   hidden: '{!pveceph}'
+               },
                fieldLabel: gettext('Pool'),
                allowBlank: false
            },
@@ -127,7 +115,11 @@ Ext.define('PVE.storage.RBDInputPanel', {
                xtype: me.isCreate ? 'textfield' : 'displayfield',
                name: 'pool',
                value: 'rbd',
-               bind: getBinds(false, true),
+               bind: {
+                   disabled: '{pveceph}',
+                   submitValue: '{!pveceph}',
+                   hidden: '{pveceph}'
+               },
                fieldLabel: gettext('Pool'),
                allowBlank: false
            },
@@ -135,7 +127,11 @@ Ext.define('PVE.storage.RBDInputPanel', {
                xtype: 'textfield',
                name: 'monhost',
                vtype: 'HostList',
-               bind: getBinds(false, true),
+               bind: {
+                   disabled: '{pveceph}',
+                   submitValue: '{!pveceph}',
+                   hidden: '{pveceph}'
+               },
                value: '',
                fieldLabel: 'Monitor(s)',
                allowBlank: false
@@ -153,7 +149,10 @@ Ext.define('PVE.storage.RBDInputPanel', {
            {
                xtype: me.isCreate ? 'textfield' : 'displayfield',
                name: 'username',
-               bind: me.isCreate ? getBinds(false) : {},
+               bind: {
+                   disabled: '{pveceph}',
+                   submitValue: '{!pveceph}'
+               },
                value: 'admin',
                fieldLabel: gettext('User name'),
                allowBlank: true