Part-DB-server/templates/info_providers/search/part_search.html.twig

157 lines
7.3 KiB
Twig

{% extends "main_card.html.twig" %}
{% import "info_providers/providers.macro.html.twig" as providers_macro %}
{% import "helper.twig" as helper %}
{% block title %}
{% if update_target %}
{% trans %}info_providers.update_part.title{% endtrans %}
{% else %}
{% trans %}info_providers.search.title{% endtrans %}
{% endif %}
{% endblock %}
{% block card_title %}
{% if update_target %} {# If update_target is set, we update an existing part #}
<i class="fas fa-cloud-arrow-down"></i> {% trans %}info_providers.update_part.title{% endtrans %}:
<b><a href="{{ entity_url(update_target) }}" target="_blank" class="text-bg-primary">{{ update_target.name }}</a></b>
{% else %} {# Create a fresh part #}
<i class="fas fa-cloud-arrow-down"></i> {% trans %}info_providers.search.title{% endtrans %}
{% endif %}
{% endblock %}
{% block card_content %}
{{ form_start(form) }}
{{ form_row(form.keyword) }}
{{ form_row(form.providers) }}
<div class="row mb-2">
<div class="col-sm-9 offset-sm-3">
<a href="{{ path('info_providers_list') }}">{% trans %}info_providers.search.info_providers_list{% endtrans %}</a>
</div>
</div>
{{ form_row(form.submit) }}
{{ form_end(form) }}
{% if results is not null %}
{% if results|length > 0 %}
<b>{% trans with {'%number%': results|length} %}info_providers.search.number_of_results{% endtrans %}</b>:
<table class="table table-striped table-hover">
<thead>
<tr>
<th></th>
<th>{% trans %}name.label{% endtrans %} / {% trans %}part.table.mpn{% endtrans %}</th>
<th>{% trans %}description.label{% endtrans %} / {% trans %}category.label{% endtrans %}</th>
<th>{% trans %}manufacturer.label{% endtrans %} / {% trans %}footprint.label{% endtrans %}</th>
<th>{% trans %}part.table.manufacturingStatus{% endtrans %}</th>
<th>{% trans %}info_providers.table.provider.label{% endtrans %}</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{% for result in results %}
{% set dto = result["dto"] %}
{# @var App\Entity\Parts\Part localPart #}
{% set localPart = result["localPart"] %}
<tr >
<td>
<img src="{{ dto.preview_image_url }}" data-thumbnail="{{ dto.preview_image_url }}"
class="hoverpic" style="max-width: 45px;" {{ stimulus_controller('elements/hoverpic') }}>
</td>
<td>
{% if dto.provider_url is not null %}
<a href="{{ dto.provider_url }}" target="_blank" rel="noopener">{{ dto.name }}</a>
{% else %}
{{ dto.name }}
{% endif %}
{% if dto.mpn is not null %}
<br>
<small class="text-muted" title="{% trans %}part.table.mpn{% endtrans %}">{{ dto.mpn }}</small>
{% endif %}
{% if result["localPart"] is not null %}
{% endif %}
</td>
<td>
{{ dto.description }}
{% if dto.category is not null %}
<br>
<small class="text-muted">{{ dto.category }}</small>
{% endif %}
</td>
<td>
{{ dto.manufacturer ?? '' }}
{% if dto.footprint is not null %}
<br>
<small class="text-muted">{{ dto.footprint }}</small>
{% endif %}
</td>
<td>{{ helper.m_status_to_badge(dto.manufacturing_status) }}</td>
<td>
{% if dto.provider_url %}
<a href="{{ dto.provider_url }}" target="_blank" rel="noopener">
{{ info_provider_label(dto.provider_key)|default(dto.provider_key) }}
</a>
{% else %}
{{ info_provider_label(dto.provider_key)|default(dto.provider_key) }}
{% endif %}
<br>
<small class="text-muted">{{ dto.provider_id }}</small>
</td>
<td>
{# TODO: would like to have a sort of "part exists!" text here, but don't know how to style it
also it would be nice to have these two buttons closer together, but when I put them in one cell
they sometimes stack#}
{% if localPart is not null %}
<a class="btn btn-primary" href="{{ path('app_part_show', {'id': localPart.id}) }}"
target="_blank" title="Show Existing Part"> {# TODO: Needs translation #}
<i class="fa-solid fa-search"></i>
</a>
{% endif %}
</td>
<td>
{% if localPart is not null %}
<a class="btn btn-primary" href="{{ path('part_edit', {'id': localPart.id}) }}"
target="_blank" title="Edit Existing Part"> {# TODO: Needs translation #}
<i class="fa-solid fa-pencil"></i>
</a>
{% endif %}
</td>
<td>
{% if update_target %} {# We update an existing part #}
{% set href = path('info_providers_update_part',
{'providerKey': dto.provider_key, 'providerId': dto.provider_id, 'id': update_target.iD}) %}
{% else %} {# Create a fresh part #}
{% set href = path('info_providers_create_part',
{'providerKey': dto.provider_key, 'providerId': dto.provider_id}) %}
{% endif %}
<a class="btn btn-primary" href="{{ href }}"
target="_blank" title="{% trans %}part.create.btn{% endtrans %}">
<i class="fa-solid fa-plus-square"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info" role="alert">
{% trans %}info_providers.search.no_results{% endtrans %}
</div>
{% endif %}
{% endif %}
{% endblock %}