shimatta-kenkyusho/shimatta_kenkyusho/templates/parts/components.html

84 lines
4.3 KiB
HTML
Raw Normal View History

2021-08-07 17:37:36 +02:00
{% extends 'base.html' %}
2022-01-02 20:00:29 +01:00
{% load crispy_forms_tags %}
2021-08-07 17:37:36 +02:00
{% block content %}
2021-11-09 16:35:11 +01:00
<div class="container">
<div class="row">
<div class="col-md">
<h2>Components</h2>
2022-01-01 17:53:10 +01:00
<form action="" method="get">
<div class="input-group mb-3">
<input class="form-control" name="search" type="search" placeholder="Search Component..." {% if search_string %}value="{{search_string}}"{% endif %}>
<button type="submit" class="btn btn-primary">
<i class="bi bi-search"></i>
</button>
2022-01-02 20:00:29 +01:00
<button class="btn btn-secondary" type="button" data-bs-toggle="collapse" href="#advanced-search-collapse">Advanced <i class="bi bi-search"></i></button>
<button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#comp-edit-modal"><i class="bi bi-plus-circle"></i> Add Component</button>
</div>
2022-01-01 17:53:10 +01:00
</form>
<div class="collapse mb-3{% if advanced_search_shown %} show{% endif %}" id="advanced-search-collapse" aria-expanded="{% if advanced_search_shown %}true{% else %}false{% endif %}">
<form method="GET">
2022-01-02 20:00:29 +01:00
<div class="row">
<div class="col-sm">
{% crispy advanced_search_form %}
</div>
{{ advanced_search_param_formset.management_form }}
2022-01-02 20:00:29 +01:00
<div class="col-sm">
{% for f in advanced_search_param_formset %}
{% crispy f %}
{% endfor %}
2022-01-02 20:00:29 +01:00
</div>
<input type="submit" name="submit-advanced-search" value="Search" class="btn btn-success">
</div>
</form>
<template id="advanced-search-parameter-template">
{% crispy advanced_search_param_formset.empty_form %}
</template>
2022-01-02 20:00:29 +01:00
</div>
2022-01-01 17:53:10 +01:00
<div class="list-group mb-3">
2021-11-09 16:35:11 +01:00
{% for comp in components %}
<a href="{% url 'parts-components-detail' uuid=comp.id %}" class="text-decoration-none">
<li class="list-group-item list-group-item-action d-flex align-items-center">
<div class="flex-shrink-0">
{% if comp.get_resolved_image %}
2021-11-09 18:44:28 +01:00
<img src="{{comp.get_resolved_image}}" class="component-img-small" alt="{{ comp.name }}" class="mr-3">
2021-11-09 16:35:11 +01:00
{% else %}
{% load static %}
2021-11-09 18:44:28 +01:00
<img src="{% static 'css/icons/card-image.svg' %}" class="component-img-def-small" alt="{{ comp.name }}" class="mr-3">
2021-11-09 16:35:11 +01:00
{% endif %}
</div>
<div class="flex-grow-1 ms-3">
<h6 class="mt-0 text-primary">
{{ comp.name }}
{% for key_param in comp.get_key_parameters_as_text %}
{{key_param}}
{% endfor %}
</h6>
2021-11-09 16:35:11 +01:00
{% if comp.package %}
Package: {{comp.package}}<br>
{% endif %}
{% if comp.manufacturer %}
Manufacturer: {{comp.manufacturer}}
{% endif %}
</div>
<span class="badge bg-primary rounded-pill">{{comp.get_total_amount}}</span>
</li>
</a>
{% endfor %}
</div>
{% include 'paginator.html' with paginator=components get_param='comp_page' aria_label='Component Page Navigation' %}
2021-11-09 16:35:11 +01:00
</div>
</div>
</div>
2022-01-01 17:53:10 +01:00
{% include 'parts/modals/edit-component-modal.html' with form=comp_form heading='New Component' open_component_button=True %}
2022-01-01 17:53:10 +01:00
{% endblock content %}
{% block custom_scripts %}
<script type="text/javascript">
{% if comp_form.errors %}
bootstrap.Modal.getOrCreateInstance(document.getElementById('comp-edit-modal')).show()
{% endif %}
</script>
{% endblock custom_scripts %}