Added possibility to load profiles from label generator dialog.

This commit is contained in:
Jan Böhmer 2020-05-08 12:43:04 +02:00
parent d8adc26b03
commit 1f48247474
3 changed files with 91 additions and 3 deletions

View file

@ -140,6 +140,7 @@ class LabelController extends AbstractController
'form' => $form->createView(),
'pdf_data' => $pdf_data,
'filename' => $filename,
'profile' => $profile,
]);
}

View file

@ -1,16 +1,27 @@
{% extends 'main_card.html.twig' %}
{% block card_title %}<i class="fas fa-qrcode fa-fw"></i> {% trans %}label_generator.title{% endtrans %}{% endblock %}
{% block title %}{% trans %}label_generator.title{% endtrans %}{% endblock %}
{%- block card_title -%}
<i class="fas fa-qrcode fa-fw"></i> {% trans %}label_generator.title{% endtrans %}
{% if profile %}({{ profile.name }}){% endif %}
{%- endblock -%}
{% block card_content %}
{{ form_start(form) }}
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" id="common-tab" role="tab" aria-controls="common" aria-selected="true" href="#common">Common</a>
<a class="nav-link active" data-toggle="tab" id="common-tab" role="tab" aria-controls="common" aria-selected="true" href="#common"
>{% trans %}label_generator.common{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" id="advanced-tab" role="tab" aria-controls="common" aria-selected="false" href="#advanced">Advanced</a>
<a class="nav-link" data-toggle="tab" id="advanced-tab" role="tab" aria-controls="advanced" aria-selected="false" href="#advanced"
>{% trans %}label_generator.advanced{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" id="profiles-tab" role="tab" aria-controls="profiles" aria-selected="false" href="#profiles"
>{% trans %}label_generator.profiles{% endtrans %}</a>
</li>
</ul>
@ -41,8 +52,48 @@
{{ form_row(form.options.additional_css) }}
{{ form_widget(form.options) }}
</div>
<div class="tab-pane" id="profiles" role="tabpanel" aria-labelledby="profiles-tab">
<div class="form-group row">
<label class="col-sm-3 col-form-label">{% trans %}label_generator.selected_profile{% endtrans %}</label>
<div class="col-sm-9">
<span class="form-control-plaintext">{{ profile.name ?? '-' }}
{% if profile %}
<a href="{{ profile | entityURL('edit') }}" title="{% trans %}label_generator.edit_profile{% endtrans %}"
><i class="fas fa-edit"></i></a>
{% endif %}
</span>
</div>
</div>
<div class="form-group row">
<div class="offset-sm-3 col-sm-9">
<div class="dropdown">
<button class="btn btn-info dropdown-toggle" type="button" id="loadProfilesButton"
{% if not is_granted("@labels.create_labels") %}disabled{% endif %}
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% trans %}label_generator.load_profile{% endtrans %}
</button>
<div class="dropdown-menu" aria-labelledby="loadProfilesButton">
{% if is_granted("@labels.create_labels") %}
{% for type in constant("App\\Entity\\LabelSystem\\LabelOptions::SUPPORTED_ELEMENTS") %}
{% set profiles = label_profile_dropdown_helper.dropdownProfiles(type) %}
{% if profiles is not empty %}
<h6 class="dropdown-header">{{ (type~'.label') | trans }}</h6>
{% endif %}
{% for profile in profiles %}
<a class="dropdown-item" href="{{ path('label_dialog_profile', {'profile': profile.id }) }}">{{ profile.name }}</a>
{% endfor %}
{% endfor %}
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{{ form_end(form) }}
{% if pdf_data %}
<div class="row">

View file

@ -8436,5 +8436,41 @@ Element 3</target>
<target>Code 128 (recommended)</target>
</segment>
</unit>
<unit id="qHJOVv6" name="label_generator.common">
<segment>
<source>label_generator.common</source>
<target>Common</target>
</segment>
</unit>
<unit id="wNFVz._" name="label_generator.profiles">
<segment>
<source>label_generator.profiles</source>
<target>Profiles</target>
</segment>
</unit>
<unit id="WLpYniK" name="label_generator.advanced">
<segment>
<source>label_generator.advanced</source>
<target>Advanced</target>
</segment>
</unit>
<unit id="CjbZJ5j" name="label_generator.selected_profile">
<segment>
<source>label_generator.selected_profile</source>
<target>Currently selected profile</target>
</segment>
</unit>
<unit id="HqINOSK" name="label_generator.edit_profile">
<segment>
<source>label_generator.edit_profile</source>
<target>Edit profile</target>
</segment>
</unit>
<unit id="fZChaHF" name="label_generator.load_profile">
<segment>
<source>label_generator.load_profile</source>
<target>Load profile</target>
</segment>
</unit>
</file>
</xliff>