Use enums for LabelOptions

This commit is contained in:
Jan Böhmer 2023-06-12 23:39:30 +02:00
parent 485b35fbd4
commit 71cd4057a7
23 changed files with 329 additions and 157 deletions

View file

@ -77,10 +77,10 @@
</button>
<div class="dropdown-menu" aria-labelledby="loadProfilesButton">
{% if is_granted("@labels.create_labels") %}
{% for type in constant("App\\Entity\\LabelSystem\\LabelOptions::SUPPORTED_ELEMENTS") %}
{% for type in enum_cases("App\\Entity\\LabelSystem\\LabelSupportedElement") %}
{% set profiles = label_profile_dropdown_helper.dropdownProfiles(type) %}
{% if profiles is not empty %}
<h6 class="dropdown-header">{{ (type~'.label') | trans }}</h6>
<h6 class="dropdown-header">{{ (type.value~'.label') | trans }}</h6>
{% endif %}
{% for profile in profiles %}
<a class="dropdown-item" href="{{ path('label_dialog_profile', {'profile': profile.id }) }}">{{ profile.name }}</a>

View file

@ -14,11 +14,11 @@
<body>
{% for element in elements %}
<div class="page">
{% if options.barcodeType == 'none' %}
{% if options.barcodeType.none %}
{% include "label_system/labels/label_page_none.html.twig" %}
{% elseif options.barcodeType in ['qr', 'datamatrix'] %}
{% elseif options.barcodeType.is2D() %}
{% include "label_system/labels/label_page_qr.html.twig" %}
{% elseif options.barcodeType in ['code39', 'code93', 'code128'] %}
{% elseif options.barcodeType.is1D() %}
{% include "label_system/labels/label_page_1d.html.twig" %}
{% endif %}
</div>