fixed: hide links based on roles in accounts home

This commit is contained in:
Anand Doshi 2012-10-04 13:53:50 +05:30
parent 809226bcb7
commit 90a54a0435
3 changed files with 6 additions and 10 deletions

View File

@ -12,7 +12,7 @@
<p class="help">Bills raised by Suppliers</p>
</div>
<div style="width: 48%; float: right;">
<h4><a href="#!Accounts Browser/Account">Chart of Accounts</a></h4>
<h4><a href="#!Accounts Browser/Account" data-role="Accounts Manager, Accounts User">Chart of Accounts</a></h4>
<p class="help">Structure of books of accounts</p>
<br>
<h4><a href="#!Accounts Browser/Cost Center">Chart of Cost Centers</a></h4>
@ -74,7 +74,7 @@
href="#!Financial Statements">Financial Statements</a>
</div>
<div class="section-item">
<a class="section-link"
<a class="section-link" data-role="Accounts Manager"
title = "Import Multiple Vouchers from CSV"
href="#voucher-import-tool">Voucher Import Tool</a>
</div>

View File

@ -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);
});
}
}

View File

@ -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('<span title="Only accessible by Roles: '+