From 652e6fb83e26b7d623fcb8a37a7a09115395402a Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 18 Jun 2022 22:22:00 +1000 Subject: [PATCH] Sales order tables (#3225) * Add buttons to expand / collapse shipment tables (cherry picked from commit 0af9fc473ee005b7544d204107cfb58ba78c5e30) * Updates for sales order lines table (cherry picked from commit d99ec062adf0c1c8e6c5cae5db921e54e167be8c) --- InvenTree/build/templates/build/detail.html | 9 +---- .../templates/order/sales_order_detail.html | 6 +++ InvenTree/templates/collapse_rows.html | 5 +++ InvenTree/templates/expand_rows.html | 5 +++ InvenTree/templates/js/translated/order.js | 37 ++++++++++++++----- 5 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 InvenTree/templates/collapse_rows.html create mode 100644 InvenTree/templates/expand_rows.html diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index f9bac157a8..26040d0fc6 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -275,13 +275,8 @@ {% if build.has_tracked_bom_items %} - - - + {% include "expand_rows.html" with label="outputs" %} + {% include "collapse_rows.html" with label="outputs" %} {% endif %} {% include "filter_list.html" with id='incompletebuilditems' %} diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index 89346c8118..40b3fa5cab 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -28,6 +28,8 @@
+ {% include "expand_rows.html" with label="sales-lines" %} + {% include "collapse_rows.html" with label="sales-lines" %} {% include "filter_list.html" with id="sales-order-lines" %}
@@ -86,6 +88,8 @@ {% if roles.sales_order.change %}
+ {% include "expand_rows.html" with label="pending-shipments" %} + {% include "collapse_rows.html" with label="pending-shipments" %} {% include "filter_list.html" with id="pending-shipments" %}
@@ -102,6 +106,8 @@
+ {% include "expand_rows.html" with label="completed-shipments" %} + {% include "collapse_rows.html" with label="completed-shipments" %} {% include "filter_list.html" with id="completed-shipments" %}
diff --git a/InvenTree/templates/collapse_rows.html b/InvenTree/templates/collapse_rows.html new file mode 100644 index 0000000000..f9fb454268 --- /dev/null +++ b/InvenTree/templates/collapse_rows.html @@ -0,0 +1,5 @@ +{% load i18n %} + + diff --git a/InvenTree/templates/expand_rows.html b/InvenTree/templates/expand_rows.html new file mode 100644 index 0000000000..bf6ac54425 --- /dev/null +++ b/InvenTree/templates/expand_rows.html @@ -0,0 +1,5 @@ +{% load i18n %} + + diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index 4bc9bcb9cd..0909c02808 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -2540,6 +2540,17 @@ function loadSalesOrderShipmentTable(table, options={}) { setupFilterList('salesordershipment', $(table), options.filter_target); + // Add callbacks for expand / collapse buttons + var prefix = options.shipped ? 'completed' : 'pending'; + + $(`#${prefix}-shipments-expand`).click(function() { + $(table).bootstrapTable('expandAllRows'); + }); + + $(`#${prefix}-shipments-collapse`).click(function() { + $(table).bootstrapTable('collapseAllRows'); + }); + function makeShipmentActions(row) { // Construct "actions" for the given shipment row var pk = row.pk; @@ -3416,6 +3427,15 @@ function loadSalesOrderLineItemTable(table, options={}) { // Show detail view if the PurchaseOrder is PENDING or SHIPPED var show_detail = pending || shipped; + // Add callbacks for expand / collapse buttons + $('#sales-lines-expand').click(function() { + $(table).bootstrapTable('expandAllRows'); + }); + + $('#sales-lines-collapse').click(function() { + $(table).bootstrapTable('collapseAllRows'); + }); + // Table columns to display var columns = [ /* @@ -3543,29 +3563,26 @@ function loadSalesOrderLineItemTable(table, options={}) { title: '{% trans "Available Stock" %}', formatter: function(value, row) { var available = row.available_stock; - var total = row.part_detail.stock; var required = Math.max(row.quantity - row.allocated - row.shipped, 0); var html = ''; - if (total > 0) { + if (available > 0) { var url = `/part/${row.part}/?display=part-stock`; var text = available; - if (total != available) { - text += ` / ${total}`; - } - html = renderLink(text, url); } else { html += `{% trans "No Stock Available" %}`; } - if (available >= required) { - html += ``; - } else { - html += ``; + if (required > 0) { + if (available >= required) { + html += ``; + } else { + html += ``; + } } return html;