From b41d1aed12c5413a1202c36b51a83953d3c9dc0d Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 29 Oct 2021 17:07:35 +1100 Subject: [PATCH] Refactor admin button for: - build order - part detail - stock item - stock location - company detail - manufacturer-part - purchase order - sales order --- .../build/templates/build/build_base.html | 156 ++++++------- .../templates/company/company_base.html | 90 ++++---- .../templates/company/manufacturer_part.html | 58 ++--- .../templates/company/supplier_part.html | 55 +++-- .../order/templates/order/order_base.html | 93 ++++---- .../templates/order/sales_order_base.html | 87 ++++---- InvenTree/part/templates/part/cat_link.html | 1 - InvenTree/part/templates/part/category.html | 61 +++--- InvenTree/part/templates/part/detail.html | 2 +- InvenTree/part/templates/part/part_base.html | 147 +++++++------ .../part/templates/part/stock_count.html | 4 +- .../stock/templates/stock/item_base.html | 207 +++++++++--------- InvenTree/stock/templates/stock/loc_link.html | 1 - InvenTree/stock/templates/stock/location.html | 139 ++++++------ InvenTree/templates/admin_button.html | 4 + InvenTree/templates/js/dynamic/inventree.js | 7 + InvenTree/templates/page_base.html | 15 ++ 17 files changed, 586 insertions(+), 541 deletions(-) create mode 100644 InvenTree/templates/admin_button.html diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index ea094204e0..fb91771d88 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -23,44 +23,88 @@ src="{% static 'img/blank_image.png' %}" {% endif %}/> {% endblock %} -{% block details %} -

- {% trans "Build Order" %} {{ build }} - {% if user.is_staff and roles.build.change %} - - {% endif %} -

-

{{ build.title }}

-
- - - - {% if roles.build.change %} -
- - -
- {% if build.active %} - + +
+ +{% if roles.build.change %} +
+ + +
+{% if build.active %} + +{% endif %} +{% endif %} +{% endblock %} + +{% block details %} + +

{{ build.title }}

+ +
+ {% if build.sales_order %} +
+ {% object_link 'so-detail' build.sales_order.id build.sales_order as link %} + {% blocktrans %}This Build Order is allocated to Sales Order {{link}}{% endblocktrans %} +
+ {% endif %} + + {% if build.parent %} +
+ {% object_link 'build-detail' build.parent.id build.parent as link %} + {% blocktrans %}This Build Order is a child of Build Order {{link}}{% endblocktrans %} +
+ {% endif %} + + {% if build.active %} + {% if build.can_complete %} +
+ {% trans "Build Order is ready to mark as completed" %} +
+ {% endif %} + {% if build.incomplete_count > 0 %} +
+ {% trans "Build Order cannot be completed as outstanding outputs remain" %} +
+ {% endif %} + {% if build.completed < build.quantity %} +
+ {% trans "Required build quantity has not yet been completed" %} +
+ {% endif %} + {% if not build.areUntrackedPartsFullyAllocated %} +
+ {% trans "Stock has not been fully allocated to this Build Order" %} +
{% endif %} {% endif %}
@@ -133,44 +177,6 @@ src="{% static 'img/blank_image.png' %}" {% endif %} -
- {% if build.sales_order %} -
- {% object_link 'so-detail' build.sales_order.id build.sales_order as link %} - {% blocktrans %}This Build Order is allocated to Sales Order {{link}}{% endblocktrans %} -
- {% endif %} - - {% if build.parent %} -
- {% object_link 'build-detail' build.parent.id build.parent as link %} - {% blocktrans %}This Build Order is a child of Build Order {{link}}{% endblocktrans %} -
- {% endif %} - - {% if build.active %} - {% if build.can_complete %} -
- {% trans "Build Order is ready to mark as completed" %} -
- {% endif %} - {% if build.incomplete_count > 0 %} -
- {% trans "Build Order cannot be completed as outstanding outputs remain" %} -
- {% endif %} - {% if build.completed < build.quantity %} -
- {% trans "Required build quantity has not yet been completed" %} -
- {% endif %} - {% if not build.areUntrackedPartsFullyAllocated %} -
- {% trans "Stock has not been fully allocated to this Build Order" %} -
- {% endif %} - {% endif %} -
{% endblock %} {% block page_data %} diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 9fcf2be16a..86797231b4 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -8,56 +8,58 @@ {% inventree_title %} | {% trans "Company" %} - {{ company.name }} {% endblock %} -{% block details_left %} -
-
-
- -
-
- - {% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} - {% if allow_download %} - - {% endif %} -
-
-
-
-
-

- {{ company.name }} - {% if user.is_staff and perms.company.change_company %} - - {% endif %} -

-

{{ company.description }}

-
- {% if company.is_supplier and roles.purchase_order.add %} - - {% endif %} - {% if perms.company.change_company %} - - {% endif %} - {% if perms.company.delete_company %} - +{% block heading %} +{% trans "Company" %}: {{ company.name }} +{% endblock %} + +{% block actions %} + +{% if user.is_staff and perms.company.change_company %} +{% url 'admin:company_company_change' company.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} +{% if company.is_supplier and roles.purchase_order.add %} + +{% endif %} +{% if perms.company.change_company %} + +{% endif %} +{% if perms.company.delete_company %} + +{% endif %} +{% endblock %} + +{% block thumbnail %} +
+ +
+
+ + {% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} + {% if allow_download %} + {% endif %}
{% endblock %} +{% block details %} +

{{ company.description }}

+ +{% endblock %} + {% block details_right %} diff --git a/InvenTree/company/templates/company/manufacturer_part.html b/InvenTree/company/templates/company/manufacturer_part.html index 9a370eeefc..09affcfd11 100644 --- a/InvenTree/company/templates/company/manufacturer_part.html +++ b/InvenTree/company/templates/company/manufacturer_part.html @@ -18,6 +18,36 @@ InvenTree | {% trans "Manufacturer Part" %} {% endblock %} +{% block heading %} +

+ {% trans "Manufacturer Part" %}: {{ part.part.full_name }} +

+{% endblock %} + +{% block actions %} +{% if user.is_staff and perms.company.change_company %} +{% url 'admin:company_supplierpart_change' part.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} +{% if roles.purchase_order.change %} +{% comment "for later" %} +{% if roles.purchase_order.add %} + +{% endif %} +{% endcomment %} + +{% if roles.purchase_order.delete %} + +{% endif %} +{% endif %} +{% endblock %} + {% block thumbnail %} - {% trans "Manufacturer Part" %}: {{ part.part.full_name }} - {% if user.is_staff and perms.company.change_company %} - - - - {% endif %} - - -{% if roles.purchase_order.change %} -
- {% comment "for later" %} - {% if roles.purchase_order.add %} - - {% endif %} - {% endcomment %} - - {% if roles.purchase_order.delete %} - - {% endif %} -
-{% endif %} {% endblock %} diff --git a/InvenTree/company/templates/company/supplier_part.html b/InvenTree/company/templates/company/supplier_part.html index 3e60783aae..1450ac4c35 100644 --- a/InvenTree/company/templates/company/supplier_part.html +++ b/InvenTree/company/templates/company/supplier_part.html @@ -19,6 +19,32 @@ {% endblock %} +{% block heading %} +

+ {% trans "Supplier Part" %}: {{ part.SKU }} +

+{% endblock %} + +{% block actions %} +{% if user.is_staff and perms.company.change_company %} +{% url 'admin:company_supplierpart_change' part.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} +{% if roles.purchase_order.add %} + +{% endif %} + +{% if roles.purchase_order.delete %} + +{% endif %} +{% endblock %} + {% block thumbnail %} - {% trans "Supplier Part" %}: {{ part.SKU }} - {% if user.is_staff and perms.company.change_company %} - - - - {% endif %} - +

{{ part.part.full_name }}

-{% if roles.purchase_order.change %} -
-
- {% if roles.purchase_order.add %} - - {% endif %} - - {% if roles.purchase_order.delete %} - - {% endif %} -
-
-{% endif %} - {% endblock %} {% block details_right %} diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 295e37b73f..9e94b379f8 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -14,6 +14,53 @@ {% endblock %} +{% block heading %} +{% trans "Purchase Order" %}: {{ order.reference }} +{% endblock %} + +{% block actions %} +{% if user.is_staff and roles.purchase_order.change %} +{% url 'admin:order_purchaseorder_change' order.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} + + +{% if roles.purchase_order.change %} + +
+ + +
+{% if order.status == PurchaseOrderStatus.PENDING and order.lines.count > 0 %} + +{% elif order.status == PurchaseOrderStatus.PLACED %} + + +{% endif %} +{% endif %} +{% endblock %} + {% block thumbnail %} - {% trans "Purchase Order" %}: {{ order.reference }} - {% if user.is_staff and roles.purchase_order.change %} - - {% endif %} - +

{% purchase_order_status_label order.status large=True %} {% if order.is_overdue %} @@ -38,44 +80,7 @@ src="{% static 'img/blank_image.png' %}" {% endif %}

{{ order.description }}{% include "clip.html"%}

-
- - - {% if roles.purchase_order.change %} - -
- - -
- {% if order.status == PurchaseOrderStatus.PENDING and order.lines.count > 0 %} - - {% elif order.status == PurchaseOrderStatus.PLACED %} - - - {% endif %} - {% endif %} -
+ {% endblock %} {% block details_right %} diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index 1c679fdc04..6200df1183 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -24,14 +24,52 @@ src="{% static 'img/blank_image.png' %}" /> {% endblock %} +{% block heading %} +{% trans "Sales Order" %} {{ order.reference }} +{% endblock %} + +{% block actions %} +{% if user.is_staff and roles.sales_order.change %} +{% url 'admin:order_salesorder_change' order.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} + + +{% if roles.sales_order.change %} + +
+ + + +
+{% if order.status == SalesOrderStatus.PENDING %} + +{% endif %} +{% endif %} +{% endblock %} + {% block details %} -

- {% trans "Sales Order" %} {{ order.reference }} - {% if user.is_staff and roles.sales_order.change %} - - {% endif %} -

{% sales_order_status_label order.status large=True %} {% if order.is_overdue %} @@ -39,42 +77,7 @@ src="{% static 'img/blank_image.png' %}" {% endif %}

{{ order.description }}{% include "clip.html"%}

-
- - - {% if roles.sales_order.change %} - -
- - -
- {% if order.status == SalesOrderStatus.PENDING %} - - {% endif %} - {% endif %} -
-{% block below_thumbnail %}
{% if order.status == SalesOrderStatus.PENDING and not order.is_fully_allocated %}
@@ -82,7 +85,7 @@ src="{% static 'img/blank_image.png' %}"
{% endif %}
- {% endblock %} + {% endblock %} {% block details_right %} diff --git a/InvenTree/part/templates/part/cat_link.html b/InvenTree/part/templates/part/cat_link.html index 274cb83710..c8b73a7dc0 100644 --- a/InvenTree/part/templates/part/cat_link.html +++ b/InvenTree/part/templates/part/cat_link.html @@ -1,6 +1,5 @@ {% load i18n %} -
  • {% if category %} {% for path_item in category.parentpath %} diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 42670d0eb3..4202577e0d 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -6,42 +6,45 @@ {% include 'part/category_sidebar.html' %} {% endblock %} +{% block heading %} +{% if category %} +{% trans "Part Category" %}: {{ category.name }} +{% else %} +{% trans "Parts" %} +{% endif %} +{% endblock %} + +{% block actions %} +{% if user.is_staff and roles.part_category.change %} +{% url 'admin:part_partcategory_change' category.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} +{% if category %} +{% if roles.part_category.change %} + +{% endif %} +{% if roles.part_category.delete %} + +{% endif %} +{% endif %} +{% if roles.part_category.add %} + +{% endif %} +{% endblock %} + {% block details_left %} {% if category %} -

    - {% trans "Part Category" %}: {{ category.name }} - {% if user.is_staff and roles.part_category.change %} - - {% endif %} -

    {{ category.description }}

    {% else %} -

    - {% trans "Parts" %} -

    {% trans "Top level part category" %}

    {% endif %} -
    - {% if roles.part_category.add %} - - {% endif %} - {% if category %} - {% if roles.part_category.change %} - - {% endif %} - {% if roles.part_category.delete %} - - {% endif %} - {% endif %} -
    - {% endblock %} {% block details_right %} diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 72db113fc0..b62058aa1f 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -6,7 +6,7 @@ {% load markdownify %} {% block sidebar %} -{% include 'part/sidebar.html' %} +{% include 'part/part_sidebar.html' %} {% endblock %} {% block page_content %} diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index c5f5f846a2..16b119e02d 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -12,14 +12,84 @@ {% include "part/part_thumb.html" %} {% endblock %} +{% block heading %} +{{ part.full_name }} +{% endblock %} + +{% block actions %} + +{% if user.is_staff and roles.part.change %} +{% url 'admin:part_part_change' part.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} + + + +{% if barcodes %} + + +{% endif %} +{% if part.active %} + +{% if roles.stock.change %} + +{% endif %} +{% if part.purchaseable and roles.purchase_order.add %} + +{% endif %} +{% endif %} + +{% if roles.part.add or roles.part.change or roles.part.delete %} +
    + + +
    +{% endif %} +{% endblock %} + {% block details %} -

    - {{ part.full_name }} - - {% if user.is_staff and roles.part.change %} -   - {% endif %} +

    @@ -67,72 +137,7 @@

    - -
    - - {% if barcodes %} - - - {% endif %} - {% if part.active %} - - {% if roles.stock.change %} - - {% endif %} - {% if part.purchaseable and roles.purchase_order.add %} - - {% endif %} - {% endif %} - - {% if roles.part.add or roles.part.change or roles.part.delete %} -
    - - -
    - {% endif %} - -
    diff --git a/InvenTree/part/templates/part/stock_count.html b/InvenTree/part/templates/part/stock_count.html index 4209b80bb6..e12c9bd7b7 100644 --- a/InvenTree/part/templates/part/stock_count.html +++ b/InvenTree/part/templates/part/stock_count.html @@ -4,7 +4,7 @@ {% decimal total_stock %} {% if total_stock == 0 %} -{% trans "No Stock" %} +{% trans "No Stock" %} {% elif total_stock < part.minimum_stock %} -{% trans "Low Stock" %} +{% trans "Low Stock" %} {% endif %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 9efd71e9bc..5a58e2e04f 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -13,9 +13,105 @@ {% endblock %} {% block heading %} -

    - {% trans "Stock Item Details" %} -

    + {% trans "Stock Item" %}: {{ item.part.full_name}} +{% endblock %} + +{% block actions %} + +{% if user.is_staff and roles.stock.change %} +{% url 'admin:stock_stockitem_change' item.pk as url %} +{% include "admin_button.html" with url=url %} +{% endif %} +{% if barcodes %} + +
    + + +
    +{% endif %} + +
    + + +
    + + +{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} + {% if roles.stock.change and not item.is_building %} +
    + + +
    + {% endif %} + + {% if roles.stock.change and not item.is_building %} +
    + + +
    + {% endif %} +{% endif %} {% endblock %} {% block thumbnail %} @@ -29,19 +125,6 @@ {% authorized_owners item.owner as owners %} {% endif %} -

    - {{ item.part.full_name}} - {% if roles.part.view %} - {% endif %} - {% if item.serialized %} - # {{ item.serial }} - {% else %} - × {% decimal item.quantity %} - {% endif %} - {% if user.is_staff and roles.stock.change %} - - {% endif %} -

    {% if item.is_expired %} {% trans "Expired" %} @@ -59,99 +142,7 @@ {% endif %}

    -
    - {% if barcodes %} - -
    - - -
    - {% endif %} - -
    - - -
    - - - {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} - {% if roles.stock.change and not item.is_building %} -
    - - -
    - {% endif %} - - {% if roles.stock.change and not item.is_building %} -
    - - -
    - {% endif %} - {% endif %} -
    diff --git a/InvenTree/stock/templates/stock/loc_link.html b/InvenTree/stock/templates/stock/loc_link.html index 6e5b329b73..23abbb9df3 100644 --- a/InvenTree/stock/templates/stock/loc_link.html +++ b/InvenTree/stock/templates/stock/loc_link.html @@ -1,6 +1,5 @@ {% load i18n %} -
  • {% if location %} {% for path_item in location.parentpath %} diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index c318c1478c..7dfd4e3025 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -7,79 +7,84 @@ {% include "stock/location_sidebar.html" %} {% endblock %} -{% block details_left %} +{% block heading %} {% if location %} -

    - {% trans "Stock Location" %}: {{ location.name }} - {% if user.is_staff and roles.stock_location.change %} - - {% endif %} -

    -

    {{ location.description }}

    +{% trans "Stock Location" %}: {{ location.name }} {% else %} -

    - {% trans "Stock" %} -

    -

    {% trans "Top level stock location" %}

    +{% trans "Stock" %} +{% endif %} +{% endblock %} + +{% block actions %} + +{% if location and user.is_staff and roles.stock_location.change %} +{% url 'admin:stock_stocklocation_change' location.pk as url %} +{% include "admin_button.html" with url=url %} {% endif %} +{% if barcodes %} + +{% if location %}
    - {% 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 %} - - {% endif %} - {% endif %} - {% if barcodes %} - - {% if location %} - - - {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} - {% if roles.stock.change %} - - {% endif %} - {% if roles.stock_location.change %} -
    - - -
    - {% endif %} - {% endif %} - {% endif %} - {% endif %} + +
    + +{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} +{% if roles.stock.change %} + +{% endif %} +{% if roles.stock_location.change %} +
    + + +
    +{% endif %} +{% endif %} +{% endif %} +{% endif %} +{% 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 %} + +{% endif %} +{% endif %} +{% endblock %} + +{% block details_left %} +{% if location %} +

    {{ location.description }}

    +{% else %} +

    {% trans "Top level stock location" %}

    +{% endif %} {% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} {% if owner_control.value == "True" %} diff --git a/InvenTree/templates/admin_button.html b/InvenTree/templates/admin_button.html new file mode 100644 index 0000000000..7186246e4a --- /dev/null +++ b/InvenTree/templates/admin_button.html @@ -0,0 +1,4 @@ +{% load i18n %} + \ No newline at end of file diff --git a/InvenTree/templates/js/dynamic/inventree.js b/InvenTree/templates/js/dynamic/inventree.js index dcff1ec77f..0172e47706 100644 --- a/InvenTree/templates/js/dynamic/inventree.js +++ b/InvenTree/templates/js/dynamic/inventree.js @@ -190,6 +190,13 @@ function inventreeDocReady() { $('.brand-icon').each(function(i, obj) { loadBrandIcon($(this), $(this).attr('brand_name')); }); + + // Callback for "admin view" button + $('#admin-button').click(function() { + var url = $(this).attr('url'); + + location.href = url; + }); } function isFileTransfer(transfer) { diff --git a/InvenTree/templates/page_base.html b/InvenTree/templates/page_base.html index 616731da6f..92130ea7a3 100644 --- a/InvenTree/templates/page_base.html +++ b/InvenTree/templates/page_base.html @@ -6,6 +6,21 @@ {% block content %}
    +
    +
    +

    + {% block heading %} + -- page header goes here -- + {% endblock %} +

    + +
    + {% block actions %} + -- actions go here -- + {% endblock %} +
    +
    +