mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Add a button to clear the whole shopping list
This commit is contained in:
parent
734814d96b
commit
be650d093d
@ -106,6 +106,12 @@ class StockApiController extends BaseApiController
|
||||
return $this->VoidApiActionResponse($response);
|
||||
}
|
||||
|
||||
public function ClearShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$this->StockService->ClearShoppingList();
|
||||
return $this->VoidApiActionResponse($response);
|
||||
}
|
||||
|
||||
public function ExternalBarcodeLookup(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
|
@ -650,6 +650,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/clear-shopping-list": {
|
||||
"get": {
|
||||
"description": "Removes all items from the shopping list",
|
||||
"tags": [
|
||||
"Stock"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/external-barcode-lookup/{barcode}": {
|
||||
"get": {
|
||||
"description": "Executes an external barcode lookoup via the configured plugin with the given barcode",
|
||||
|
@ -153,6 +153,8 @@ return array(
|
||||
'Edit recipe ingredient' => 'Rezeptzutat bearbeiten',
|
||||
'Are you sure to delete recipe "#1"?' => 'Rezept "#1" wirklich löschen?',
|
||||
'Are you sure to delete recipe ingredient "#1"?' => 'Rezeptzutat "#1" wirklich löschen?',
|
||||
'Are you sure to empty the shopping list?' => 'Sicher, dass die Einkaufsliste geleert werden soll?',
|
||||
'Clear list' => 'Liste leeren',
|
||||
|
||||
//Constants
|
||||
'manually' => 'Manuell',
|
||||
|
@ -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);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -75,6 +75,7 @@ $app->group('/api', function()
|
||||
$this->get('/stock/get-product-details/{productId}', 'Grocy\Controllers\StockApiController:ProductDetails');
|
||||
$this->get('/stock/get-current-stock', 'Grocy\Controllers\StockApiController:CurrentStock');
|
||||
$this->get('/stock/add-missing-products-to-shoppinglist', 'Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList');
|
||||
$this->get('/stock/clear-shopping-list', 'Grocy\Controllers\StockApiController:ClearShoppingList');
|
||||
$this->get('/stock/external-barcode-lookup/{barcode}', 'Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
||||
|
||||
$this->get('/recipes/add-not-fulfilled-products-to-shopping-list/{recipeId}', 'Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList');
|
||||
|
@ -203,6 +203,11 @@ class StockService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
public function ClearShoppingList()
|
||||
{
|
||||
$this->Database->shopping_list()->delete();
|
||||
}
|
||||
|
||||
private function ProductExists($productId)
|
||||
{
|
||||
$productRow = $this->Database->products()->where('id = :1', $productId)->fetch();
|
||||
|
@ -9,11 +9,14 @@
|
||||
<div class="col">
|
||||
<h1>
|
||||
@yield('title')
|
||||
<a class="btn btn-outline-dark" href="{{ $U('/shoppinglistitem/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add') }}
|
||||
<a class="btn btn-outline-dark responsive-button" href="{{ $U('/shoppinglistitem/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add') }}
|
||||
</a>
|
||||
<a id="add-products-below-min-stock-amount" class="btn btn-outline-primary" href="#">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add products that are below defined min. stock amount') }}
|
||||
<a id="clear-shopping-list" class="btn btn-outline-danger responsive-button @if($listItems->count() == 0) disabled @endif" href="#">
|
||||
<i class="fas fa-trash"></i> {{ $L('Clear list') }}
|
||||
</a>
|
||||
<a id="add-products-below-min-stock-amount" class="btn btn-outline-primary responsive-button" href="#">
|
||||
<i class="fas fa-cart-plus"></i> {{ $L('Add products that are below defined min. stock amount') }}
|
||||
</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user