mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Always save the recipe edit form when adding, editing or deleting ingredients (fixes #17)
This commit is contained in:
parent
9bedc6a138
commit
c6310d636d
@ -82,6 +82,7 @@ $(document).on('click', '.recipe-pos-delete-button', function(e)
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function() { }, function() { });
|
||||
Grocy.Api.Get('delete-object/recipes_pos/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
@ -112,6 +113,7 @@ $(document).on('click', '.recipe-pos-order-missing-button', function(e)
|
||||
Grocy.Api.Post('add-object/shopping_list', jsonData,
|
||||
function(result)
|
||||
{
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function () { }, function () { });
|
||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
||||
},
|
||||
function(xhr)
|
||||
@ -127,3 +129,33 @@ $(document).on('click', '.recipe-pos-show-note-button', function(e)
|
||||
|
||||
bootbox.alert(note);
|
||||
});
|
||||
|
||||
$(document).on('click', '.recipe-pos-edit-button', function (e)
|
||||
{
|
||||
var recipePosId = $(e.currentTarget).attr('data-recipe-pos-id');
|
||||
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/recipe/' + Grocy.EditObjectId + '/pos/' + recipePosId);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("#recipe-pos-add-button").on("click", function(e)
|
||||
{
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/recipe/' + Grocy.EditObjectId + '/pos/new');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -44,7 +44,7 @@
|
||||
<div class="col-xs-12 col-md-5 pb-3">
|
||||
<h2>
|
||||
{{ $L('Ingredients list') }}
|
||||
<a class="btn btn-outline-dark" href="{{ $U('/recipe/' . $recipe->id . '/pos/new') }}">
|
||||
<a id="recipe-pos-add-button" class="btn btn-outline-dark" href="#">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add') }}
|
||||
</a>
|
||||
</h1>
|
||||
@ -62,7 +62,7 @@
|
||||
@foreach($recipePositions as $recipePosition)
|
||||
<tr class="@if(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled == 1) table-success @elseif(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled_with_shopping_list == 1) table-warning @else table-danger @endif">
|
||||
<td class="fit-content">
|
||||
<a class="btn btn-sm btn-info" href="{{ $U('/recipe/' . $recipe->id . '/pos/' . $recipePosition->id) }}">
|
||||
<a class="btn btn-sm btn-info recipe-pos-edit-button" href="#" data-recipe-pos-id="{{ $recipePosition->id }}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-danger recipe-pos-delete-button" href="#" data-recipe-pos-id="{{ $recipePosition->id }}" data-recipe-pos-name="{{ FindObjectInArrayByPropertyValue($products, 'id', $recipePosition->product_id)->name }}">
|
||||
|
Loading…
x
Reference in New Issue
Block a user