From 11ea8f3716b84f23726338d442d4acfef67f7cef Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 8 Nov 2024 16:40:30 +0100 Subject: [PATCH] Fixed shopping list print view table/list sorting (fixes #2602) --- changelog/76_UNRELEASED_xxxx-xx-xx.md | 2 +- controllers/StockController.php | 2 +- public/viewjs/shoppinglist.js | 4 +--- views/shoppinglist.blade.php | 9 +++++++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/changelog/76_UNRELEASED_xxxx-xx-xx.md b/changelog/76_UNRELEASED_xxxx-xx-xx.md index 722c405e..bb23e119 100644 --- a/changelog/76_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/76_UNRELEASED_xxxx-xx-xx.md @@ -22,7 +22,7 @@ ### Shopping list -- xxx +- Fixed that when printing a shoppping list the table/list wasn't sorted (will now be sorted alphabetically by the product name of the corresponding list item) ### Recipes diff --git a/controllers/StockController.php b/controllers/StockController.php index fecd6e80..e434c37e 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -393,7 +393,7 @@ class StockController extends BaseController } return $this->renderPage($response, 'shoppinglist', [ - 'listItems' => $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId), + 'listItems' => $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId)->orderBy('product_name', 'COLLATE NOCASE'), 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'missingProducts' => $this->getStockService()->GetMissingProducts(), diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 96912269..83661191 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -22,8 +22,7 @@ $('#shoppinglist-table tbody').removeClass("d-none"); shoppingListTable.columns.adjust().draw(); var shoppingListPrintShadowTable = $('#shopping-list-print-shadow-table').DataTable({ - 'order': [[1, 'asc']], - "orderFixed": [[2, 'asc']], + "orderFixed": [[0, 'asc'], [2, 'asc']], 'columnDefs': [ { 'visible': false, 'targets': 2 }, { 'orderable': false, 'targets': '_all' } @@ -500,7 +499,6 @@ $(document).on("click", "#print-shopping-list-button", function(e) if (!$("#print-group-by-product-group").prop("checked")) { shoppingListPrintShadowTable.rowGroup().enable(false); - shoppingListPrintShadowTable.order.fixed({}); shoppingListPrintShadowTable.draw(); } diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index cadc1b9c..6dc31bed 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -4,6 +4,15 @@ @section('title', $__t('Shopping list')) +@push('pageStyles') + +@endpush + @push('pageScripts') @endpush