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 file_extension_to_fa_icon(ext) %}
|
|
|
|
{% if ext in ['jpeg', 'jpg', 'gif', 'png', 'tiff', 'tif', 'webp', 'bmp', 'svg'] %} {# Images #}
|
|
|
|
fa-file-image
|
|
|
|
{% elseif ext in ['pdf'] %} {# PDFs #}
|
|
|
|
fa-file-pdf
|
|
|
|
{% elseif ext in ['txt', 'md', 'rtf'] %} {# Text files #}
|
|
|
|
fa-file-alt
|
|
|
|
{% elseif ext in ['csv'] %} {# CSV files #}
|
2019-08-11 17:24:54 +02:00
|
|
|
fa-file-csv
|
2019-08-10 19:04:47 +02:00
|
|
|
{% elseif ext in ['doc', 'docx', 'odt'] %} {# Documents #}
|
|
|
|
fa-file-word
|
|
|
|
{% elseif ext in ['zip', 'rar', 'bz2', 'tar', '7z', 'gz'] %}
|
|
|
|
fa-file-archive
|
|
|
|
{% elseif ext in ['mp3', 'wav', 'aac', 'm4a', 'wma'] %}
|
|
|
|
fa-file-audio
|
|
|
|
{% elseif ext in ['ppt', 'pptx', 'odp'] %}
|
|
|
|
fa-file-powerpoint
|
|
|
|
{% elseif ext in ['xls', 'xlsx', 'ods'] %}
|
|
|
|
fa-file-excel
|
|
|
|
{% elseif ext in ['php', 'xml', 'html', 'js', 'ts', 'htm', 'c', 'cpp'] %}
|
|
|
|
fa-file-code
|
|
|
|
{% elseif ext in ['webm', 'avi', 'mp4', 'mkv', 'wmv'] %} {# Videos#}
|
|
|
|
fa-file-video
|
|
|
|
{% else %}
|
|
|
|
fa-file
|
|
|
|
{% endif %}
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-3x", link = true) %}
|
|
|
|
{% if not attachment_helper or attachment_helper.fileExisting(attachment) %}
|
|
|
|
<a target="_blank" data-no-ajax href="{% if link %}{{ attachment|entityURL('file_view') }}{% endif %}">
|
2019-08-11 17:24:54 +02:00
|
|
|
{% if attachment.picture %}
|
|
|
|
<img class="hoverpic" src="{{ attachment|entityURL('file_view') }}">
|
|
|
|
{% else %}
|
|
|
|
<i class="text-dark {{ class }} {{ _self.file_extension_to_fa_icon(attachment.extension) }}"></i>
|
|
|
|
{% endif %}
|
2019-08-10 19:04:47 +02:00
|
|
|
</a>
|
|
|
|
{% elseif not attachment_helper.fileExisting(attachment) %}
|
|
|
|
<i class="{{ class }} fa-exclamation-triangle text-danger"></i>
|
|
|
|
{% endif %}
|
2019-08-15 22:59:34 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro string_to_tags(string, class="badge badge-info") %}
|
|
|
|
{% for tag in string|split(',') %}
|
2019-09-05 22:27:18 +02:00
|
|
|
<a href="{{ url('part_list_tags', {'tag': tag | trim}) }}" 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 %}
|
|
|
|
{% set color = " badge-secondary" %}
|
|
|
|
|
|
|
|
{% if status == "active" %}
|
|
|
|
{% set color = " badge-success" %}
|
|
|
|
{% elseif status == "nrfnd" %}
|
|
|
|
{% set color = " badge-warning" %}
|
|
|
|
{% elseif status == "eol" %}
|
|
|
|
{% set color = " badge-warning" %}
|
|
|
|
{% elseif status == "discontinued" %}
|
|
|
|
{% set color = " badge-danger" %}
|
|
|
|
{% 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-08-02 14:44:58 +02:00
|
|
|
{% endmacro %}
|