Refactor part base display

This commit is contained in:
Oliver 2021-07-15 12:04:48 +10:00
parent 8fed3b3522
commit 0667857754
2 changed files with 47 additions and 227 deletions

View File

@ -18,131 +18,6 @@
<div class='col-sm-6'>
<table class='table table-striped'>
<col width='25'>
<tr>
<td><span class='fas fa-font'></span></td>
<td><strong>{% trans "Part name" %}</strong></td>
<td>{{ part.name }}{% include "clip.html"%}</td>
</tr>
{% if part.IPN %}
<tr>
<td></td>
<td><strong>{% trans "IPN" %}</strong></td>
<td>{{ part.IPN }}{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.revision %}
<tr>
<td><span class='fas fa-code-branch'></span></td>
<td><strong>{% trans "Revision" %}</strong></td>
<td>{{ part.revision }}{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.trackable %}
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td><strong>{% trans "Latest Serial Number" %}</strong></td>
<td>
{% if part.getLatestSerialNumber %}
{{ part.getLatestSerialNumber }}{% include "clip.html"%}
{% else %}
<em>{% trans "No serial numbers recorded" %}</em>
{% endif %}
</td>
</tr>
{% endif %}
<tr>
<td><span class='fas fa-info-circle'></span></td>
<td><strong>{% trans "Description" %}</strong></td>
<td>{{ part.description }}{% include "clip.html"%}</td>
</tr>
{% if part.variant_of %}
<tr>
<td></td>
<td><strong>{% trans "Variant Of" %}</strong></td>
<td><a href="{% url 'part-detail' part.variant_of.id %}">{{ part.variant_of.full_name }}</a>{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.keywords %}
<tr>
<td><span class='fas fa-key'></span></td>
<td><strong>{% trans "Keywords" %}</strong></td>
<td>{{ part.keywords }}{% include "clip.html"%}</td>
</tr>
{% endif %}
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td><strong>{% trans "Category" %}</strong></td>
<td>
{% if part.category %}
<a href="{% url 'category-detail' part.category.id %}">{{ part.category.pathstring }}</a>{% include "clip.html"%}
{% endif %}
</td>
</tr>
{% if part.link %}
<tr>
<td><span class='fas fa-link'></span></td>
<td><strong>{% trans "External Link" %}</strong></td>
<td><a href="{{ part.link }}">{{ part.link }}</a>{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.default_location %}
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td><strong>{% trans "Default Location" %}</strong></td>
<td><a href="{% url 'stock-location-detail' part.default_location.id %}">{{ part.default_location.pathstring }}</a>{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.default_supplier %}
<tr>
<td></td>
<td><strong>{% trans "Default Supplier" %}</strong></td>
<td><a href="{% url 'supplier-part-detail' part.default_supplier.id %}">
{{ part.default_supplier.supplier.name }} | {{ part.default_supplier.SKU }}
</a>{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.units %}
<tr>
<td></td>
<td><strong>{% trans "Units" %}</strong></td>
<td>{{ part.units }}{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.minimum_stock > 0 %}
<tr>
<td><span class='fas fa-greater-than-equal'></span></td>
<td><strong>{% trans "Minimum Stock" %}</strong></td>
<td>{{ part.minimum_stock }}</td>
</tr>
{% endif %}
{% if part.default_expiry > 0 %}
<tr>
<td><span class='fas fa-stopwatch'></span></td>
<td><strong>{% trans "Stock Expiry Time" %}</strong></td>
<td>{{ part.default_expiry }} {% trans "days" %}</td>
</tr>
{% endif %}
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td><strong>{% trans "Creation Date" %}</strong></td>
<td>{{ part.creation_date }}</td>
</tr>
{% if part.creation_user %}
<tr>
<td><span class='fas fa-user'></span></td>
<td><strong>{% trans "Created By" %}</strong></td>
<td>{{ part.creation_user }}</td>
</tr>
{% endif %}
{% if part.responsible %}
<tr>
<td><span class='fas fa-user'></span></td>
<td><strong>{% trans "Responsible User" %}</strong></td>
<td>{{ part.responsible }}</td>
</tr>
{% endif %}
<tr><td colspan="3"></td></tr>
<tr>
<td><span class='fas fa-sticky-note'></span></td>
@ -171,96 +46,7 @@
</table>
</div>
<div class='col-sm-6'>
<table class='table table-striped'>
<col width='25'>
<tr>
<td><span class='fas fa-ghost'%></span></td>
<td><strong>{% trans "Virtual" %}</strong></td>
<td>{% include "slide.html" with state=part.virtual field='virtual' %}</td>
{% if part.virtual %}
<td>{% trans "Part is virtual (not a physical part)" %}</td>
{% else %}
<td><em>{% trans "Part is not a virtual part" %}</em></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-clone'></span></td>
<td><strong>{% trans "Template" %}</strong></td>
<td>{% include "slide.html" with state=part.is_template field='is_template' %}</td>
{% if part.is_template %}
<td>{% trans "Part is a template part (variants can be made from this part)" %}</td>
{% else %}
<td><em>{% trans "Part is not a template part" %}</em></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-tools'></span></td>
<td><strong>{% trans "Assembly" %}</strong></td>
<td>{% include "slide.html" with state=part.assembly field='assembly' %}</td>
{% if part.assembly %}
<td>{% trans "Part can be assembled from other parts" %}</td>
{% else %}
<td><em>{% trans "Part cannot be assembled from other parts" %}</em></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-th'></span></td>
<td><strong>{% trans "Component" %}</strong></td>
<td>{% include "slide.html" with state=part.component field='component' %}</td>
{% if part.component %}
<td>{% trans "Part can be used in assemblies" %}</td>
{% else %}
<td><em>{% trans "Part cannot be used in assemblies" %}</em></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-directions'></span></td>
<td><strong>{% trans "Trackable" %}</strong></td>
<td>{% include "slide.html" with state=part.trackable field='trackable' %}</td>
{% if part.trackable %}
<td>{% trans "Part stock is tracked by serial number" %}</td>
{% else %}
<td><em>{% trans "Part stock is not tracked by serial number" %}</em></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-shopping-cart'></span></td>
<td><strong>{% trans "Purchaseable" %}</strong></td>
<td>{% include "slide.html" with state=part.purchaseable field='purchaseable' %}</td>
{% if part.purchaseable %}
<td>{% trans "Part can be purchased from external suppliers" %}</td>
{% else %}
<td><em>{% trans "Part can be purchased from external suppliers" %}</em></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-dollar-sign'></span></td>
<td><strong>{% trans "Salable" %}</strong></td>
<td>{% include "slide.html" with state=part.salable field='salable' %}</td>
{% if part.salable %}
<td>{% trans "Part can be sold to customers" %}</td>
{% else %}
<td><em>{% trans "Part cannot be sold to customers" %}</em></td>
{% endif %}
</tr>
<tr><td colspan='4'></td></tr>
<tr>
<td>
{% if part.active %}
<span class='fas fa-check-circle icon-green'></span>
{% else %}
<span class='fas fa-times-circle icon-red'></span>
{% endif %}
</td>
<td><strong>{% trans "Active" %}</strong></td>
<td>{% include "slide.html" with state=part.active field='active' disabled=False %}</td>
{% if part.active %}
<td>{% trans "Part is active" %}</td>
{% else %}
<td><em>{% trans "Part is not active" %}</em></td>
{% endif %}
</tr>
</table>
</div>
</div>

View File

@ -27,7 +27,34 @@
</div>
{% endif %}
</h3>
{% if part.description %}
<p><em>{{ part.description }}</em></p>
{% endif %}
<p>
<div id='part-properties' class='btn-group' role='group'>
{% if part.virtual %}
<span class='fas fa-ghost' title='{% trans "Part is virtual (not a physical part)" %}'></span>
{% endif %}
{% if part.is_template %}
<span class='fas fa-clone' title='{% trans "Part is a template part (variants can be made from this part)" %}'></span>
{% endif %}
{% if part.assembly %}
<span class='fas fa-tools' title='{% trans "Part can be assembled from other parts" %}'></span>
{% endif %}
{% if part.component %}
<span class='fas fa-th' title='{% trans "Part can be used in assemblies" %}'></span>
{% endif %}
{% if part.trackable %}
<span class='fas fa-directions' title='{% trans "Part stock is tracked by serial number" %}'></span>
{% endif %}
{% if part.purchaseable %}
<span class='fas fa-shopping-cart' title='{% trans "Part can be purchased from external suppliers" %}'></span>
{% endif %}
{% if part.salable %}
<span class='fas fa-dollar-sign' title='{% trans "Part can be sold to customers" %}'></span>
{% endif %}
</div>
</p>
<div class='btn-group action-buttons' role='group'>
<button type='button' class='btn btn-default' id='toggle-starred' title='{% trans "Star this part" %}'>
@ -97,11 +124,11 @@
</div>
<table class='table table-condensed'>
<col width='25'>
{% if part.IPN %}
{% if part.keywords %}
<tr>
<td></td>
<td>{% trans "IPN" %}</td>
<td>{{ part.IPN }}</td>
<td><span class='fas fa-key'></span></td>
<td>{% trans "Keywords" %}</td>
<td>{{ part.keywords }}</td>
</tr>
{% endif %}
{% if part.link %}
@ -112,7 +139,22 @@
</tr>
{% endif %}
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td>{% trans "Creation Date" %}</td>
<td>
{{ part.creation_date }}
{% if part.creation_user %}
<span class='badge'>{{ part.creation_user }}</span>
{% endif %}
</td>
</tr>
{% if part.trackable and part.getLatestSerialNumber %}
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Latest Serial Number" %}</td>
<td>{{ part.getLatestSerialNumber }}{% include "clip.html"%}</td>
</tr>
{% endif %}
</table>
</div>
</div>
@ -197,14 +239,6 @@
{% endif %}
{% endif %}
{% endif %}
{% if part.trackable and part.getLatestSerialNumber %}
<tr><td colspan="3"></td></tr>
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Latest Serial Number" %}</td>
<td>{{ part.getLatestSerialNumber }}{% include "clip.html"%}</td>
</tr>
{% endif %}
</table>
</div>
</div>