{% macro boolean(value) %} {% if value %} {% trans %}bool.true{% endtrans %} {% else %} {% trans %}bool.false{% endtrans %} {% endif %} {% endmacro %} {% macro array_to_tags(tags, class="badge bg-primary") %} {% for tag in tags %} {{ tag | trim }} {% endfor %} {% endmacro %} {% macro bool_icon(bool) %} {% if bool %} {% else %} {% endif %} {% endmacro %} {% macro boolean_badge(value, class="badge") %} {% if value %} {% set class = class ~ ' bg-success' %} {% else %} {% set class = class ~ ' bg-danger' %} {% endif %} {{ _self.bool_icon(value) }} {{ _self.boolean(value) }} {% endmacro %} {% macro string_to_tags(string, class="badge bg-info") %} {% for tag in string|split(',') %} {{ tag | trim }} {% endfor %} {% endmacro %} {% macro m_status_to_badge(status, class="badge") %} {% if status is enum %} {% set status = status.value %} {% endif %} {% if status is not empty %} {% set color = " bg-secondary" %} {% if status == "active" %} {% set color = " bg-success" %} {% elseif status == "nrfnd" %} {% set color = " bg-warning" %} {% elseif status == "eol" %} {% set color = " bg-warning" %} {% elseif status == "discontinued" %} {% set color = " bg-danger" %} {% endif %} {{ ("m_status." ~ status) | trans }} {% endif %} {% endmacro %} {% macro project_status_to_badge(status, class="badge") %} {% if status is not empty %} {% set color = " bg-secondary" %} {% if status == "in_production" %} {% set color = " bg-success" %} {% endif %} {{ ("project.status." ~ status) | trans }} {% endif %} {% endmacro %} {% macro structural_entity_link(entity, link_type = "list_parts") %} {# @var entity \App\Entity\Base\StructuralDBElement #} {% if entity %} {% else %} - {% endif %} {% endmacro %} {% 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", "project.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 %} {% endmacro %} {% macro breadcrumb_entity_link(entity, link_type = "list_parts", icon = "") %} {% 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_history', entity) %} {% if lastModified == true %} {% set user = last_editing_user(entity) %} {% else %} {% set user = creating_user(entity) %} {% endif %} {% if user is not null %} ({{ _self.user_icon_link(user) }}) {% endif %} {% endif %} {% endmacro %} {% macro entity_last_modified(entity, datetime_format = "short") %} {{ _self.date_user_combination(entity, true, datetime_format) }} {% endmacro %} {% macro entity_created_at(entity, datetime_format = "short") %} {{ _self.date_user_combination(entity, false, datetime_format) }} {% endmacro %} {% macro user_icon(user) %} User avatar {% endmacro %} {% macro user_icon_link(user) %} {% if user.fullName is not empty %} {{ _self.user_icon(user) }} {{ user.fullName }} {% else %} {{ _self.user_icon(user) }} @{{ user.name }} {% endif %} {% endmacro %} {% macro part_icon_link(part) %} {% set preview_attach = part_preview_generator.tablePreviewAttachment(part) %} {% if preview_attach %} Part image {% endif %} {{ part.name }} {% endmacro %} {% macro entity_preview_sm(entity) %} {# @var entity \App\Entity\Contracts\HasMasterAttachmentInterface #} {% if entity.masterPictureAttachment and entity.masterPictureAttachment.picture and attachment_manager.fileExisting(entity.masterPictureAttachment) %} {% endif %} {% endmacro %} {% macro entity_preview_xs(entity) %} {# @var entity \App\Entity\Contracts\HasMasterAttachmentInterface #} {% if entity.masterPictureAttachment and entity.masterPictureAttachment.picture and attachment_manager.fileExisting(entity.masterPictureAttachment) %} {% endif %} {% endmacro %} {% macro parameters_table(parameters) %} {% for param in parameters %} {% endfor %}
{% trans %}specifications.property{% endtrans %} {% trans %}specifications.value{% endtrans %}
{{ param.name }} {% if param.symbol is not empty %}${{ param.symbol }}${% endif %} {{ param.formattedValue }}
{% endmacro parameters_table %} {% macro format_date_nullable(datetime) %} {% if datetime is null %} {% trans %}datetime.never{% endtrans %} {% else %} {{ datetime|format_datetime }} {% endif %} {% endmacro %}