]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
combogrid: add deleteEmpty and skipEmptyText
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 27 Jun 2019 12:21:43 +0000 (14:21 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 27 Jun 2019 12:21:46 +0000 (14:21 +0200)
Slightly adapted from the proxmox textfield version of this

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
form/ComboGrid.js

index 970e363ce27ce8621fd6030f2d75f0acf2539e4f..fee08dd7f12d9610c61cbb783674f61e5ae9488a 100644 (file)
@@ -27,6 +27,11 @@ Ext.define('Proxmox.form.ComboGrid', {
         me.callParent(arguments);
     },
 
+    config: {
+       skipEmptyText: false,
+       deleteEmpty: false,
+    },
+
     // needed to trigger onKeyUp etc.
     enableKeyEvents: true,
 
@@ -51,6 +56,34 @@ Ext.define('Proxmox.form.ComboGrid', {
        }
     },
 
+    getSubmitData: function() {
+       var me = this;
+
+       let data = null;
+       if (!me.disabled && me.submitValue) {
+           let val = me.getSubmitValue();
+           if (val !== null) {
+               data = {};
+               data[me.getName()] = val;
+           } else if (me.getDeleteEmpty()) {
+               data = {};
+               data['delete'] = me.getName();
+           }
+       }
+       return data;
+   },
+
+    getSubmitValue: function() {
+       var me = this;
+
+       var value = me.callParent();
+       if (value !== '') {
+           return value;
+       }
+
+       return me.getSkipEmptyText() ? null: value;
+    },
+
     setAllowBlank: function(allowBlank) {
        this.allowBlank = allowBlank;
        this.validate();