2021-11-09 16:35:11 +01:00
|
|
|
{% extends 'base.html' %}
|
2021-11-09 18:44:28 +01:00
|
|
|
{% load static %}
|
|
|
|
{% load qr_code %}
|
2021-11-12 20:14:02 +01:00
|
|
|
{% load crispy_forms_tags %}
|
2021-11-09 16:35:11 +01:00
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
<div class="container">
|
2021-11-10 19:38:39 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-3">
|
|
|
|
<div class="row justify-content-center">
|
|
|
|
{% if component.get_resolved_image %}
|
|
|
|
<img src="{{component.get_resolved_image}}" alt="{{component.name}}" class="component-img-big btn" data-bs-toggle="modal" data-bs-target="#comp-img-modal">
|
|
|
|
{% else %}
|
|
|
|
<img src="{% static 'css/icons/card-image.svg' %}" alt="{{component.name}}" class="component-img-def-big">
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
{% qr_from_text component.get_qr_code size="m" image_format="svg" %}
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
{% if component.datasheet_link %}
|
|
|
|
<a class="btn btn-secondary mb-2" href="{{component.datasheet_link}}"><i class="bi bi-file-pdf-fill"></i> Datasheet</a>
|
2021-11-09 18:44:28 +01:00
|
|
|
{% endif %}
|
2021-11-10 19:38:39 +01:00
|
|
|
<button class="btn btn-primary mb-2" data-bs-toggle="modal" data-bs-target="#comp-edit-modal"><i class="bi bi-pencil-square"></i> Edit Component</button>
|
|
|
|
</div>
|
2021-11-09 18:44:28 +01:00
|
|
|
</div>
|
2021-11-10 19:38:39 +01:00
|
|
|
<div class="col">
|
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th scope="col">Name</th>
|
|
|
|
<th scope="col">Package</th>
|
|
|
|
<th scope="col">Manufacturer</th>
|
|
|
|
<th scope="col">Type</th>
|
|
|
|
<th scope="col">Total #</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2021-11-11 20:51:02 +01:00
|
|
|
<td class="align-middle" scope="row">
|
|
|
|
{{component.name}}
|
|
|
|
</td>
|
|
|
|
<td class="align-middle" >
|
|
|
|
{% if component.package %}
|
|
|
|
<a href="{% url 'parts-packages-detail' uuid=component.package.id %}" class="link-primary text-decoration-none">{{component.package.name}}</a>
|
|
|
|
{% if component.package.image %}
|
|
|
|
<img src="{{component.package.image.url}}" class="component-img-small">
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
<td class="align-middle" >
|
|
|
|
{% if component.manufacturer %}
|
|
|
|
{{component.manufacturer.name}}
|
|
|
|
{% if component.manufacturer.image %}
|
|
|
|
<img src="{{component.manufacturer.image.url}}" class="component-img-small">
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
<td class="align-middle">
|
|
|
|
{% if component.component_type %}{{component.component_type.class_name}}{% endif %}
|
|
|
|
</td>
|
|
|
|
<td class="align-middle">
|
|
|
|
{{component.get_total_amount}}
|
|
|
|
</td>
|
2021-11-10 19:38:39 +01:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<h2>Description</h2>
|
|
|
|
{% if component.description %}
|
2021-11-11 20:51:02 +01:00
|
|
|
{{component.description|linebreaks}}
|
2021-11-10 19:38:39 +01:00
|
|
|
{% else %}
|
|
|
|
<div class="alert alert-secondary" role="alert">
|
|
|
|
No description available
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-11-12 20:14:02 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<h2>Parameters</h2>
|
|
|
|
<form method="post">
|
|
|
|
{% csrf_token %}
|
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<th scope="col">Parameter</th>
|
|
|
|
<th scope="col">Value</th>
|
|
|
|
<th scope="col">Unit</th>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for f in param_formset %}
|
|
|
|
<tr>
|
|
|
|
<td><input type="text" class="form-control" name="{{f.parameter_type.name}}" value="{{f.parameter_type.value}}"></td>
|
|
|
|
<td><input type="text" class="form-control" name="{{f.value.name}}" value="{{f.value.value}}"></td>
|
|
|
|
<td>{{f.parameter_type_object.unit}}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<input type="submit" class="btn btn-primary" name="submit-edit-params" value="Save Parameters">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<h2>Stocks</h2>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-10 19:38:39 +01:00
|
|
|
|
2021-11-09 18:44:28 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-09 16:35:11 +01:00
|
|
|
</div>
|
2021-11-09 18:44:28 +01:00
|
|
|
|
|
|
|
{% if component.get_resolved_image %}
|
|
|
|
<div class="modal fade" id="comp-img-modal" tabindex="-1">
|
|
|
|
<div class="modal-dialog modal-lg modal-fullscreen-lg-down">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5>{{component.name}}</h5>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="text-center">
|
|
|
|
<img class="component-img-huge" src="{{component.get_resolved_image}}">
|
|
|
|
</div>
|
|
|
|
{% if not component.image %}
|
|
|
|
<hr>
|
|
|
|
<div class="alert alert-warning">
|
|
|
|
Component doesn't have an image. The image is inherited from its package.
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-11-11 20:51:02 +01:00
|
|
|
{% include 'parts/modals/edit-component-modal.html' with heading="Edit "|add:component.name form=edit_form %}
|
2021-11-10 19:38:39 +01:00
|
|
|
{% endblock content %}
|
|
|
|
|
|
|
|
{% block custom_scripts %}
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
{% if edit_form.errors %}
|
|
|
|
bootstrap.Modal.getOrCreateInstance(document.getElementById('comp-edit-modal')).show()
|
|
|
|
{% endif %}
|
|
|
|
</script>
|
|
|
|
{% endblock custom_scripts %}
|
2021-11-09 18:44:28 +01:00
|
|
|
|