From b2eec2b111def5b16dac965a7eb5428d6edd8cd2 Mon Sep 17 00:00:00 2001 From: JOKer Date: Thu, 25 Nov 2021 19:08:53 +0100 Subject: [PATCH] Improve sorting for stock entries view (#1695) In the stockentries view the ordering by expiration date, amount, price and purchase date did not work as expected. b5fc64cf already addressed a similar issue for other views. This commit now does the same: set DataTables types on the specific columns. Since the units being part of the "amount" column break numeric sorting, this commit adds a "data-order" field for that column, so numeric sorting can still work. This is done in aligment with the stockoverview page, that already contains such an entry to facilitate proper sorting. --- public/viewjs/stockentries.js | 8 +++++++- views/stockentries.blade.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js index 7f190e99..4b3fdd6f 100644 --- a/public/viewjs/stockentries.js +++ b/public/viewjs/stockentries.js @@ -3,7 +3,13 @@ 'columnDefs': [ { 'orderable': false, 'targets': 0 }, { 'searchable': false, "targets": 0 }, - { 'visible': false, 'targets': 10 } + { 'visible': false, 'targets': 10 }, + { "type": "num", "targets": 1}, + { "type": "num", "targets": 3 }, + { "type": "html", "targets": 4 }, + { "type": "html-num-fmt", "targets": 7}, + { "type": "html", "targets": 8}, + { "type": "html", "targets": 9} ].concat($.fn.dataTable.defaults.columnDefs) }); $('#stockentries-table tbody').removeClass("d-none"); diff --git a/views/stockentries.blade.php b/views/stockentries.blade.php index ea944465..6762b09d 100644 --- a/views/stockentries.blade.php +++ b/views/stockentries.blade.php @@ -231,7 +231,7 @@ data-product-id="{{ $stockEntry->product_id }}"> {{ FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->name }} - + {{ $stockEntry->amount }} {{ $__n($stockEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name_plural) }}