diff --git a/changelog/60_3.0.0_2020-12-22.md b/changelog/60_3.0.0_2020-12-22.md index 3d869f89..c2848dad 100644 --- a/changelog/60_3.0.0_2020-12-22.md +++ b/changelog/60_3.0.0_2020-12-22.md @@ -92,6 +92,7 @@ - Added a button to add all currently in-stock but overdue and expired products to the shopping list (thanks @m-byte) - Improved that when `FEATURE_FLAG_STOCK` is disabled, all product/stock related inputs and buttons are now hidden on the shopping list page (thanks @fipwmaqzufheoxq92ebc) - Shopping list items can now have their own Userfields (entity `shopping_list`), on the shopping list table those fields are rendered additionally to the product Userfields +- Made the print view configurable (new dialog before printing - option to hide header, group products by their product group, alternative list layout) - Fixed that "Add products that are below defined min. stock amount" always rounded up the missing amount to an integral number, this now allows decimal numbers ### Recipe improvements/fixes diff --git a/localization/strings.pot b/localization/strings.pot index 63a04920..0edf78dc 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1537,9 +1537,6 @@ msgstr "" msgid "per day" msgstr "" -msgid "Normal view" -msgstr "" - msgid "Only undone items" msgstr "" @@ -2035,3 +2032,15 @@ msgstr "" msgid "Last price (Total)" msgstr "" + +msgid "Show header" +msgstr "" + +msgid "Group by product group" +msgstr "" + +msgid "Table" +msgstr "" + +msgid "Layout type" +msgstr "" diff --git a/public/js/grocy.js b/public/js/grocy.js index fdb5ffc9..71e76528 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -813,7 +813,7 @@ $.extend(true, $.fn.dataTable.defaults, { }); return $("") - .append('' + group + ' ') + .append('' + group + ' ') .attr("data-name", group) .toggleClass("collapsed", collapsed); } diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 85552474..4bba444b 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -19,6 +19,20 @@ $('#shoppinglist-table tbody').removeClass("d-none"); shoppingListTable.columns.adjust().draw(); +var shoppingListPrintShadowTable = $('#shopping-list-print-shadow-table').DataTable({ + 'order': [[1, 'asc']], + "orderFixed": [[2, 'asc']], + 'columnDefs': [ + { 'visible': false, 'targets': 2 }, + { 'orderable': false, 'targets': '_all' } + ].concat($.fn.dataTable.defaults.columnDefs), + 'rowGroup': { + enable: true, + dataSrc: 2 + } +}); +shoppingListPrintShadowTable.columns.adjust().draw(); + $("#search").on("keyup", Delay(function() { var value = $(this).val(); @@ -367,9 +381,99 @@ OnListItemRemoved(); $(document).on("click", "#print-shopping-list-button", function(e) { - $(".print-timestamp").text(moment().format("l LT")); - $("#description-for-print").html($("#description").val()); - window.print(); + var dialogHtml = ' \ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
' + __t('Layout type') + '
\ +
\ + \ + \ +
\ +
\ + \ + \ +
'; + + bootbox.dialog({ + message: dialogHtml, + size: 'small', + backdrop: true, + closeButton: false, + className: "d-print-none", + buttons: { + cancel: { + label: __t('Cancel'), + className: 'btn-secondary', + callback: function() + { + bootbox.hideAll(); + } + }, + ok: { + label: __t('Print'), + className: 'btn-primary responsive-button', + callback: function() + { + bootbox.hideAll(); + + $(".print-timestamp").text(moment().format("l LT")); + + $("#description-for-print").html($("#description").val()); + if ($("#description").text().isEmpty()) + { + $("#description-for-print").parent().addClass("d-print-none"); + } + + if (!$("#print-show-header").prop("checked")) + { + $("#print-header").addClass("d-none"); + } + + if (!$("#print-group-by-product-group").prop("checked")) + { + shoppingListPrintShadowTable.rowGroup().enable(false); + shoppingListPrintShadowTable.order.fixed({}); + shoppingListPrintShadowTable.draw(); + } + + $("." + $("input[name='print-layout-type']:checked").val()).removeClass("d-none"); + + window.print(); + } + } + } + }); }); $("#description").on("summernote.change", function() diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index f5b2abc6..da8d7998 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -147,11 +147,6 @@
- - {{ $__t('Normal view') }} - @@ -312,28 +307,33 @@
-

+

- @if (FindObjectInArrayByPropertyValue($shoppingLists, 'id', $selectedShoppingListId)->name != $__t("Shopping list")) -

- {{ FindObjectInArrayByPropertyValue($shoppingLists, 'id', $selectedShoppingListId)->name }} -

- @endif -
- {{ $__t('Time of printing') }}: - -
-
-
-
+ + @if (FindObjectInArrayByPropertyValue($shoppingLists, 'id', $selectedShoppingListId)->name != $__t("Shopping list")) +

+ {{ FindObjectInArrayByPropertyValue($shoppingLists, 'id', $selectedShoppingListId)->name }} +

+ @endif +
+ {{ $__t('Time of printing') }}: + +
+ +
+ @include('components.userfields_thead', array( 'userfields' => $userfields @@ -350,6 +350,9 @@ + @include('components.userfields_tbody', array( 'userfields' => $userfields, @@ -362,8 +365,16 @@
{{ $__t('Product') }} / {{ $__t('Note') }} {{ $__t('Amount') }}{{ $__t('Product group') }} {{ $listItem->amount }} @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural) }}@endif + @if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else {{ $__t('Ungrouped') }} @endif +
-
-
+ +
+
{{ $__t('Notes') }}