[pve-devel] [PATCH manager] gui: refactor render_full_name
Dominik Csapak
d.csapak at proxmox.com
Mon Nov 19 12:51:38 CET 2018
this also fixes a missing htmlEncode in UserSelector
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Utils.js | 6 ++++++
www/manager6/dc/UserView.js | 9 +--------
www/manager6/form/UserSelector.js | 9 +--------
3 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 49b5786a..a190a7ab 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -806,6 +806,12 @@ Ext.define('PVE.Utils', { utilities: {
return value;
},
+ render_full_name: function(firstname, metaData, record) {
+ var first = firstname || '';
+ var last = record.data.lastname || '';
+ return Ext.htmlEncode(first + " " + last);
+ },
+
windowHostname: function() {
return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
function(m, addr, offset, original) { return addr; });
diff --git a/www/manager6/dc/UserView.js b/www/manager6/dc/UserView.js
index 5f8bed17..4d0c5595 100644
--- a/www/manager6/dc/UserView.js
+++ b/www/manager6/dc/UserView.js
@@ -92,13 +92,6 @@ Ext.define('PVE.dc.UserView', {
edit_btn, remove_btn, pwchange_btn
];
- var render_full_name = function(firstname, metaData, record) {
-
- var first = firstname || '';
- var last = record.data.lastname || '';
- return Ext.htmlEncode(first + " " + last);
- };
-
var render_username = function(userid) {
return userid.match(/^(.+)(@[^@]+)$/)[1];
};
@@ -147,7 +140,7 @@ Ext.define('PVE.dc.UserView', {
header: gettext('Name'),
width: 150,
sortable: true,
- renderer: render_full_name,
+ renderer: PVE.Utils.render_full_name,
dataIndex: 'firstname'
},
{
diff --git a/www/manager6/form/UserSelector.js b/www/manager6/form/UserSelector.js
index 8eafe0e8..cd01bc3e 100644
--- a/www/manager6/form/UserSelector.js
+++ b/www/manager6/form/UserSelector.js
@@ -21,13 +21,6 @@ Ext.define('PVE.form.UserSelector', {
}]
});
- var render_full_name = function(firstname, metaData, record) {
-
- var first = firstname || '';
- var last = record.data.lastname || '';
- return first + " " + last;
- };
-
Ext.apply(me, {
store: store,
listConfig: {
@@ -41,7 +34,7 @@ Ext.define('PVE.form.UserSelector', {
{
header: gettext('Name'),
sortable: true,
- renderer: render_full_name,
+ renderer: PVE.Utils.render_full_name,
dataIndex: 'firstname',
flex: 1
},
--
2.11.0
More information about the pve-devel
mailing list