[pve-devel] [PATCH widget-toolkit 1/7] add pmxUserSelector

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Nov 9 12:27:15 CET 2021


copied from pbs

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 src/Makefile             |  1 +
 src/form/UserSelector.js | 50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100644 src/form/UserSelector.js

diff --git a/src/Makefile b/src/Makefile
index a490ccd..cc464c3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -42,6 +42,7 @@ JSSRC=					\
 	form/MultiDiskSelector.js	\
 	form/TaskTypeSelector.js	\
 	form/ACME.js			\
+	form/UserSelector.js		\
 	button/Button.js		\
 	button/HelpButton.js		\
 	grid/ObjectGrid.js		\
diff --git a/src/form/UserSelector.js b/src/form/UserSelector.js
new file mode 100644
index 0000000..ce66fab
--- /dev/null
+++ b/src/form/UserSelector.js
@@ -0,0 +1,50 @@
+Ext.define('Proxmox.form.UserSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: 'widget.pmxUserSelector',
+
+    allowBlank: false,
+    autoSelect: false,
+    valueField: 'userid',
+    displayField: 'userid',
+
+    editable: true,
+    anyMatch: true,
+    forceSelection: true,
+
+    store: {
+	model: 'pmx-users',
+	autoLoad: true,
+	params: {
+	    enabled: 1,
+	},
+	sorters: 'userid',
+    },
+
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('User'),
+		sortable: true,
+		dataIndex: 'userid',
+		renderer: Ext.String.htmlEncode,
+		flex: 1,
+	    },
+	    {
+		header: gettext('Name'),
+		sortable: true,
+		renderer: (first, mD, rec) => Ext.String.htmlEncode(
+		    `${first || ''} ${rec.data.lastname || ''}`,
+		),
+		dataIndex: 'firstname',
+		flex: 1,
+	    },
+	    {
+		header: gettext('Comment'),
+		sortable: false,
+		dataIndex: 'comment',
+		renderer: Ext.String.htmlEncode,
+		flex: 1,
+	    },
+	],
+    },
+});
-- 
2.30.2






More information about the pve-devel mailing list