diff --git a/config-dist.php b/config-dist.php index 343d6e08..35f869e4 100644 --- a/config-dist.php +++ b/config-dist.php @@ -198,7 +198,7 @@ Setting('FEATURE_FLAG_STOCK_PRODUCT_FREEZING', true); Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_FIELD_NUMBER_PAD', true); // Activate the number pad in due date fields on (supported) mobile browsers Setting('FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS', true); Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', true); -Setting('FEATURE_FLAG_THERMAL_PRINTER', true); +Setting('FEATURE_FLAG_THERMAL_PRINTER', false); // Feature settings Setting('FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT', true); // When set to true, opened items will be counted as missing for calculating if a product is below its minimum stock amount diff --git a/localization/strings.pot b/localization/strings.pot index 6ce941ba..59608c71 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2077,3 +2077,15 @@ msgstr "" msgid "A product or a note is required" msgstr "" + +msgid "Thermal printer" +msgstr "" + +msgid "Printing" +msgstr "" + +msgid "Connecting to printer..." +msgstr "" + +msgid "Unable to print" +msgstr "" diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 4cb2c093..bc472167 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -433,14 +433,16 @@ $(document).on("click", "#print-shopping-list-button", function(e) cancel: { label: __t('Cancel'), className: 'btn-secondary', - callback: function () { + callback: function() + { bootbox.hideAll(); } }, printtp: { label: __t('Thermal printer'), className: 'btn-secondary', - callback: function () { + callback: function() + { bootbox.hideAll(); var printHeader = $("#print-show-header").prop("checked"); var thermalPrintDialog = bootbox.dialog({ @@ -448,14 +450,14 @@ $(document).on("click", "#print-shopping-list-button", function(e) message: '

' + __t('Connecting to printer...') + '

' }); //Delaying for one second so that the alert can be closed - setTimeout(function () + setTimeout(function() { Grocy.Api.Get('print/shoppinglist/thermal?list=' + $("#selected-shopping-list").val() + '&printHeader=' + printHeader, - function (result) + function(result) { bootbox.hideAll(); }, - function (xhr) + function(xhr) { console.error(xhr); var validResponse = true; @@ -468,9 +470,10 @@ $(document).on("click", "#print-shopping-list-button", function(e) } if (validResponse) { - thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print: ') + jsonError.error_message); - } else { - thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print: ') + xhr.responseText); + thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print') + '
' + jsonError.error_message + '
'); + } else + { + thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print') + '
' + xhr.responseText + '
'); } } ); @@ -480,29 +483,32 @@ $(document).on("click", "#print-shopping-list-button", function(e) ok: { label: __t('Print'), className: 'btn-primary responsive-button', - callback: function () + callback: function() { bootbox.hideAll(); $('.modal-backdrop').remove(); $(".print-timestamp").text(moment().format("l LT")); $("#description-for-print").html($("#description").val()); - if ($("#description").text().isEmpty()) { + if ($("#description").text().isEmpty()) + { $("#description-for-print").parent().addClass("d-print-none"); } - if (!$("#print-show-header").prop("checked")) { + if (!$("#print-show-header").prop("checked")) + { $("#print-header").addClass("d-none"); } - if (!$("#print-group-by-product-group").prop("checked")) { + if (!$("#print-group-by-product-group").prop("checked")) + { shoppingListPrintShadowTable.rowGroup().enable(false); shoppingListPrintShadowTable.order.fixed({}); shoppingListPrintShadowTable.draw(); } - $(".print-layout-container").addClass("d-none"); - $("." + $("input[name='print-layout-type']:checked").val()).removeClass("d-none"); + $(".print-layout-container").addClass("d-none"); + $("." + $("input[name='print-layout-type']:checked").val()).removeClass("d-none"); window.print(); }