Refactor stock location view

This commit is contained in:
Oliver 2021-10-27 23:46:09 +11:00
parent 840187f577
commit a21959f54d
2 changed files with 120 additions and 137 deletions

View File

@ -7,145 +7,132 @@
{% include "stock/location_navbar.html" %} {% include "stock/location_navbar.html" %}
{% endblock %} {% endblock %}
{% block content %} {% block details_left %}
{% if location %}
<h4>
{% trans "Stock Location" %}: {{ location.name }}
{% if user.is_staff and roles.stock_location.change %}
<a href="{% url 'admin:stock_stocklocation_change' location.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
</h4>
<p>{{ location.description }}</p>
{% else %}
<h4>
{% trans "Stock" %}
</h4>
<p>{% trans "All stock items" %}</p>
{% endif %}
<div class='panel panel-inventree'> <div class='btn-group' role='group'>
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser or not location %}
<div class='panel-heading'> {% if roles.stock_location.add %}
<h4> <button class='btn btn-success' id='location-create' type='button' title='{% trans "Create new stock location" %}'>
{% if location %} <span class='fas fa-plus-circle'></span>
{{ location.name }} </button>
{% if location %} {% endif %}
{% if user.is_staff and roles.stock_location.change %} {% endif %}
<a href="{% url 'admin:stock_stocklocation_change' location.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a> {% if barcodes %}
{% endif %} <!-- Barcode actions menu -->
</h3> {% if location %}
{% else %} <div class='btn-group' role='group'>
<h3>{% trans "Stock" %}</h3> <button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
<p>{% trans "All stock items" %}</p> <ul class='dropdown-menu'>
{% endif %} <li><a class='dropdown-item' href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
<li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
{% else %} <li><a class='dropdown-item' href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li>
{% trans "Stock" %} </ul>
{% endif %}
</h4>
</div> </div>
<!-- Check permissions and owner -->
<div class='panel-content'> {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %}
{% if roles.stock.change %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} <div class='btn-group' role='group'>
{% if owner_control.value == "True" %} <button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'>
{% authorized_owners location.owner as owners %} <span class='fas fa-boxes'></span> <span class='caret'></span>
</button>
{% if location and not user in owners and not user.is_superuser %} <ul class='dropdown-menu' role='menu'>
<div class='alert alert-block alert-info'> <li>
{% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}<br> <a class='dropdown-item' href='#' id='location-count'>
<span class='fas fa-clipboard-list'></span>
{% trans "Count stock" %}
</a>
</li>
<li>
<a class='dropdown-item' href='#' id='location-move'>
<span class='fas fa-exchange-alt'></span>
{% trans "Transfer stock" %}
</a>
</li>
</ul>
</div> </div>
{% endif %} {% endif %}
{% if roles.stock_location.change %}
<div class='btn-group' role='group'>
<button id='location-actions' title='{% trans "Location actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle="dropdown"><span class='fas fa-sitemap'></span> <span class='caret'></span></button>
<ul class='dropdown-menu' role='menu'>
<li><a class='dropdown-item' href='#' id='location-edit'><span class='fas fa-edit icon-green'></span> {% trans "Edit location" %}</a></li>
{% if roles.stock.delete %}
<li><a class='dropdown-item' href='#' id='location-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete location" %}</a></li>
{% endif %}
</ul>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %} {% endif %}
<div class='row'>
<div class='col-sm-6'>
<div class='btn-group' role='group'>
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser or not location %}
{% if roles.stock_location.add %}
<button class='btn btn-success' id='location-create' title='{% trans "Create new stock location" %}'>
<span class='fas fa-plus-circle'/>
</button>
{% endif %}
{% endif %}
{% if barcodes %}
<!-- Barcode actions menu -->
{% if location %}
<div class='btn-group' role='group'>
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'>
<li><a class='dropdown-item' href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
<li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
<li><a class='dropdown-item' href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li>
</ul>
</div>
<!-- Check permissions and owner -->
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %}
{% if roles.stock.change %}
<div class='btn-group' role='group'>
<button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'>
<span class='fas fa-boxes'></span> <span class='caret'></span>
</button>
<ul class='dropdown-menu' role='menu'>
<li>
<a class='dropdown-item' href='#' id='location-count'>
<span class='fas fa-clipboard-list'></span>
{% trans "Count stock" %}
</a>
</li>
<li>
<a class='dropdown-item' href='#' id='location-move'>
<span class='fas fa-exchange-alt'></span>
{% trans "Transfer stock" %}
</a>
</li>
</ul>
</div>
{% endif %}
{% if roles.stock_location.change %}
<div class='btn-group' role='group'>
<button id='location-actions' title='{% trans "Location actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle="dropdown"><span class='fas fa-sitemap'></span> <span class='caret'></span></button>
<ul class='dropdown-menu' role='menu'>
<li><a class='dropdown-item' href='#' id='location-edit'><span class='fas fa-edit icon-green'></span> {% trans "Edit location" %}</a></li>
{% if roles.stock.delete %}
<li><a class='dropdown-item' href='#' id='location-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete location" %}</a></li>
{% endif %}
</ul>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
<div class='col-sm-6'>
{% if location %}
<table class='table table-striped table-condensed'>
<col width='25'>
<tr>
<td><span class='fas fa-info-circle'></span></td>
<td>{% trans "Description" %}</td>
<td>{{ location.description }}</td>
</tr>
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "Sublocations" %}</td>
<td>{{ location.children.count }}</td>
</tr>
<tr>
<td><span class='fas fa-boxes'></span></td>
<td>{% trans "Stock Items" %}</td>
<td>{{ location.item_count }}</td>
</tr>
</table>
{% else %}
<h3>{% trans "Stock Details" %}</h3>
<table class='table table-striped table-condensed'>
<col width='25'>
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "Stock Locations" %}</td>
<td>{{ loc_count }}</td>
</tr>
<tr>
<td><span class='fas fa-boxes'></span></td>
<td>{% trans "Stock Items" %}</td>
<td>{{ stock_count }}</td>
</tr>
</table>
{% endif %}
</div>
</div>
</div>
</div> </div>
{% block location_content %} {% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners location.owner as owners %}
{% if location and not user in owners and not user.is_superuser %}
<div class='alert alert-block alert-info'>
{% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}<br>
</div>
{% endif %}
{% endif %}
{% endblock %}
{% block details_right %}
{% if location %}
<table class='table table-striped table-condensed'>
<col width='25'>
<tr>
<td><span class='fas fa-info-circle'></span></td>
<td>{% trans "Description" %}</td>
<td>{{ location.description }}</td>
</tr>
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "Sublocations" %}</td>
<td>{{ location.children.count }}</td>
</tr>
<tr>
<td><span class='fas fa-boxes'></span></td>
<td>{% trans "Stock Items" %}</td>
<td>{{ location.item_count }}</td>
</tr>
</table>
{% else %}
<h3>{% trans "Stock Details" %}</h3>
<table class='table table-striped table-condensed'>
<col width='25'>
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "Stock Locations" %}</td>
<td>{{ loc_count }}</td>
</tr>
<tr>
<td><span class='fas fa-boxes'></span></td>
<td>{% trans "Stock Items" %}</td>
<td>{{ stock_count }}</td>
</tr>
</table>
{% endif %}
{% endblock %}
{% block page_content %}
<div class='panel panel-inventree panel-hidden' id='panel-stock'> <div class='panel panel-inventree panel-hidden' id='panel-stock'>
<div class='panel-heading'> <div class='panel-heading'>
@ -184,10 +171,6 @@
{% endblock %} {% endblock %}
</div>
{% endblock %}
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}

View File

@ -1,4 +1,4 @@
{% extends "base.html" %} {% extends "page_base.html" %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% load inventree_extras %} {% load inventree_extras %}