2019-08-02 14:44:58 +02:00
|
|
|
{% macro boolean(value) %}
|
|
|
|
{% if value %}
|
|
|
|
{% trans %}bool.true{% endtrans %}
|
|
|
|
{% else %}
|
|
|
|
{% trans %}bool.false{% endtrans %}
|
|
|
|
{% endif %}
|
2019-08-10 19:04:47 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-3x", link = true) %}
|
2020-03-30 16:56:58 +02:00
|
|
|
{% set disabled = attachment.secure and not is_granted("show_secure", attachment) %}
|
2019-08-10 19:04:47 +02:00
|
|
|
{% if not attachment_helper or attachment_helper.fileExisting(attachment) %}
|
2020-03-30 16:56:58 +02:00
|
|
|
{% if link and not disabled %}
|
2022-07-24 22:48:21 +02:00
|
|
|
<a target="_blank" data-turbo="false" rel="noopener" href="{{ attachment|entityURL('file_view') }}">
|
|
|
|
{% endif %}
|
|
|
|
{% if attachment.picture %}
|
2022-07-29 23:54:49 +02:00
|
|
|
<img class="hoverpic" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ attachment|entityURL('file_view') }}" src="{{ attachment|entityURL('file_view') }}">
|
2022-07-24 22:48:21 +02:00
|
|
|
{% else %}
|
|
|
|
<i class="text-dark {{ class }} {{ ext_to_fa_icon(attachment.extension) }}"></i>
|
2020-03-30 16:56:58 +02:00
|
|
|
{% endif %}
|
|
|
|
{% if link and not disabled %}
|
2022-07-24 22:48:21 +02:00
|
|
|
</a>
|
2020-03-30 16:56:58 +02:00
|
|
|
{% endif %}
|
2019-08-10 19:04:47 +02:00
|
|
|
{% elseif not attachment_helper.fileExisting(attachment) %}
|
2020-05-27 22:06:32 +02:00
|
|
|
<i class="{{ class }} fa-exclamation-triangle text-danger" title="{% trans %}attachment.file_not_found{% endtrans %}"></i>
|
2019-08-10 19:04:47 +02:00
|
|
|
{% endif %}
|
2019-08-15 22:59:34 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
2022-07-24 22:39:32 +02:00
|
|
|
{% macro string_to_tags(string, class="badge bg-info") %}
|
2019-08-15 22:59:34 +02:00
|
|
|
{% for tag in string|split(',') %}
|
2022-08-04 21:00:42 +02:00
|
|
|
<a href="{{ path('part_list_tags', {'tag': tag | trim | url_encode}) }}" class="{{ class }}" >{{ tag | trim }}</a>
|
2019-08-15 22:59:34 +02:00
|
|
|
{% endfor %}
|
2019-09-02 18:41:57 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro m_status_to_badge(status, class="badge") %}
|
|
|
|
{% if status is not empty %}
|
2022-07-24 22:39:32 +02:00
|
|
|
{% set color = " bg-secondary" %}
|
2019-09-02 18:41:57 +02:00
|
|
|
|
|
|
|
{% if status == "active" %}
|
2022-07-24 22:39:32 +02:00
|
|
|
{% set color = " bg-success" %}
|
2019-09-02 18:41:57 +02:00
|
|
|
{% elseif status == "nrfnd" %}
|
2022-07-24 22:39:32 +02:00
|
|
|
{% set color = " bg-warning" %}
|
2019-09-02 18:41:57 +02:00
|
|
|
{% elseif status == "eol" %}
|
2022-07-24 22:39:32 +02:00
|
|
|
{% set color = " bg-warning" %}
|
2019-09-02 18:41:57 +02:00
|
|
|
{% elseif status == "discontinued" %}
|
2022-07-24 22:39:32 +02:00
|
|
|
{% set color = " bg-danger" %}
|
2019-09-02 18:41:57 +02:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<span class="{{ class ~ color}}" title="{{ ("m_status." ~ status ~ ".help") | trans }}">
|
|
|
|
<i class="fa-fw fas fa-info-circle"></i>
|
|
|
|
{{ ("m_status." ~ status) | trans }}
|
|
|
|
</span>
|
|
|
|
{% endif %}
|
2019-09-08 16:20:53 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro structural_entity_link(entity, link_type = "list_parts") %}
|
|
|
|
{# @var entity \App\Entity\Base\StructuralDBElement #}
|
|
|
|
{% if entity %}
|
|
|
|
<ul class="structural_link d-inline">
|
|
|
|
{% for e in entity.pathArray %}
|
|
|
|
<li>
|
2019-09-16 13:27:53 +02:00
|
|
|
{% if link_type is not empty and e.id is not null %}
|
2019-09-08 16:20:53 +02:00
|
|
|
<a href="{{ e | entityURL(link_type) }}">{{ e.name }}</a>
|
|
|
|
{% else %}
|
|
|
|
{{ e.name }}
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% else %}
|
|
|
|
-
|
|
|
|
{% endif %}
|
2019-09-08 16:29:56 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
2022-09-04 23:02:31 +02:00
|
|
|
{% macro entity_icon(entity_or_type, classes = "", style = "") %}
|
|
|
|
{% set map = {
|
|
|
|
"attachment_type": ["fa-solid fa-file-alt", "attachment_type.label"],
|
|
|
|
"category": ["fa-solid fa-tags", "category.label"],
|
|
|
|
"currency": ["fa-solid fa-coins", "currency.label"],
|
|
|
|
"device": ["fa-solid fa-archive", "device.label"],
|
|
|
|
"footprint": ["fa-solid fa-microchip", "footprint.label"],
|
|
|
|
"group": ["fa-solid fa-users", "group.label"],
|
|
|
|
"label_profile": ["fa-solid fa-qrcode", "label_profile.label"],
|
|
|
|
"manufacturer": ["fa-solid fa-industry", "manufacturer.label"],
|
|
|
|
"measurement_unit": ["fa-solid fa-balance-scale", "measurement_unit.label"],
|
|
|
|
"storelocation": ["fa-solid fa-cube", "storelocation.label"],
|
|
|
|
"supplier": ["fa-solid fa-truck", "supplier.label"],
|
|
|
|
"user": ["fa-solid fa-user", "user.label"],
|
|
|
|
} %}
|
|
|
|
|
|
|
|
{% if entity_or_type is entity %}
|
|
|
|
{% set type = entity_type(entity_or_type) %}
|
|
|
|
{% else %}
|
|
|
|
{% set type = entity_or_type %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if type is not null and map[type] is defined %}
|
|
|
|
{% set icon = map[type][0] %}
|
|
|
|
{% set label = map[type][1] %}
|
|
|
|
{% else %}
|
|
|
|
{% set icon = "fa-solid fa-question" %}
|
|
|
|
{% set label = "Unknown type " ~ type %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<i class="fa-fw {{ icon }} {{ classes }}" style="{{ style }}" title="{{ label | trans }}"></i>
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro breadcrumb_entity_link(entity, link_type = "list_parts", icon = "") %}
|
|
|
|
<nav aria-label="breadcrumb">
|
|
|
|
<ol class="breadcrumb py-2 px-3 rounded" style="background-color: var(--bs-gray-200);">
|
|
|
|
{% if icon is not empty %}
|
|
|
|
<i class="{{ icon }} fa-fw me-1" style="line-height: inherit;"></i>
|
|
|
|
{% else %}
|
|
|
|
{{ _self.entity_icon(entity, "me-1", "line-height: inherit;") }}
|
|
|
|
{% endif %}
|
|
|
|
{% for e in entity.pathArray %}
|
|
|
|
<li class="breadcrumb-item {% if loop.last %}active{% endif %}">
|
|
|
|
{% if link_type is not empty and not loop.last and e.id is not null %}
|
|
|
|
<a href="{{ e | entityURL(link_type) }}">{{ e.name }}</a>
|
|
|
|
{% else %}
|
|
|
|
{{ e.name }}
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ol>
|
|
|
|
</nav>
|
2019-12-29 20:04:52 +01:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro bool_icon(bool) %}
|
|
|
|
{% if bool %}
|
|
|
|
<i class="fas fa-check-circle fa-fw" title="{% trans %}Yes{% endtrans %}"></i>
|
|
|
|
{% else %}
|
|
|
|
<i class="fas fa-times-circle fa-fw" title="{% trans %}No{% endtrans %}"></i>
|
|
|
|
{% endif %}
|
2020-02-06 19:22:01 +01:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro date_user_combination(entity, lastModified, datetime_format = "short") %}
|
|
|
|
{% if lastModified == true %}
|
|
|
|
{{ entity.lastModified | format_datetime(datetime_format) }}
|
|
|
|
{% else %}
|
|
|
|
{{ entity.addedDate | format_datetime(datetime_format) }}
|
|
|
|
{% endif %}
|
|
|
|
{% if is_granted('show_users', entity) %}
|
|
|
|
{% if lastModified == true %}
|
|
|
|
{% set user = getLastEditingUser(entity) %}
|
|
|
|
{% else %}
|
|
|
|
{% set user = getCreatingUser(entity) %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if user is not null %}
|
|
|
|
{% if user.fullName is not empty %}
|
2022-08-04 21:00:42 +02:00
|
|
|
<a href="{{ path('user_info', {"id": user.id}) }}" title="@{{ user.name }}"><i>({{ user.fullName }})</i></a>
|
2020-02-06 19:22:01 +01:00
|
|
|
{% else %}
|
2022-08-04 21:00:42 +02:00
|
|
|
<a href="{{ path('user_info', {"id": user.id}) }}" title="@{{ user.name }}"><i>(@{{ user.name }})</i></a>
|
2020-02-06 19:22:01 +01:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2020-03-24 15:08:56 +01:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro parameters_table(parameters) %}
|
2022-07-24 22:48:21 +02:00
|
|
|
<table class="table table-hover table-striped table-sm">
|
|
|
|
<thead>
|
2020-03-24 15:08:56 +01:00
|
|
|
<tr>
|
2022-07-24 22:48:21 +02:00
|
|
|
<th>{% trans %}specifications.property{% endtrans %}</th>
|
|
|
|
<th>{% trans %}specifications.value{% endtrans %}</th>
|
2020-03-24 15:08:56 +01:00
|
|
|
</tr>
|
2022-07-24 22:48:21 +02:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for param in parameters %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ param.name }} {% if param.symbol is not empty %}<span class="latex" data-controller="common--latex">${{ param.symbol }}$</span>{% endif %}</td>
|
|
|
|
<td>{{ param.formattedValue }}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2020-03-24 15:08:56 +01:00
|
|
|
{% endmacro parameters_table %}
|