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.
This commit is contained in:
JOKer 2021-11-25 19:08:53 +01:00 committed by GitHub
parent 8876c6cf95
commit b2eec2b111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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");

View File

@ -231,7 +231,7 @@
data-product-id="{{ $stockEntry->product_id }}">
{{ FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->name }}
</td>
<td>
<td data-order="{{ $stockEntry->amount }}">
<span id="stock-{{ $stockEntry->id }}-amount"
class="locale-number locale-number-quantity-amount">{{ $stockEntry->amount }}</span> <span id="product-{{ $stockEntry->product_id }}-qu-name">{{ $__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) }}</span>
<span id="stock-{{ $stockEntry->id }}-opened-amount"