diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 0725c9d1a6..e8a98476db 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -157,6 +157,62 @@ font-style: italic; } +.dropdown { + padding-left: 1px; + margin-left: 1px; +} + +/* Styles for table buttons and filtering */ +.button-toolbar .btn { + margin-left: 1px; + margin-right: 1px; +} + +.filters { + display: inline-block; + *display: inline; + border: 1px solid #555; + border-radius: 3px; + padding: 3px; + margin-bottom: 1px; + margin-top: 1px; + vertical-align: middle; +} + +.filter-list { + margin: 1px; + padding: 1px; +} + +.filter-list .close { + cursor: pointer; + right: 0%; + padding-right: 2px; + padding-left: 2px; + transform: translate(0%, -25%); +} + +.filter-list .close:hover {background: #bbb;} + +.filter-list > li { + display: inline-block; + *display: inline; + zoom: 1; + padding-left: 3px; + padding-right: 3px; + padding-top: 2px; + padding-bottom: 2px; + border: 1px solid; + border-color: #aaa; + border-radius: 3px; + background: #eee; + margin: 1px; +} + +.filter-list > li:hover { + background: #ddd; +} + /* Part image icons with full-display on mouse hover */ .hover-img-thumb { diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 27d720c410..f79a4bf217 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -14,10 +14,33 @@ function getStockLocations(filters={}, options={}) { return inventreeGet('/api/stock/location/', filters, options) } +// A map of available filters for the stock table +function getStockFilterOptions() { + return { + 'cascade': { + 'type': 'bool', + }, + 'status': { + 'options': { + 'OK': 10, + 'ATTENTION': 50, + 'DAMAGED': 55, + 'DESTROYED': 60, + 'LOST': 70 + }, + } + }; +} + + function loadStockFilters() { // Load the stock table filters from session-storage var filterstring = inventreeLoad("stockfilters", "cascade=true&loc=1"); + if (filterstring.length == 0) { + filterstring = 'cascade=true&test=1&location=10&status=50'; + } + var split = filterstring.split("&"); var filters = {}; @@ -25,12 +48,15 @@ function loadStockFilters() { console.log("Loaded stock filters: " + filterstring); split.forEach(function(item, index) { - var f = item.split('='); - if (f.length == 2) { - filters[f[0]] = f[1]; - } else { - console.log("Improperly formatted filter: " + item); + if (item.length > 0) { + var f = item.split('='); + + if (f.length == 2) { + filters[f[0]] = f[1]; + } else { + console.log("Improperly formatted filter: " + item); + } } }); @@ -54,6 +80,41 @@ function saveStockFilters(filters) { inventreeSave("stockfilters", filterstring); } +function removeStockFilter(key) { + + var filters = loadStockFilters(); + + delete filters[key]; + + saveStockFilters(filters); + + return filters; +} + + +function updateStockFilterList(filterListElement, filters, table, params) { + + for (var key in filters) { + $(filterListElement).append(`