Add a button to clear the whole shopping list

This commit is contained in:
Bernd Bestel
2018-07-15 08:29:26 +02:00
parent 734814d96b
commit be650d093d
8 changed files with 75 additions and 4 deletions

View File

@@ -48,3 +48,36 @@ $(document).on('click', '#add-products-below-min-stock-amount', function(e)
}
);
});
$(document).on('click', '#clear-shopping-list', function(e)
{
bootbox.confirm({
message: L('Are you sure to empty the shopping list?'),
buttons: {
confirm: {
label: L('Yes'),
className: 'btn-success'
},
cancel: {
label: L('No'),
className: 'btn-danger'
}
},
callback: function(result)
{
if (result === true)
{
Grocy.Api.Get('stock/clear-shopping-list',
function(result)
{
window.location.href = U('/shoppinglist');
},
function(xhr)
{
console.error(xhr);
}
);
}
}
});
});

View File

@@ -43,6 +43,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
$('#amount').focus();
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
},
function(xhr)
{