[pve-devel] [PATCH v5 03/15] ui: parser: add helpers for lists of property strings

Dominik Csapak d.csapak at proxmox.com
Tue Jun 6 15:52:10 CEST 2023


namely the filtering while preserving the original string and general
parsing

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

diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
index c3772d3b..21a12311 100644
--- a/www/manager6/Parser.js
+++ b/www/manager6/Parser.js
@@ -604,5 +604,19 @@ Ext.define('PVE.Parser', {
 	});
 	return [res, extradata];
     },
+
+     // returns the list of parsed propety strings
+    parsePropertyStringList: function(list, defaultKey) {
+	if (!Ext.isArray(list)) {
+	    return [];
+	}
+
+	return list.map((entry) => PVE.Parser.parsePropertyString(entry, defaultKey));
+    },
+
+    filterPropertyStringList: function(list, filterFn, defaultKey) {
+	let parsed = list.map((entry) => [PVE.Parser.parsePropertyString(entry, defaultKey), entry]);
+	return parsed.filter(([entry, _]) => filterFn(entry)).map(([_, entry]) => entry);
+    },
 },
 });
-- 
2.30.2






More information about the pve-devel mailing list