[pve-devel] [PATCH manager 3/5] gui: Utils: add propertyString helper

Dominik Csapak d.csapak at proxmox.com
Thu Oct 31 09:33:42 CET 2019


this helper conditionally sets the given value to the given property
on the given object, optionally a different value

this is useful for our MP/HD Edit panels, where we set the options
of the drive/mp this way for every gui option we have

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Utils.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 47f9d297..55b06e50 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1260,6 +1260,18 @@ Ext.define('PVE.Utils', { utilities: {
 	} else {
 	    return false;
 	}
+    },
+
+    propertyStringSet: function(target, source, name, value) {
+	if (source) {
+	    if (value === undefined) {
+		target[name] = source;
+	    } else {
+		target[name] = value;
+	    }
+	} else {
+	    delete target[name];
+	}
     }
 },
 
-- 
2.20.1





More information about the pve-devel mailing list