diff --git a/public/js/grocy.js b/public/js/grocy.js index db4ebbd1..6e3af619 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -895,6 +895,18 @@ $(document).on("click", "tr.dtrg-group", function() collapsedGroups[name] = !collapsedGroups[name]; $("table").DataTable().draw(); }); +$.fn.dataTable.ext.type.order["custom-sort-pre"] = function(data) +{ + // Workaround for https://github.com/DataTables/ColReorder/issues/85 + // + // Custom sorting can normally be provided by a "data-order" attribute on the element, + // however this causes issues when reordering such a column... + // + // This here is for a custom column type "custom-sort", + // the custom order value needs to be provided in the first child () of the + + return (parseFloat($(data).get(0).innerText)); +}; // serializeJSON defaults $.serializeJSON.defaultOptions.checkboxUncheckedValue = "0"; diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index d9d44d40..762898bb 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -9,7 +9,7 @@ var shoppingListTable = $('#shoppinglist-table').DataTable({ { 'visible': false, 'targets': 6 }, { 'visible': false, 'targets': 7 }, { 'visible': false, 'targets': 8 }, - { "type": "num", "targets": 2 }, + { "type": "custom-sort", "targets": 2 }, { "type": "html-num-fmt", "targets": 5 }, { "type": "html-num-fmt", "targets": 6 } ].concat($.fn.dataTable.defaults.columnDefs), diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js index b233324a..b47aee5e 100644 --- a/public/viewjs/stockentries.js +++ b/public/viewjs/stockentries.js @@ -5,9 +5,9 @@ { 'searchable': false, "targets": 0 }, { 'visible': false, 'targets': 10 }, { "type": "num", "targets": 1 }, - { "type": "num", "targets": 3 }, + { "type": "custom-sort", "targets": 3 }, { "type": "html", "targets": 4 }, - { "type": "html-num-fmt", "targets": 7 }, + { "type": "custom-sort", "targets": 7 }, { "type": "html", "targets": 8 }, { "type": "html", "targets": 9 } ].concat($.fn.dataTable.defaults.columnDefs) diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index e8fac8b9..82603122 100755 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -1,4 +1,6 @@ -var stockOverviewTable = $('#stock-overview-table').DataTable({ + + +var stockOverviewTable = $('#stock-overview-table').DataTable({ 'order': [[5, 'asc']], 'columnDefs': [ { 'orderable': false, 'targets': 0 }, @@ -19,15 +21,15 @@ { 'visible': false, 'targets': 16 }, { 'visible': false, 'targets': 17 }, { 'visible': false, 'targets': 18 }, - { "type": "num", "targets": 3 }, + { "type": "custom-sort", "targets": 3 }, { "type": "html-num-fmt", "targets": 9 }, { "type": "html-num-fmt", "targets": 10 }, { "type": "html", "targets": 5 }, { "type": "html", "targets": 11 }, - { "type": "html-num-fmt", "targets": 12 }, + { "type": "custom-sort", "targets": 12 }, { "type": "num", "targets": 13 }, { "type": "html-num-fmt", "targets": 4 }, - { "type": "html-num-fmt", "targets": 18 } + { "type": "custom-sort", "targets": 18 } ].concat($.fn.dataTable.defaults.columnDefs) }); diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index 931d3c79..c371e470 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -243,8 +243,8 @@ } @endphp @endif - amount }}> + + {{$listItem->amount}} {{ $listItem->amount }} @if(!empty($listItem->product_id)){{ $__n($listItem->amount, $listItem->qu_name, $listItem->qu_name_plural, true) }}@endif diff --git a/views/stockentries.blade.php b/views/stockentries.blade.php index 06b2d4f3..43645645 100644 --- a/views/stockentries.blade.php +++ b/views/stockentries.blade.php @@ -255,7 +255,8 @@ data-product-id="{{ $stockEntry->product_id }}"> {{ FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->name }} - + + {{$stockEntry->amount}} {{ $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, true) }} shopping_location_id)->name }} @endif - + + {{$stockEntry->price}} @if($currentStockEntry->product_group_name !== null){{ $currentStockEntry->product_group_name }}@endif - + + @if($currentStockEntry->product_no_own_stock == 1){{ $currentStockEntry->amount_aggregated }}@else{{ $currentStockEntry->amount }}@endif {{ $currentStockEntry->amount }} {{ $__n($currentStockEntry->amount, $currentStockEntry->qu_unit_name, $currentStockEntry->qu_unit_name_plural) }} @@ -400,8 +401,8 @@ - + + {{$currentStockEntry->last_price}} @if(!empty($currentStockEntry->last_price)) @endif - + + {{$currentStockEntry->average_price}} @if(!empty($currentStockEntry->average_price))