From 90a54a0435184bc00d787c22f1e7cb99432ba2f1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 4 Oct 2012 13:53:50 +0530 Subject: [PATCH] fixed: hide links based on roles in accounts home --- accounts/page/accounts_home/accounts_home.html | 4 ++-- accounts/page/accounts_home/accounts_home.js | 7 ------- public/js/modules.js | 5 ++++- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/accounts/page/accounts_home/accounts_home.html b/accounts/page/accounts_home/accounts_home.html index 3a6f2b8426..db87a49720 100644 --- a/accounts/page/accounts_home/accounts_home.html +++ b/accounts/page/accounts_home/accounts_home.html @@ -12,7 +12,7 @@

Bills raised by Suppliers

-

Chart of Accounts

+

Chart of Accounts

Structure of books of accounts


Chart of Cost Centers

@@ -74,7 +74,7 @@ href="#!Financial Statements">Financial Statements
- Voucher Import Tool
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 8e71151e65..3815578d34 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -22,11 +22,4 @@ pscript['onload_accounts-home'] = function(wrapper) { $('.india-specific').toggle(false); } - if(wn.boot.profile.roles.indexOf('Accounts Manager')==-1 && wn.boot.profile.roles.indexOf('Accounts User')==-1) { - $('[href*="Accounts Browser"]').each(function() { - var txt = $(this).text(); - $(this).parent().css('color', '#999').html(txt); - }); - } - } diff --git a/public/js/modules.js b/public/js/modules.js index a9e82d6ff8..9b554e9967 100644 --- a/public/js/modules.js +++ b/public/js/modules.js @@ -128,7 +128,10 @@ erpnext.module_page.hide_links = function(wrapper) { // pages $(wrapper).find('[data-role]').each(function() { - if(!has_common(user_roles, [$(this).attr("data-role"), "System Manager"])) { + // can define multiple roles + var data_roles = $(this).attr("data-role").split(",").map(function(role) { + return role.trim(); }); + if(!has_common(user_roles, ["System Manager"].concat(data_roles))) { var html = $(this).html(); $(this).parent().css('color', '#999'); $(this).replaceWith('