From 6a0c5b78ae8728f77e94dc6279a3d90b77987f72 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 Apr 2020 20:56:31 +1000 Subject: [PATCH] Refactor the purchase-order table - Filter by order status --- .../static/script/inventree/order.js | 49 ++++++------------- .../order/templates/order/order_status.html | 13 ----- InvenTree/order/templates/order/po_table.html | 22 --------- .../templates/order/purchase_orders.html | 5 +- InvenTree/templates/status_codes.html | 8 +++ 5 files changed, 26 insertions(+), 71 deletions(-) delete mode 100644 InvenTree/order/templates/order/order_status.html delete mode 100644 InvenTree/order/templates/order/po_table.html diff --git a/InvenTree/InvenTree/static/script/inventree/order.js b/InvenTree/InvenTree/static/script/inventree/order.js index babdf34f83..4ef2fae019 100644 --- a/InvenTree/InvenTree/static/script/inventree/order.js +++ b/InvenTree/InvenTree/static/script/inventree/order.js @@ -104,8 +104,21 @@ function removePurchaseOrderLineItem(e) { function loadPurchaseOrderTable(table, options) { /* Create a purchase-order table */ + var params = options.params || {}; + + var filters = loadTableFilters("build"); + + for (var key in params) { + filters[key] = params[key]; + } + + setupFilterList("order", table); + table.inventreeTable({ url: options.url, + queryParams: filters, + groupBy: false, + original: params, formatNoMatches: function() { return "No purchase orders found"; }, columns: [ { @@ -144,7 +157,7 @@ function loadPurchaseOrderTable(table, options) { field: 'status', title: 'Status', formatter: function(value, row, index, field) { - return orderStatusLabel(row.status, row.status_text); + return orderStatusDisplay(row.status, row.status_text); } }, { @@ -155,37 +168,3 @@ function loadPurchaseOrderTable(table, options) { ], }); } - - -function orderStatusLabel(code, label) { - /* Render a purchase-order status label. */ - - var html = ""; - html += label; - html += ""; - - return html; -} \ No newline at end of file diff --git a/InvenTree/order/templates/order/order_status.html b/InvenTree/order/templates/order/order_status.html deleted file mode 100644 index c9e13cac24..0000000000 --- a/InvenTree/order/templates/order/order_status.html +++ /dev/null @@ -1,13 +0,0 @@ -{% if order.status == OrderStatus.PENDING %} - -{% elif order.status == OrderStatus.PLACED %} - -{% elif order.status == OrderStatus.COMPLETE %} - -{% elif order.status == OrderStatus.CANCELLED or order.status == OrderStatus.RETURNED %} - -{% else %} - -{% endif %} -{{ order.get_status_display }} - \ No newline at end of file diff --git a/InvenTree/order/templates/order/po_table.html b/InvenTree/order/templates/order/po_table.html deleted file mode 100644 index 712553e866..0000000000 --- a/InvenTree/order/templates/order/po_table.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - {% for order in orders %} - - - - - - - - {% endfor %} - -
CompanyOrder ReferenceDescriptionStatusItems
{% include "hover_image.html" with image=order.supplier.image hover=True %}{{ order.supplier.name }}{{ order }}{{ order.description }}{% include "order/order_status.html" %}{{ order.lines.count }}
\ No newline at end of file diff --git a/InvenTree/order/templates/order/purchase_orders.html b/InvenTree/order/templates/order/purchase_orders.html index 644e6418fa..d985b814df 100644 --- a/InvenTree/order/templates/order/purchase_orders.html +++ b/InvenTree/order/templates/order/purchase_orders.html @@ -13,8 +13,11 @@ InvenTree | Purchase Orders
-
+
+
+ +
diff --git a/InvenTree/templates/status_codes.html b/InvenTree/templates/status_codes.html index 0d92b6f467..36d5aa8b3e 100644 --- a/InvenTree/templates/status_codes.html +++ b/InvenTree/templates/status_codes.html @@ -1,3 +1,6 @@ +/* + * Status codes for the {{ label }} model. + */ var {{ label }}Codes = { {% for opt in options %}'{{ opt.key }}': { key: '{{ opt.key }}', @@ -6,6 +9,11 @@ var {{ label }}Codes = { },{% endfor %} }; +/* + * Render the status for a {{ label }} object. + * Uses the values specified in "status_codes.py" + * This function is generated by the "status_codes.html" template + */ function {{ label }}StatusDisplay(key) { key = String(key);