Do some random coding for Distribotr numbers and Component parameters. This is probably not the most ideal solution. Will change this later

This commit is contained in:
2021-11-13 21:05:52 +01:00
parent 5c3197e040
commit ac318ca864
6 changed files with 277 additions and 57 deletions

View File

@@ -24,7 +24,7 @@
<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>
</div>
<div class="col">
<div class="col m-1">
<table class="table">
<thead>
<tr>
@@ -65,17 +65,36 @@
</tr>
</tbody>
</table>
<h2>Description</h2>
{% if component.description %}
{{component.description|linebreaks}}
{% else %}
<div class="alert alert-secondary" role="alert">
No description available
</div>
{% endif %}
<div class="row">
<div class="col">
<h2>Parameters</h2>
<h2>Description</h2>
{% if component.description %}
{{component.description|linebreaks}}
{% else %}
<div class="alert alert-secondary" role="alert">
No description available
</div>
{% endif %}
</div>
<div class="col-4">
{% if component.pref_distri %}
<h4>Preferred Distributor</h4>
<div class="d-flex align-items-center">
{% if component.pref_distri.image %}
<div class="flex-shrink-0">
<img src="{{component.pref_distri.image.url}}" alt="{{component.pref_distri.name}}" class="component-img-big">
</div>
<div class="flex-grow-1 ms-2">
<h6>{{component.pref_distri.name}}</h6>
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>
<div class="row">
<div class="col">
<h3>Parameters</h3>
<form method="post">
{% csrf_token %}
<table class="table">
@@ -87,35 +106,81 @@
<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|default_if_none:""}}</td>
<td><input type="text" class="form-control{% if f.parameter_type.errors %} is-invalid{% endif %}" name="{{f.parameter_type.html_name}}" value="{{f.parameter_type.value}}"></td>
<td><input type="text" class="form-control{% if f.value.errors %} is-invalid{% endif %}" name="{{f.value.html_name}}" value="{{f.value.value}}"></td>
<td>{{f.parameter_type_object.unit|default_if_none:"-"}}</td>
</tr>
{% if f.errors %}
<tr class="text-danger">
<td>
{% if f.parameter_type.errors %}
{{f.parameter_type.errors}}
{% endif %}
</td>
<td>
{% if f.value.errors %}
{{f.value.errors}}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{{param_formset.management_form}}
<input type="submit" class="btn btn-primary" name="submit-edit-params" value="Save Parameters">
</form>
</div>
<div class="col">
<h2>Stocks</h2>
<table class="table">
<thead>
<th scope="col">Storage</th>
<th scope="col">Amount</th>
</thead>
<tbody>
{% for stock in stocks %}
<tr>
<td><a class="text-decoration-none text-primary" href="{% url 'parts-stocks-detail' uuid=stock.storage.id %}">{{stock.storage.get_full_path}}</a></td>
<td>{{stock.amount}}</td>
<tr>
{% endfor %}
</tbody>
</table>
<h3>Distributor Part Numbers</h3>
<form method="post">
{% csrf_token %}
<table class="table">
<thead>
<th scope="col">Distributor</th>
<th scope="col">Part Number</th>
</thead>
<tbody>
{% for form in distri_num_formset %}
<tr>
<td>
{% if form.instance.distributor %}
{{form.instance.distributor.name}}
{% else %}
<input type="text" name="__unused_search" id="{{form.distributor.id_for_label}}-search">
{% endif %}
</td>
<input type="hidden" name="{{form.distributor.html_name}}" id="{{form.distributor.id_for_label}}" value="{{form.distributor.value|default_if_none:""}}">
<input type="hidden" name="{{form.id.html_name}}" value="{{form.id.value|default_if_none:""}}">
<td>
<input class="form-control" type="text" name="{{form.distributor_part_number.html_name}}" id="{{form.distributor_part_number.id_for_label}}" value="{{form.distributor_part_number.value|default_if_none:""}}">
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{distri_num_formset.management_form}}
<input type="submit" class="btn btn-secondary" name="submit-edit-distri-nums" value="Save">
</form>
</div>
</div>
<div class="row mt-2">
<table class="table">
<thead>
<th scope="col">Storage</th>
<th scope="col">Amount</th>
</thead>
<tbody>
{% for stock in stocks %}
<tr>
<td><a class="text-decoration-none text-primary" href="{% url 'parts-stocks-detail' uuid=stock.storage.id %}">{{stock.storage.get_full_path}}</a></td>
<td>{{stock.amount}}</td>
<tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>