Allow to define manufacturing status for a part.

This commit is contained in:
Jan Böhmer 2019-09-02 18:41:57 +02:00
parent b14edfc3bd
commit d22f9da1f0
5 changed files with 84 additions and 4 deletions

View file

@ -1,3 +1,4 @@
{{ form_row(form.manufacturer) }}
{{ form_row(form.manufacturer_product_number) }}
{{ form_row(form.manufacturer_product_url)}}
{{ form_row(form.manufacturer_product_url)}}
{{ form_row(form.manufacturing_status) }}

View file

@ -45,6 +45,13 @@
</div>
{% endif %}
{# Manufacturing status tag #}
<div class="mt-1">
<h6>
{{ helper.m_status_to_badge(part.manufacturingStatus) }}
</h6>
</div>
{# Show tags #}
{% if part.tags is not empty %}
<div class="mt-1">

View file

@ -52,4 +52,25 @@
{% for tag in string|split(',') %}
<a href="#" class="{{ class }}" >{{ tag | trim }}</a>
{% endfor %}
{% 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 %}
{% endmacro %}