diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index e5892843f3..c8d3f35cd6 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -15,10 +15,17 @@ function getStockLocations(filters={}, options={}) { } // A map of available filters for the stock table -function getStockFilterOptions() { +function getAvailableStockFilters() { return { 'cascade': { 'type': 'bool', + 'description': 'Include stock in sublocations', + 'title': 'sublocations', + }, + 'active': { + 'type': 'bool', + 'title': 'part active', + 'description': 'Show stock for active parts', }, 'status': { 'options': { @@ -28,6 +35,7 @@ function getStockFilterOptions() { 'DESTROYED': 60, 'LOST': 70 }, + 'description': 'Stock status', } }; } @@ -35,10 +43,10 @@ function getStockFilterOptions() { function loadStockFilters() { // Load the stock table filters from session-storage - var filterstring = inventreeLoad("stockfilters", "cascade=true&loc=1"); + var filterstring = inventreeLoad("stockfilters", "cascade=true"); if (filterstring.length == 0) { - filterstring = 'cascade=true&test=1&location=10&status=50'; + filterstring = 'cascade=true&status=60'; } var split = filterstring.split("&"); @@ -91,9 +99,80 @@ function removeStockFilter(key) { return filters; } +function addStockFilter(key, value) { + var filters = loadStockFilters(); + + filters[key] = value; + + saveStockFilters(filters); + + return filters; +} + function createStockFilter() { // TODO console.log("create stock filter"); + + var html = ``; + + // Add in a (blank) selection for filter value + html += ``; + + html += ``; + + var div = $("#add-new-filter"); + + div.html(html); + + div.find("#filter-make").click(function() { + var tag = div.find("#filter-tag").val(); + var val = div.find("#filter-value").val(); + + console.log(tag + " -> " + val); + + addStockFilter(tag, val); + }); + + div.find('#filter-tag').on('change', function() { + console.log(this.value); + + // Select the filter + var filter = available[this.value]; + + var list = div.find('#filter-value'); + + list.empty(); + + if ('type' in filter) { + if (filter.type == 'bool') { + + list.append(``); + list.append(``); + } + } else if ('options' in filter) { + for (var opt in filter.options) { + + list.append(``); + } + } + + console.log("..."); + }); + + console.log('done'); } function clearStockFilters() { diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index cd0c7a52cf..db40da2d87 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -2,26 +2,31 @@
- {% if read_only %} - {% else %} - -