From dec7b337c675c974aa7f1e2a5b14cd791dfefe53 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 1 Jun 2017 14:13:27 +0530 Subject: [PATCH] add toString method to frappe.user --- frappe/public/js/frappe/misc/user.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frappe/public/js/frappe/misc/user.js b/frappe/public/js/frappe/misc/user.js index 9224e2756d..ee97b6889d 100644 --- a/frappe/public/js/frappe/misc/user.js +++ b/frappe/public/js/frappe/misc/user.js @@ -141,6 +141,19 @@ $.extend(frappe.user, { quote: quote }); } + }, + + /* Normally frappe.user is an object + * having properties and methods. + * But in the following case + * + * if (frappe.user === 'Administrator') + * + * frappe.user will cast to a string + * returning frappe.user.name + */ + toString: function() { + return this.name; } });