mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 01:55:47 +00:00
Persist shopping list print settings (closes #2667)
This commit is contained in:
parent
bf353d9622
commit
6a7436dbf0
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
### Shopping list
|
### Shopping list
|
||||||
|
|
||||||
- xxx
|
- The print options (show header, layout type etc.) are now saved (as user settings, so global defaults can also defined in `config.php` as usual)
|
||||||
|
|
||||||
### Recipes
|
### Recipes
|
||||||
|
|
||||||
|
@ -202,6 +202,9 @@ DefaultUserSetting('shopping_list_show_calendar', false); // When enabled, a sma
|
|||||||
DefaultUserSetting('shopping_list_round_up', false); // When enabled, all quantity amounts on the shopping list are always displayed rounded up to the nearest whole number
|
DefaultUserSetting('shopping_list_round_up', false); // When enabled, all quantity amounts on the shopping list are always displayed rounded up to the nearest whole number
|
||||||
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount', false); // If products should be automatically added to the shopping list when they are below their min. stock amount
|
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount', false); // If products should be automatically added to the shopping list when they are below their min. stock amount
|
||||||
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount_list_id', 1); // When the above setting is enabled, the id of the shopping list to which the products will be added
|
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount_list_id', 1); // When the above setting is enabled, the id of the shopping list to which the products will be added
|
||||||
|
DefaultUserSetting('shopping_list_print_show_header', true); // Default for the shopping list print option "Show header"
|
||||||
|
DefaultUserSetting('shopping_list_print_group_by_product_group', true); // Default for the shopping list print option "Group by product group"
|
||||||
|
DefaultUserSetting('shopping_list_print_layout_type', 'table'); // Default for the shopping list print option "Layout type" (table or list)
|
||||||
|
|
||||||
// Recipe settings
|
// Recipe settings
|
||||||
DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group
|
DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group
|
||||||
|
@ -375,12 +375,38 @@ OnListItemRemoved();
|
|||||||
|
|
||||||
$(document).on("click", "#print-shopping-list-button", function(e)
|
$(document).on("click", "#print-shopping-list-button", function(e)
|
||||||
{
|
{
|
||||||
|
var checkedPrintShowHeader = "";
|
||||||
|
if (BoolVal(Grocy.UserSettings.shopping_list_print_show_header))
|
||||||
|
{
|
||||||
|
checkedPrintShowHeader = "checked";
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkedGroupByProductGroup = "";
|
||||||
|
if (BoolVal(Grocy.UserSettings.shopping_list_print_group_by_product_group))
|
||||||
|
{
|
||||||
|
checkedGroupByProductGroup = "checked";
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkedLayoutTypeTable = "";
|
||||||
|
var checkedLayoutTypeList = "";
|
||||||
|
if (Grocy.UserSettings.shopping_list_print_layout_type == "table")
|
||||||
|
{
|
||||||
|
checkedLayoutTypeTable = "checked";
|
||||||
|
checkedLayoutTypeList = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkedLayoutTypeTable = "";
|
||||||
|
checkedLayoutTypeList = "checked";
|
||||||
|
}
|
||||||
|
|
||||||
var dialogHtml = ' \
|
var dialogHtml = ' \
|
||||||
<div class="text-center"><h5>' + __t('Print options') + '</h5><hr></div> \
|
<div class="text-center"><h5>' + __t('Print options') + '</h5><hr></div> \
|
||||||
<div class="custom-control custom-checkbox"> \
|
<div class="custom-control custom-checkbox"> \
|
||||||
<input id="print-show-header" \
|
<input id="print-show-header" \
|
||||||
checked \
|
' + checkedPrintShowHeader + ' \
|
||||||
class="form-check-input custom-control-input" \
|
class="form-check-input custom-control-input user-setting-control" \
|
||||||
|
data-setting-key="shopping_list_print_show_header" \
|
||||||
type="checkbox" \
|
type="checkbox" \
|
||||||
value="1"> \
|
value="1"> \
|
||||||
<label class="form-check-label custom-control-label" \
|
<label class="form-check-label custom-control-label" \
|
||||||
@ -389,8 +415,9 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
|||||||
</div> \
|
</div> \
|
||||||
<div class="custom-control custom-checkbox"> \
|
<div class="custom-control custom-checkbox"> \
|
||||||
<input id="print-group-by-product-group" \
|
<input id="print-group-by-product-group" \
|
||||||
checked \
|
' + checkedGroupByProductGroup + ' \
|
||||||
class="form-check-input custom-control-input" \
|
class="form-check-input custom-control-input user-setting-control" \
|
||||||
|
data-setting-key="shopping_list_print_group_by_product_group" \
|
||||||
type="checkbox" \
|
type="checkbox" \
|
||||||
value="1"> \
|
value="1"> \
|
||||||
<label class="form-check-label custom-control-label" \
|
<label class="form-check-label custom-control-label" \
|
||||||
@ -400,21 +427,24 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
|||||||
<h5 class="pt-3 pb-0">' + __t('Layout type') + '</h5> \
|
<h5 class="pt-3 pb-0">' + __t('Layout type') + '</h5> \
|
||||||
<div class="custom-control custom-radio"> \
|
<div class="custom-control custom-radio"> \
|
||||||
<input id="print-layout-type-table" \
|
<input id="print-layout-type-table" \
|
||||||
checked \
|
' + checkedLayoutTypeTable + ' \
|
||||||
class="custom-control-input" \
|
class="custom-control-input user-setting-control" \
|
||||||
|
data-setting-key="shopping_list_print_layout_type" \
|
||||||
type="radio" \
|
type="radio" \
|
||||||
name="print-layout-type" \
|
name="print-layout-type" \
|
||||||
value="print-layout-type-table"> \
|
value="table"> \
|
||||||
<label class="custom-control-label" \
|
<label class="custom-control-label" \
|
||||||
for="print-layout-type-table">' + __t('Table') + ' \
|
for="print-layout-type-table">' + __t('Table') + ' \
|
||||||
</label> \
|
</label> \
|
||||||
</div> \
|
</div> \
|
||||||
<div class="custom-control custom-radio"> \
|
<div class="custom-control custom-radio"> \
|
||||||
<input id="print-layout-type-list" \
|
<input id="print-layout-type-list" \
|
||||||
class="custom-control-input" \
|
' + checkedLayoutTypeList + ' \
|
||||||
|
class="custom-control-input user-setting-control" \
|
||||||
|
data-setting-key="shopping_list_print_layout_type" \
|
||||||
type="radio" \
|
type="radio" \
|
||||||
name="print-layout-type" \
|
name="print-layout-type" \
|
||||||
value="print-layout-type-list"> \
|
value="list"> \
|
||||||
<label class="custom-control-label" \
|
<label class="custom-control-label" \
|
||||||
for="print-layout-type-list">' + __t('List') + ' \
|
for="print-layout-type-list">' + __t('List') + ' \
|
||||||
</label> \
|
</label> \
|
||||||
@ -442,7 +472,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
|||||||
message: '<p><i class="fa fa-spin fa-spinner"></i> ' + __t('Connecting to printer...') + '</p>'
|
message: '<p><i class="fa fa-spin fa-spinner"></i> ' + __t('Connecting to printer...') + '</p>'
|
||||||
});
|
});
|
||||||
|
|
||||||
//Delaying for one second so that the alert can be closed
|
// 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,
|
Grocy.Api.Get('print/shoppinglist/thermal?list=' + $("#selected-shopping-list").val() + '&printHeader=' + printHeader,
|
||||||
@ -454,17 +484,21 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
|||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
var validResponse = true;
|
var validResponse = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var jsonError = JSON.parse(xhr.responseText);
|
var jsonError = JSON.parse(xhr.responseText);
|
||||||
} catch (e)
|
}
|
||||||
|
catch (e)
|
||||||
{
|
{
|
||||||
validResponse = false;
|
validResponse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validResponse)
|
if (validResponse)
|
||||||
{
|
{
|
||||||
thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print') + '<br><pre><code>' + jsonError.error_message + '</pre></code>');
|
thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print') + '<br><pre><code>' + jsonError.error_message + '</pre></code>');
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print') + '<br><pre><code>' + xhr.responseText + '</pre></code>');
|
thermalPrintDialog.find('.bootbox-body').html(__t('Unable to print') + '<br><pre><code>' + xhr.responseText + '</pre></code>');
|
||||||
}
|
}
|
||||||
@ -500,7 +534,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(".print-layout-container").addClass("d-none");
|
$(".print-layout-container").addClass("d-none");
|
||||||
$("." + $("input[name='print-layout-type']:checked").val()).removeClass("d-none");
|
$(".print-layout-type-" + $("input[name='print-layout-type']:checked").val()).removeClass("d-none");
|
||||||
|
|
||||||
window.print();
|
window.print();
|
||||||
}
|
}
|
||||||
@ -523,19 +557,6 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("change", "input[name='print-layout-type']", function(e)
|
|
||||||
{
|
|
||||||
if (this.value == "print-layout-type-list")
|
|
||||||
{
|
|
||||||
$("#print-group-by-product-group").prop("checked", false);
|
|
||||||
$("#print-group-by-product-group").attr("disabled", "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$("#print-group-by-product-group").removeAttr("disabled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#description").on("summernote.change", function()
|
$("#description").on("summernote.change", function()
|
||||||
{
|
{
|
||||||
$("#save-description-button").removeClass("disabled");
|
$("#save-description-button").removeClass("disabled");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user