diff --git a/changelog/58_UNRELEASED_2020-xx-xx.md b/changelog/58_UNRELEASED_2020-xx-xx.md index 917421e0..4a0ce2a9 100644 --- a/changelog/58_UNRELEASED_2020-xx-xx.md +++ b/changelog/58_UNRELEASED_2020-xx-xx.md @@ -21,7 +21,8 @@ - Fixed that undoing "product-opened"-actions was not possible - Fixed/improved consuming from the stock overview page for products with enabled tare weight handling ("consume 1" button is now disabled for such products, "consume all" works again) -### Shopping list fixes +### Shopping list improvements/fixes +- It's now possible to collapse/expand the product group sections (by clicking on the grey group header) - Fixed that the "shopping list to stock workflow"-dialog was not visible in compact view - Fixed that when printing the shopping list configured userfields were not included diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 867992eb..243de784 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -1,4 +1,6 @@ -var shoppingListTable = $('#shoppinglist-table').DataTable({ +var collapsedGroups = {}; + +var shoppingListTable = $('#shoppinglist-table').DataTable({ 'order': [[1, 'asc']], "orderFixed": [[3, 'asc']], 'columnDefs': [ @@ -7,12 +9,34 @@ { 'visible': false, 'targets': 3 } ], 'rowGroup': { - dataSrc: 3 + dataSrc: 3, + startRender: function(rows, group) + { + var collapsed = !!collapsedGroups[group]; + var toggleClass = collapsed ? "fa-caret-right" : "fa-caret-down"; + + rows.nodes().each(function(row) + { + row.style.display = collapsed ? "none" : ""; + }); + + return $("