From 6df6a460e4dbe1cd83d2d78b1258805f5186e40b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 19 Feb 2021 17:48:32 +1100 Subject: [PATCH 1/8] Add items using javascript --- InvenTree/templates/InvenTree/index.html | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 36e4f8bc49..3343eb3ce7 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -9,6 +9,15 @@ InvenTree | {% trans "Index" %}

InvenTree


+
+ +
+
+ +
+
{% if roles.part.view %} {% include "InvenTree/latest_parts.html" with collapse_id="latest_parts" %} @@ -52,6 +61,64 @@ InvenTree | {% trans "Index" %} {{ block.super }} +function addHeaderTitle(title) { + // Add a header block to the action list + $("#action-item-list").append( + `
  • ${title}
  • ` + ); +} + +function addHeaderAction(label, title, icon) { + // Add an action block to the action list + $("#action-item-list").append( + `
  • + + + ${title} + + + + +
  • ` + ); +} + +{% if roles.part.view %} +addHeaderTitle('{% trans "Parts" %}'); +addHeaderAction('starred-parts', '{% trans "Starred Parts" %}', 'fa-star'); +addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper'); +addHeaderAction('bom-validation', '{% trans "BOM Waiting Validation" %}', 'fa-times-circle'); +{% endif %} + +{% if roles.stock.view %} +addHeaderTitle('{% trans "Stock" %}'); +addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-shopping-cart'); +addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa-bullhorn'); +{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %} +{% if expiry %} +addHeaderAction('expired-stock', '{% trans "Expired Stock" %}', 'fa-calendar-times'); +addHeaderAction('stale-stock', '{% trans "Stale Stock" %}', 'fa-stopwatch'); +{% endif %} +{% endif %} + +{% if roles.build.view %} +addHeaderTitle('{% trans "Build Orders" %}'); +addHeaderAction('build-pending', '{% trans "In Progress" %}', 'fa-cogs'); +addHeaderAction('build-overdue', '{% trans "Overdue" %}', 'fa-calendar-times'); +{% endif %} + +{% if roles.purchase_order.view %} +addHeaderTitle('{% trans "Purchase Orders" %}'); +addHeaderAction('po-outstanding', '{% trans "Outstanding" %}', 'fa-sign-in-alt'); +addHeaderAction('po-overdue', '{% trans "Overdue" %}', 'fa-calendar-times'); +{% endif %} + +{% if roles.sales_order.view %} +addHeaderTitle('{% trans "Sales Orders" %}'); +addHeaderAction('so-outstanding', '{% trans "Outstanding" %}', 'fa-sign-out-alt'); +addHeaderAction('so-overdue', '{% trans "Overdue" %}', 'fa-calendar-times'); +{% endif %} + loadSimplePartTable("#latest-parts-table", "{% url 'api-part-list' %}", { params: { ordering: "-creation_date", From 116ea651600cd7d7e500dbdb5192af93e957258d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 19 Feb 2021 17:57:38 +1100 Subject: [PATCH 2/8] Show / hide panels --- InvenTree/templates/InvenTree/index.html | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 3343eb3ce7..937bcf84e3 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -71,7 +71,7 @@ function addHeaderTitle(title) { function addHeaderAction(label, title, icon) { // Add an action block to the action list $("#action-item-list").append( - `
  • + `
  • ${title} @@ -81,6 +81,27 @@ function addHeaderAction(label, title, icon) {
  • ` ); + + // Add a detail item to the detail item-panel + $("#detail-item-list").append( + `
  • +

    ${title}

    +
    +
  • ` + ); + + $(`#detail-${label}`).hide(); + + $(`#action-${label}`).click(function() { + + // Hide all child elements + $('#detail-item-list').children('li').each(function() { + $(this).hide(); + }); + + // Show the one we want + $(`#detail-${label}`).show(); + }); } {% if roles.part.view %} From 9d12d435743c0c072fa5bb0f00fddb3500a8ff59 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 19 Feb 2021 18:10:10 +1100 Subject: [PATCH 3/8] Cleanup / refactor --- .../templates/InvenTree/bom_invalid.html | 15 -- .../templates/InvenTree/build_overdue.html | 15 -- .../templates/InvenTree/build_pending.html | 15 -- .../templates/InvenTree/expired_stock.html | 15 -- InvenTree/templates/InvenTree/index.html | 210 ++++++++---------- .../templates/InvenTree/index/on_load.html | 5 - .../templates/InvenTree/latest_parts.html | 15 -- InvenTree/templates/InvenTree/low_stock.html | 15 -- .../templates/InvenTree/po_outstanding.html | 15 -- InvenTree/templates/InvenTree/po_overdue.html | 15 -- .../InvenTree/required_stock_build.html | 15 -- .../templates/InvenTree/so_outstanding.html | 15 -- InvenTree/templates/InvenTree/so_overdue.html | 15 -- .../templates/InvenTree/stale_stock.html | 15 -- .../templates/InvenTree/starred_parts.html | 15 -- 15 files changed, 87 insertions(+), 323 deletions(-) delete mode 100644 InvenTree/templates/InvenTree/bom_invalid.html delete mode 100644 InvenTree/templates/InvenTree/build_overdue.html delete mode 100644 InvenTree/templates/InvenTree/build_pending.html delete mode 100644 InvenTree/templates/InvenTree/expired_stock.html delete mode 100644 InvenTree/templates/InvenTree/index/on_load.html delete mode 100644 InvenTree/templates/InvenTree/latest_parts.html delete mode 100644 InvenTree/templates/InvenTree/low_stock.html delete mode 100644 InvenTree/templates/InvenTree/po_outstanding.html delete mode 100644 InvenTree/templates/InvenTree/po_overdue.html delete mode 100644 InvenTree/templates/InvenTree/required_stock_build.html delete mode 100644 InvenTree/templates/InvenTree/so_outstanding.html delete mode 100644 InvenTree/templates/InvenTree/so_overdue.html delete mode 100644 InvenTree/templates/InvenTree/stale_stock.html delete mode 100644 InvenTree/templates/InvenTree/starred_parts.html diff --git a/InvenTree/templates/InvenTree/bom_invalid.html b/InvenTree/templates/InvenTree/bom_invalid.html deleted file mode 100644 index 46e698dcc3..0000000000 --- a/InvenTree/templates/InvenTree/bom_invalid.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "BOM Waiting Validation" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/build_overdue.html b/InvenTree/templates/InvenTree/build_overdue.html deleted file mode 100644 index 9270336de1..0000000000 --- a/InvenTree/templates/InvenTree/build_overdue.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Overdue Builds" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/build_pending.html b/InvenTree/templates/InvenTree/build_pending.html deleted file mode 100644 index fce1c6df02..0000000000 --- a/InvenTree/templates/InvenTree/build_pending.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Pending Builds" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/expired_stock.html b/InvenTree/templates/InvenTree/expired_stock.html deleted file mode 100644 index 20e2591c16..0000000000 --- a/InvenTree/templates/InvenTree/expired_stock.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Expired Stock" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 937bcf84e3..c72dd5264a 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -15,40 +15,8 @@ InvenTree | {% trans "Index" %}
      -
    -
    -
    - {% if roles.part.view %} - {% include "InvenTree/latest_parts.html" with collapse_id="latest_parts" %} - {% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %} - {% include "InvenTree/starred_parts.html" with collapse_id="starred" %} - {% endif %} - {% if roles.build.view %} - {% include "InvenTree/build_pending.html" with collapse_id="build_pending" %} - {% include "InvenTree/build_overdue.html" with collapse_id="build_overdue" %} - {% endif %} -
    -
    - {% if roles.stock.view %} - {% include "InvenTree/low_stock.html" with collapse_id="order" %} - {% settings_value "STOCK_ENABLE_EXPIRY" as expiry %} - {% if expiry %} - {% include "InvenTree/expired_stock.html" with collapse_id="expired" %} - {% include "InvenTree/stale_stock.html" with collapse_id="stale" %} - {% endif %} - {% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %} - {% endif %} -
    -
    - {% if roles.purchase_order.view %} - {% include "InvenTree/po_outstanding.html" with collapse_id="po_outstanding" %} - {% endif %} - {% include "InvenTree/po_overdue.html" with collapse_id="po_overdue" %} - {% if roles.sales_order.view %} - {% include "InvenTree/so_outstanding.html" with collapse_id="so_outstanding" %} - {% include "InvenTree/so_overdue.html" with collapse_id="so_overdue" %} - {% endif %} +
    {% endblock %} @@ -68,7 +36,7 @@ function addHeaderTitle(title) { ); } -function addHeaderAction(label, title, icon) { +function addHeaderAction(label, title, icon, options) { // Add an action block to the action list $("#action-item-list").append( `
  • @@ -86,7 +54,7 @@ function addHeaderAction(label, title, icon) { $("#detail-item-list").append( `
  • ${title}

    -
    +
  • ` ); @@ -102,6 +70,13 @@ function addHeaderAction(label, title, icon) { // Show the one we want $(`#detail-${label}`).show(); }); + + // Connect a callback to the table + $(`#table-${label}`).on('load-success.bs.table', function() { + var count = $(`#table-${label}`).bootstrapTable('getData').length; + + $(`#badge-${label}`).html(count); + }); } {% if roles.part.view %} @@ -109,6 +84,30 @@ addHeaderTitle('{% trans "Parts" %}'); addHeaderAction('starred-parts', '{% trans "Starred Parts" %}', 'fa-star'); addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper'); addHeaderAction('bom-validation', '{% trans "BOM Waiting Validation" %}', 'fa-times-circle'); + + +loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", { + params: { + ordering: "-creation_date", + limit: 10, + }, + name: 'latest_parts', +}); + +loadSimplePartTable("#table-starred-parts", "{% url 'api-part-list' %}", { + params: { + "starred": true, + }, + name: 'starred_parts', +}); + +loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", { + params: { + "bom_valid": false, + }, + name: 'bom_invalid_parts', +}); + {% endif %} {% if roles.stock.view %} @@ -119,50 +118,47 @@ addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa {% if expiry %} addHeaderAction('expired-stock', '{% trans "Expired Stock" %}', 'fa-calendar-times'); addHeaderAction('stale-stock', '{% trans "Stale Stock" %}', 'fa-stopwatch'); + +loadStockTable($("#table-expired-stock"), { + params: { + expired: true, + location_detail: true, + part_detail: true, + }, +}); + +loadStockTable($("#table-stale-stock"), { + params: { + stale: true, + expired: false, + location_detail: true, + part_detail: true, + }, +}); {% endif %} + +loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", { + params: { + low_stock: true, + }, + name: "low_stock_parts", +}); + +loadSimplePartTable("#table-stock-to-build", "{% url 'api-part-list' %}", { + params: { + stock_to_build: true, + }, + name: "to_build_parts", +}); + {% endif %} {% if roles.build.view %} addHeaderTitle('{% trans "Build Orders" %}'); -addHeaderAction('build-pending', '{% trans "In Progress" %}', 'fa-cogs'); -addHeaderAction('build-overdue', '{% trans "Overdue" %}', 'fa-calendar-times'); -{% endif %} +addHeaderAction('build-pending', '{% trans "Build Orders In Progress" %}', 'fa-cogs'); +addHeaderAction('build-overdue', '{% trans "Overdue Build Orders" %}', 'fa-calendar-times'); -{% if roles.purchase_order.view %} -addHeaderTitle('{% trans "Purchase Orders" %}'); -addHeaderAction('po-outstanding', '{% trans "Outstanding" %}', 'fa-sign-in-alt'); -addHeaderAction('po-overdue', '{% trans "Overdue" %}', 'fa-calendar-times'); -{% endif %} - -{% if roles.sales_order.view %} -addHeaderTitle('{% trans "Sales Orders" %}'); -addHeaderAction('so-outstanding', '{% trans "Outstanding" %}', 'fa-sign-out-alt'); -addHeaderAction('so-overdue', '{% trans "Overdue" %}', 'fa-calendar-times'); -{% endif %} - -loadSimplePartTable("#latest-parts-table", "{% url 'api-part-list' %}", { - params: { - ordering: "-creation_date", - limit: 10, - }, - name: 'latest_parts', -}); - -loadSimplePartTable("#starred-parts-table", "{% url 'api-part-list' %}", { - params: { - "starred": true, - }, - name: 'starred_parts', -}); - -loadSimplePartTable("#bom-invalid-table", "{% url 'api-part-list' %}", { - params: { - "bom_valid": false, - }, - name: 'bom_invalid_parts', -}); - -loadBuildTable("#build-pending-table", { +loadBuildTable("#table-build-pending", { url: "{% url 'api-build-list' %}", params: { part_detail: true, @@ -171,7 +167,7 @@ loadBuildTable("#build-pending-table", { disableFilters: true, }); -loadBuildTable("#build-overdue-table", { +loadBuildTable("#table-build-overdue", { url: "{% url 'api-build-list' %}", params: { part_detail: true, @@ -179,39 +175,14 @@ loadBuildTable("#build-overdue-table", { }, disableFilters: true, }); +{% endif %} -loadStockTable($("#expired-stock-table"), { - params: { - expired: true, - location_detail: true, - part_detail: true, - }, -}); +{% if roles.purchase_order.view %} +addHeaderTitle('{% trans "Purchase Orders" %}'); +addHeaderAction('po-outstanding', '{% trans "Outstanding Purchase Orders" %}', 'fa-sign-in-alt'); +addHeaderAction('po-overdue', '{% trans "Overdue Purchase Orders" %}', 'fa-calendar-times'); -loadStockTable($("#stale-stock-table"), { - params: { - stale: true, - expired: false, - location_detail: true, - part_detail: true, - }, -}); - -loadSimplePartTable("#low-stock-table", "{% url 'api-part-list' %}", { - params: { - low_stock: true, - }, - name: "low_stock_parts", -}); - -loadSimplePartTable("#stock-to-build-table", "{% url 'api-part-list' %}", { - params: { - stock_to_build: true, - }, - name: "to_build_parts", -}); - -loadPurchaseOrderTable("#po-outstanding-table", { +loadPurchaseOrderTable("#table-po-outstanding", { url: "{% url 'api-po-list' %}", params: { supplier_detail: true, @@ -219,7 +190,7 @@ loadPurchaseOrderTable("#po-outstanding-table", { } }); -loadPurchaseOrderTable("#po-overdue-table", { +loadPurchaseOrderTable("#table-po-overdue", { url: "{% url 'api-po-list' %}", params: { supplier_detail: true, @@ -227,7 +198,14 @@ loadPurchaseOrderTable("#po-overdue-table", { } }); -loadSalesOrderTable("#so-outstanding-table", { +{% endif %} + +{% if roles.sales_order.view %} +addHeaderTitle('{% trans "Sales Orders" %}'); +addHeaderAction('so-outstanding', '{% trans "Outstanding Sales Orders" %}', 'fa-sign-out-alt'); +addHeaderAction('so-overdue', '{% trans "Overdue Sales Orders" %}', 'fa-calendar-times'); + +loadSalesOrderTable("#table-so-outstanding", { url: "{% url 'api-so-list' %}", params: { customer_detail: true, @@ -235,7 +213,7 @@ loadSalesOrderTable("#so-outstanding-table", { }, }); -loadSalesOrderTable("#so-overdue-table", { +loadSalesOrderTable("#table-so-overdue", { url: "{% url 'api-so-list' %}", params: { overdue: true, @@ -243,20 +221,6 @@ loadSalesOrderTable("#so-overdue-table", { } }); -{% include "InvenTree/index/on_load.html" with label="latest-parts" %} -{% include "InvenTree/index/on_load.html" with label="starred-parts" %} -{% include "InvenTree/index/on_load.html" with label="bom-invalid" %} -{% include "InvenTree/index/on_load.html" with label="build-pending" %} -{% include "InvenTree/index/on_load.html" with label="build-overdue" %} - -{% include "InvenTree/index/on_load.html" with label="expired-stock" %} -{% include "InvenTree/index/on_load.html" with label="stale-stock" %} -{% include "InvenTree/index/on_load.html" with label="low-stock" %} -{% include "InvenTree/index/on_load.html" with label="stock-to-build" %} - -{% include "InvenTree/index/on_load.html" with label="po-outstanding" %} -{% include "InvenTree/index/on_load.html" with label="po-overdue" %} -{% include "InvenTree/index/on_load.html" with label="so-outstanding" %} -{% include "InvenTree/index/on_load.html" with label="so-overdue" %} +{% endif %} {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/index/on_load.html b/InvenTree/templates/InvenTree/index/on_load.html deleted file mode 100644 index a63479e60d..0000000000 --- a/InvenTree/templates/InvenTree/index/on_load.html +++ /dev/null @@ -1,5 +0,0 @@ -$("#{{ label }}-table").on('load-success.bs.table', function() { - var count = $("#{{ label }}-table").bootstrapTable('getData').length; - - $("#{{ label }}-count").html(count); -}); \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/latest_parts.html b/InvenTree/templates/InvenTree/latest_parts.html deleted file mode 100644 index e88ada9548..0000000000 --- a/InvenTree/templates/InvenTree/latest_parts.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Latest Parts" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/low_stock.html b/InvenTree/templates/InvenTree/low_stock.html deleted file mode 100644 index a4d2fb4e0f..0000000000 --- a/InvenTree/templates/InvenTree/low_stock.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Low Stock" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/po_outstanding.html b/InvenTree/templates/InvenTree/po_outstanding.html deleted file mode 100644 index 8393e36b97..0000000000 --- a/InvenTree/templates/InvenTree/po_outstanding.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Outstanding Purchase Orders" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/po_overdue.html b/InvenTree/templates/InvenTree/po_overdue.html deleted file mode 100644 index 99e3e7d40f..0000000000 --- a/InvenTree/templates/InvenTree/po_overdue.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Overdue Purchase Orders" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/required_stock_build.html b/InvenTree/templates/InvenTree/required_stock_build.html deleted file mode 100644 index 337ed289ba..0000000000 --- a/InvenTree/templates/InvenTree/required_stock_build.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Require Stock To Complete Build" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/so_outstanding.html b/InvenTree/templates/InvenTree/so_outstanding.html deleted file mode 100644 index a1c978264f..0000000000 --- a/InvenTree/templates/InvenTree/so_outstanding.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Outstanding Sales Orders" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/so_overdue.html b/InvenTree/templates/InvenTree/so_overdue.html deleted file mode 100644 index bf2b64a1e3..0000000000 --- a/InvenTree/templates/InvenTree/so_overdue.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Overdue Sales Orders" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/stale_stock.html b/InvenTree/templates/InvenTree/stale_stock.html deleted file mode 100644 index 3cbb74369c..0000000000 --- a/InvenTree/templates/InvenTree/stale_stock.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Stale Stock" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/starred_parts.html b/InvenTree/templates/InvenTree/starred_parts.html deleted file mode 100644 index ae8b9ecc1d..0000000000 --- a/InvenTree/templates/InvenTree/starred_parts.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "collapse_index.html" %} - -{% load i18n %} - -{% block collapse_title %} - -{% trans "Starred Parts" %} -{% endblock %} - -{% block collapse_content %} - - -
    - -{% endblock %} \ No newline at end of file From d11adf3b346feeeb08a62b60cd724794281d1412 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 21 Feb 2021 20:18:14 +1100 Subject: [PATCH 4/8] fade in --- InvenTree/templates/InvenTree/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index c72dd5264a..bad3d3e9d7 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -68,7 +68,7 @@ function addHeaderAction(label, title, icon, options) { }); // Show the one we want - $(`#detail-${label}`).show(); + $(`#detail-${label}`).fadeIn(); }); // Connect a callback to the table From e53c6e9975cea9d7ca743a1659ff0ab0c7a0fce2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 21 Feb 2021 20:29:48 +1100 Subject: [PATCH 5/8] Fancy --- InvenTree/InvenTree/static/css/inventree.css | 10 ++++++++++ InvenTree/templates/InvenTree/index.html | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index ac3d402c3b..2e044d3e6f 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -50,6 +50,16 @@ border-radius: 5px; } +.index-bg { + width: 100%; + object-fit: fill; + opacity: 5%; +} + +.index-action-selected { + background-color: #EEEEF5; +} + .markdownx .row { margin: 5px; padding: 5px; diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index bad3d3e9d7..ff69bf16d7 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n %} +{% load static %} {% load inventree_extras %} {% block page_title %} InvenTree | {% trans "Index" %} @@ -15,7 +16,11 @@ InvenTree | {% trans "Index" %}
      - +
    • +
      + +
      +
    @@ -69,6 +74,14 @@ function addHeaderAction(label, title, icon, options) { // Show the one we want $(`#detail-${label}`).fadeIn(); + + // Remove css class from all action items + $("#action-item-list").children('li').each(function() { + $(this).removeClass('index-action-selected'); + }) + + // Add css class to the action we are interested in + $(`#action-${label}`).addClass('index-action-selected'); }); // Connect a callback to the table From 745188082b38fb5842be0d72d42674ce9d6193e1 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 21 Feb 2021 21:06:44 +1100 Subject: [PATCH 6/8] Add more searchable fields to SupplierPart model --- InvenTree/company/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index 731fd193fa..3398760d45 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -184,6 +184,8 @@ class SupplierPartList(generics.ListCreateAPIView): 'manufacturer__name', 'description', 'MPN', + 'part__name', + 'part__description', ] From afd7199a69a4ece29c2beddb99beae0b1c068c38 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 21 Feb 2021 21:06:52 +1100 Subject: [PATCH 7/8] Cleanup search page too --- InvenTree/InvenTree/static/css/inventree.css | 8 + InvenTree/templates/InvenTree/index.html | 10 +- InvenTree/templates/InvenTree/search.html | 232 ++++++++++++------- 3 files changed, 159 insertions(+), 91 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 2e044d3e6f..a0053e5f53 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -497,6 +497,14 @@ background-color: #f33; } +.badge-orange { + background-color: #fcba03; +} + +.badge-green { + background-color: #1A1; +} + .part-thumb { width: 200px; height: 200px; diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index ff69bf16d7..687ceaf0ee 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -26,10 +26,6 @@ InvenTree | {% trans "Index" %} {% endblock %} -{% block js_load %} -{{ block.super }} -{% endblock %} - {% block js_ready %} {{ block.super }} @@ -78,7 +74,7 @@ function addHeaderAction(label, title, icon, options) { // Remove css class from all action items $("#action-item-list").children('li').each(function() { $(this).removeClass('index-action-selected'); - }) + }); // Add css class to the action we are interested in $(`#action-${label}`).addClass('index-action-selected'); @@ -89,6 +85,10 @@ function addHeaderAction(label, title, icon, options) { var count = $(`#table-${label}`).bootstrapTable('getData').length; $(`#badge-${label}`).html(count); + + if (count > 0) { + $(`#badge-${label}`).addClass('badge-orange'); + } }); } diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index d78204270a..4fc7442856 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -9,98 +9,123 @@ InvenTree | {% trans "Search Results" %} {% block content %} -

    {% trans "Search Results" %}

    +

    + {% trans "Search Results" %} +

    -
    -{% include "search_form.html" with query_text=query %} +
    + {% include "search_form.html" with query_text=query %}
    -

    -
    - {% if query %} - -
    -

    {% trans "No results found for " %}'{{ query }}'

    -
    - -{% include "InvenTree/search_part_category.html" with collapse_id="categories" %} - -{% include "InvenTree/search_parts.html" with collapse_id='parts' %} - -{% include "InvenTree/search_company.html" with collapse_id='companies' %} - -{% include "InvenTree/search_supplier_parts.html" with collapse_id='supplier_parts' %} - -{% include "InvenTree/search_stock_location.html" with collapse_id="locations" %} - -{% include "InvenTree/search_stock_items.html" with collapse_id="stock" %} - {% else %} -
    -

    {% trans "Enter a search query" %}

    +

    {% trans "Enter a search query" %}

    - {% endif %} -{% endblock %} +
    +
      +
    +
    +
    +
      +
    • +
      + +
      +
    • +
    +
    -{% block js_load %} -{{ block.super }} - {% endblock %} {% block js_ready %} {{ block.super }} - function onSearchResults(table, output) { + function addItemTitle(title) { + // Add header block to the results list + $('#search-item-list').append( + `
  • ${title}
  • ` + ); + } - $(table).on('load-success.bs.table', function() { + function addItem(label, title, icon, options) { + // Add a search itme to the action list + $('#search-item-list').append( + `
  • + + + ${title} + + + + +
  • ` + ); - var panel = $(output).closest('.panel-group'); + // Add a results table + $('#search-result-list').append( + `
  • +

    ${title}

    +
    +
  • ` + ); - var n = $(table).bootstrapTable('getData').length; + // Hide the results table + $(`#search-result-${label}`).hide(); - var text = ''; - if (n == 0) { - text = 'No results' + // Add callback when the action is clicked + $(`#search-item-${label}`).click(function() { - $(panel).hide(); + // Hide all childs + $('#search-result-list').children('li').each(function() { + $(this).hide(); + }); - } else { - text = n + ' result'; + // Show the one we want + $(`#search-result-${label}`).fadeIn(); - if (n > 1) { - text += 's'; - } + // Remove css class from all action items + $("#search-item-list").children('li').each(function() { + $(this).removeClass('index-action-selected'); + }); + + // Add css class to the action we are interested in + $(`#search-item-${label}`).addClass('index-action-selected'); + }); - $(panel).show(); + // Connect a callback to the table + $(`#table-${label}`).on('load-success.bs.table', function() { + var count = $(`#table-${label}`).bootstrapTable('getData').length; - var collapse = panel.find('.panel-collapse'); + $(`#badge-${label}`).html(count); - collapse.collapse('show'); - - $("#no-search-results").hide(); + if (count > 0) { + $(`#badge-${label}`).addClass('badge-orange'); } - - $(output).html(`${text}`); }); } - onSearchResults("#category-results-table", "#category-results-count"); - - onSearchResults("#location-results-table", "#location-results-count"); - - onSearchResults("#stock-results-table", "#stock-results-count"); - - onSearchResults('#part-results-table', '#part-result-count'); + {% if roles.part.view %} + addItemTitle('{% trans "Part" %}'); - onSearchResults('#company-results-table', '#company-result-count'); - - onSearchResults('#supplier-part-results-table', '#supplier-part-result-count'); + addItem('part', '{% trans "Parts" %}', 'fa-shapes'); - $("#category-results-table").inventreeTable({ + loadPartTable("#table-part", + "{% url 'api-part-list' %}", + { + params: { + search: "{{ query }}", + }, + checkbox: false, + disableFilters: true, + } + ); + + addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap'); + + $("#table-category").inventreeTable({ url: "{% url 'api-part-category-list' %}", queryParams: { search: "{{ query }}", @@ -120,7 +145,29 @@ InvenTree | {% trans "Search Results" %} ], }); - $('#stock-results-table').inventreeTable({ + addItem('supplier-part', '{% trans "Supplier Parts" %}', 'fa-pallet'); + + loadSupplierPartTable( + "#table-supplier-part", + "{% url 'api-supplier-part-list' %}", + { + params: { + search: "{{ query }}", + part_detail: true, + supplier_detail: true, + manufacturer_detail: true + }, + } + ); + + {% endif %} + + {% if roles.stock.view %} + addItemTitle('{% trans "Stock" %}'); + + addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes'); + + $('#table-stock').inventreeTable({ url: "{% url 'api-stock-list' %}", queryParams: { search: "{{ query }}", @@ -199,8 +246,9 @@ InvenTree | {% trans "Search Results" %} ] }); + addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt'); - $("#location-results-table").inventreeTable({ + $("#table-location").inventreeTable({ url: "{% url 'api-location-list' %}", queryParams: { search: "{{ query }}", @@ -220,36 +268,48 @@ InvenTree | {% trans "Search Results" %} ], }); + {% endif %} - loadPartTable("#part-results-table", - "{% url 'api-part-list' %}", - { - params: { - search: "{{ query }}", - }, - checkbox: false, - disableFilters: true, - } - ); - + {% if roles.purchase_order.view or roles.sales_order.view %} + addItemTitle('{% trans "Company" %}'); - loadCompanyTable('#company-results-table', "{% url 'api-company-list' %}", { + {% if roles.purchase_order.view %} + addItem('supplier', '{% trans "Suppliers" %}', 'fa-building'); + + loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", { params: { search: "{{ query }}", + is_supplier: "true", } }); - loadSupplierPartTable( - "#supplier-part-results-table", - "{% url 'api-supplier-part-list' %}", - { - params: { - search: "{{ query }}", - part_detail: true, - supplier_detail: true, - manufacturer_detail: true - }, + addItem('manufacturer', '{% trans "Manufacturers" %}', 'fa-industry'); + + loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", { + params: { + search: "{{ query }}", + is_manufacturer: "true", } - ); + }); + + + {% endif %} + + {% if roles.sales_order.view %} + addItem('customer', '{% trans "Customers" %}', 'fa-user-tie'); + + loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", { + params: { + search: "{{ query }}", + is_customer: "true", + } + }); + + {% endif %} + + {% endif %} + + + {% endblock %} \ No newline at end of file From 2b1101e165aabb6f4014e5c1f1fafc1639a6a24c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 21 Feb 2021 21:09:55 +1100 Subject: [PATCH 8/8] remove unused files --- .../templates/InvenTree/search_company.html | 14 ------------- .../InvenTree/search_part_category.html | 14 ------------- .../templates/InvenTree/search_parts.html | 21 ------------------- .../InvenTree/search_stock_items.html | 16 -------------- .../InvenTree/search_stock_location.html | 16 -------------- .../InvenTree/search_supplier_parts.html | 14 ------------- InvenTree/templates/InvenTree/searching.html | 3 --- 7 files changed, 98 deletions(-) delete mode 100644 InvenTree/templates/InvenTree/search_company.html delete mode 100644 InvenTree/templates/InvenTree/search_part_category.html delete mode 100644 InvenTree/templates/InvenTree/search_parts.html delete mode 100644 InvenTree/templates/InvenTree/search_stock_items.html delete mode 100644 InvenTree/templates/InvenTree/search_stock_location.html delete mode 100644 InvenTree/templates/InvenTree/search_supplier_parts.html delete mode 100644 InvenTree/templates/InvenTree/searching.html diff --git a/InvenTree/templates/InvenTree/search_company.html b/InvenTree/templates/InvenTree/search_company.html deleted file mode 100644 index 776f661819..0000000000 --- a/InvenTree/templates/InvenTree/search_company.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "collapse.html" %} - -{% block collapse_title %} -

    Companies

    -{% endblock %} - -{% block collapse_heading %} -

    {% include "InvenTree/searching.html" %}

    -{% endblock %} - -{% block collapse_content %} - -
    -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_part_category.html b/InvenTree/templates/InvenTree/search_part_category.html deleted file mode 100644 index 899aca094c..0000000000 --- a/InvenTree/templates/InvenTree/search_part_category.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "collapse.html" %} - -{% block collapse_title %} -

    Part Categories

    -{% endblock %} - -{% block collapse_heading %} -

    {% include "InvenTree/searching.html" %}

    -{% endblock %} - -{% block collapse_content %} - -
    -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_parts.html b/InvenTree/templates/InvenTree/search_parts.html deleted file mode 100644 index ca75b096c2..0000000000 --- a/InvenTree/templates/InvenTree/search_parts.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "collapse.html" %} - -{% block collapse_title %} -

    Parts

    -{% endblock %} - -{% block collapse_heading %} -

    {% include "InvenTree/searching.html" %}

    -{% endblock %} - -{% block collapse_content %} -
    -
    - -
    -
    -
    - - -
    -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_stock_items.html b/InvenTree/templates/InvenTree/search_stock_items.html deleted file mode 100644 index 16d1542d96..0000000000 --- a/InvenTree/templates/InvenTree/search_stock_items.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "collapse.html" %} - -{% load i18n %} - -{% block collapse_title %} -

    {% trans "Stock Items" %}

    -{% endblock %} - -{% block collapse_heading %} -

    {% include "InvenTree/searching.html" %}

    -{% endblock %} - -{% block collapse_content %} - -
    -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_stock_location.html b/InvenTree/templates/InvenTree/search_stock_location.html deleted file mode 100644 index 1778e6256d..0000000000 --- a/InvenTree/templates/InvenTree/search_stock_location.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "collapse.html" %} - -{% load i18n %} - -{% block collapse_title %} -

    {% trans "Stock Locations" %}

    -{% endblock %} - -{% block collapse_heading %} -

    {% include "InvenTree/searching.html" %}

    -{% endblock %} - -{% block collapse_content %} - -
    -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_supplier_parts.html b/InvenTree/templates/InvenTree/search_supplier_parts.html deleted file mode 100644 index 04ee32cc5b..0000000000 --- a/InvenTree/templates/InvenTree/search_supplier_parts.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "collapse.html" %} - -{% block collapse_title %} -

    Supplier Parts

    -{% endblock %} - -{% block collapse_heading %} -

    {% include "InvenTree/searching.html" %}

    -{% endblock %} - -{% block collapse_content %} - -
    -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/searching.html b/InvenTree/templates/InvenTree/searching.html deleted file mode 100644 index d2c8dd0363..0000000000 --- a/InvenTree/templates/InvenTree/searching.html +++ /dev/null @@ -1,3 +0,0 @@ -{% load i18n %} - - {% trans "Searching" %}