From 425db5fd39dfb7df90903143ed07be4bf3cb6def Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 7 May 2018 21:51:08 +1000 Subject: [PATCH] Tweaked part stock page --- InvenTree/part/templates/part/stock.html | 57 +++++++++++++++++-- InvenTree/static/script/inventree/stock.js | 16 ++++++ InvenTree/stock/templates/stock/location.html | 2 +- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index 3efe9af05e..3f6f41d1c6 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -4,19 +4,30 @@ {% include 'part/tabs.html' with tab='stock' %} -

Part Stock

-

Part Stock

-
+

- +
+ + +

+
+
@@ -25,6 +36,8 @@ {% block js_load %} {{ block.super }} + + {% endblock %} {% block js_ready %} {{ block.super }} @@ -43,6 +56,7 @@ $("#stock-table").bootstrapTable({ sortable: true, search: true, + pagination: true, queryParams: function(p) { return { part: {{ part.id }}, @@ -79,4 +93,39 @@ url: "{% url 'api-stock-list' %}" }); + function selectedStock() { + return $("#stock-table").bootstrapTable('getSelections'); + } + + $("#multi-item-move").click(function() { + + var items = selectedStock(); + + moveStockItems(items, + { + success: function() { + $("#stock-table").bootstrapTable('refresh'); + } + }); + + return false; + }); + + $("#multi-item-delete").click(function() { + + var items = selectedStock(); + + deleteStockItems(items, {}); + + return false; + }); + + $("#multi-item-stocktake").click(function() { + var items = selectedStock(); + + countStockItems(items, {}); + + return false; + }); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js index 4bca89e4a0..55e9f2d423 100644 --- a/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/static/script/inventree/stock.js @@ -85,6 +85,22 @@ function moveStockItems(items, options) { }); } +function countStockItems(items, options) { + var modal = '#modal-form'; + + if ('modal' in options) { + modal = options.modal; + } + + if (items.length == 0) { + alert('No stock items selected'); + return; + } + + openModal(modal); + modalSetTitle(modal, 'Stocktake'); +} + function deleteStockItems(items, options) { var modal = '#modal-delete'; diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index d5df1a0715..43b7cebb8f 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -148,7 +148,7 @@ $("#multi-item-stocktake").click(function() { var items = selectedStock(); - alert('Stocktake on ' + items.length + ' items'); + countStockItems(items, {}); return false; });