mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-02 01:04:41 +02:00
Added permissions to label system.
This commit is contained in:
parent
fde1d7be4f
commit
5a9be023b1
6 changed files with 62 additions and 27 deletions
|
@ -1,17 +1,24 @@
|
|||
{% macro profile_dropdown(type, id = null, include_text = true, btn_type = 'btn-secondary') %}
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn {{ btn_type }} dropdown-toggle" title="{% trans %}label_generator.label_btn{% endtrans %}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<button type="button" class="btn {{ btn_type }} dropdown-toggle" title="{% trans %}label_generator.label_btn{% endtrans %}"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" {% if not is_granted("@labels.create_labels") %}disabled{% endif %}>
|
||||
<i class="fas fa-fw fa-qrcode"></i> {% if include_text %}{% trans %}label_generator.label_btn{% endtrans %}{% endif %}
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
{% set profiles = label_profile_dropdown_helper.dropdownProfiles(type) %}
|
||||
{% if is_granted('@labels.read_profiles') %}
|
||||
{% set profiles = label_profile_dropdown_helper.dropdownProfiles(type) %}
|
||||
{% else %}
|
||||
{% set profiles = [] %}
|
||||
{% endif %}
|
||||
{% for profile in profiles %}
|
||||
<a class="dropdown-item" href="{{ path('label_dialog_profile', {'profile': profile.id, 'target_type': type, 'target_id': id, 'generate': true}) }}">{{ profile.name }}</a>
|
||||
{% endfor %}
|
||||
{% if profiles is not empty %}
|
||||
{% if profiles is not empty and is_granted('@labels.edit_options') %}
|
||||
<div class="dropdown-divider"></div>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href="{{ path('label_dialog', {'target_type': type, 'target_id': id}) }}">{% trans %}label_generator.label_empty{% endtrans %}</a>
|
||||
{% if is_granted('@labels.edit_options') %} {# An empty dialog does not make much sense, when you can not edit the options... #}
|
||||
<a class="dropdown-item" href="{{ path('label_dialog', {'target_type': type, 'target_id': id}) }}">{% trans %}label_generator.label_empty{% endtrans %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
Loading…
Add table
Add a link
Reference in a new issue