Updates for 'admin' buttons:

- Make them work like proper links
- Hidden if 'hide_admin_link' customization option is set
- Check for user staff status
This commit is contained in:
Oliver Walters 2022-11-01 23:17:18 +11:00
parent 058587d86c
commit 00e570ca2a
2 changed files with 11 additions and 10 deletions

View File

@ -127,13 +127,6 @@ function inventreeDocReady() {
loadBrandIcon($(this), $(this).attr('brand_name'));
});
// Callback for "admin view" button
$('#admin-button, .admin-button').click(function() {
var url = $(this).attr('url');
location.href = url;
});
// Display any cached alert messages
showCachedAlerts();

View File

@ -1,4 +1,12 @@
{% load inventree_extras %}
{% load i18n %}
<button id='admin-button' title='{% trans "View in administration panel" %}' type='button' class='btn btn-primary admin-button' url='{{ url }}'>
<span class='fas fa-user-shield'></span>
</button>
{% inventree_customize 'hide_admin_link' as hidden %}
{% if not hidden and user.is_staff %}
<a href='{{ url }}'>
<button id='admin-button' href='{{ url }}' title='{% trans "View in administration panel" %}' type='button' class='btn btn-primary admin-button'>
<span class='fas fa-user-shield'></span>
</button>
</a>
{% endif %}