Moved quick link logic into an macro

This commit is contained in:
Jan Böhmer 2022-10-09 20:39:51 +02:00
parent 74a563a75a
commit a01ed3acf6
5 changed files with 25 additions and 19 deletions

View file

@ -22,5 +22,6 @@
{% endblock %} {% endblock %}
{% block quick_links %} {% block quick_links %}
{% include 'QuickLinks/_company.html.twig' %} {% import "components/quick_links.macro.html.twig" as quick_links %}
{{ quick_links.company(entity) }}
{% endblock %} {% endblock %}

View file

@ -9,7 +9,8 @@
{% embed "Parts/lists/_info_card.html.twig" with {'header_label': 'manufacturer.label'} %} {% embed "Parts/lists/_info_card.html.twig" with {'header_label': 'manufacturer.label'} %}
{% block quick_links %} {% block quick_links %}
<div class="mb-2"> <div class="mb-2">
{% include 'QuickLinks/_company.html.twig' %} {% import "components/quick_links.macro.html.twig" as quick_links %}
{{ quick_links.company(entity) }}
</div> </div>
{% endblock %} {% endblock %}
{% endembed %} {% endembed %}

View file

@ -9,7 +9,8 @@
{% embed "Parts/lists/_info_card.html.twig" with {'header_label': 'supplier.label'} %} {% embed "Parts/lists/_info_card.html.twig" with {'header_label': 'supplier.label'} %}
{% block quick_links %} {% block quick_links %}
<div class="mb-2"> <div class="mb-2">
{% include 'QuickLinks/_company.html.twig' %} {% import "components/quick_links.macro.html.twig" as quick_links %}
{{ quick_links.company(entity) }}
</div> </div>
{% endblock %} {% endblock %}
{% endembed %} {% endembed %}

View file

@ -1,16 +0,0 @@
<div class="btn-toolbar">
<div class="btn-group">
{% if entity.website is not empty %}
<a class="btn btn-outline-secondary" href="{{ entity.website }}" title="{% trans %}company.edit.quick.website{% endtrans %}" data-turbo="false"><i class="fas fa-globe fa-fw"></i></a>
{% endif %}
{% if entity.emailAddress is not empty %}
<a class="btn btn-outline-secondary" href="mailto:{{ entity.emailAddress }}" title="{% trans %}company.edit.quick.email{% endtrans %}" data-turbo="false"><i class="fas fa-envelope-open-text"></i></a>
{% endif %}
{% if entity.phoneNumber is not empty %}
<a class="btn btn-outline-secondary" href="tel:{{ entity.phoneNumber | replace({' ': ''}) }}" title="{% trans %}company.edit.quick.phone{% endtrans %}" data-turbo="false"><i class="fas fa-phone"></i></a>
{% endif %}
{% if entity.faxNumber is not empty %}
<a class="btn btn-outline-secondary" href="tel:{{ entity.faxNumber | replace({' ': ''}) }}" title="{% trans %}company.edit.quick.fax{% endtrans %}" data-turbo="false"><i class="fas fa-fax"></i></a>
{% endif %}
</div>
</div>

View file

@ -0,0 +1,19 @@
{# Renders an btn toolbar to quickly call/email or visit the website of a company #}
{% macro company(entity) %}
<div class="btn-toolbar">
<div class="btn-group">
{% if entity.website is not empty %}
<a class="btn btn-outline-secondary" href="{{ entity.website }}" title="{% trans %}company.edit.quick.website{% endtrans %}" target="_blank" rel="nofollow"><i class="fas fa-globe fa-fw"></i></a>
{% endif %}
{% if entity.emailAddress is not empty %}
<a class="btn btn-outline-secondary" href="mailto:{{ entity.emailAddress }}" title="{% trans %}company.edit.quick.email{% endtrans %}" target="_blank" rel="nofollow"><i class="fas fa-envelope-open-text"></i></a>
{% endif %}
{% if entity.phoneNumber is not empty %}
<a class="btn btn-outline-secondary" href="tel:{{ entity.phoneNumber | replace({' ': ''}) }}" title="{% trans %}company.edit.quick.phone{% endtrans %}" target="_blank" rel="nofollow"><i class="fas fa-phone"></i></a>
{% endif %}
{% if entity.faxNumber is not empty %}
<a class="btn btn-outline-secondary" href="tel:{{ entity.faxNumber | replace({' ': ''}) }}" title="{% trans %}company.edit.quick.fax{% endtrans %}" target="_blank" rel="nofollow"><i class="fas fa-fax"></i></a>
{% endif %}
</div>
</div>
{% endmacro %}