mirror of
https://github.com/grocy/grocy.git
synced 2025-04-28 17:23:56 +00:00
Finalize recipes feature
This commit is contained in:
parent
be650d093d
commit
ea0f5101ec
@ -16,10 +16,22 @@ class RecipesController extends BaseController
|
||||
|
||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$selectedRecipe = null;
|
||||
$selectedRecipePositions = null;
|
||||
if (isset($request->getQueryParams()['recipe']))
|
||||
{
|
||||
$selectedRecipe = $this->Database->recipes($request->getQueryParams()['recipe']);
|
||||
$selectedRecipePositions = $this->Database->recipes_pos()->where('recipe_id', $request->getQueryParams()['recipe']);
|
||||
}
|
||||
|
||||
return $this->AppContainer->view->render($response, 'recipes', [
|
||||
'recipes' => $this->Database->recipes()->orderBy('name'),
|
||||
'recipesFulfillment' => $this->RecipesService->GetRecipesFulfillment(),
|
||||
'recipesSumFulfillment' => $this->RecipesService->GetRecipesSumFulfillment()
|
||||
'recipesSumFulfillment' => $this->RecipesService->GetRecipesSumFulfillment(),
|
||||
'selectedRecipe' => $selectedRecipe,
|
||||
'selectedRecipePositions' => $selectedRecipePositions,
|
||||
'products' => $this->Database->products(),
|
||||
'quantityunits' => $this->Database->quantity_units()
|
||||
]);
|
||||
}
|
||||
|
||||
@ -40,8 +52,8 @@ class RecipesController extends BaseController
|
||||
'recipe' => $this->Database->recipes($recipeId),
|
||||
'recipePositions' => $this->Database->recipes_pos()->where('recipe_id', $recipeId),
|
||||
'mode' => 'edit',
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'products' => $this->Database->products(),
|
||||
'quantityunits' => $this->Database->quantity_units(),
|
||||
'recipesFulfillment' => $this->RecipesService->GetRecipesFulfillment(),
|
||||
'recipesSumFulfillment' => $this->RecipesService->GetRecipesSumFulfillment()
|
||||
]);
|
||||
@ -54,7 +66,7 @@ class RecipesController extends BaseController
|
||||
return $this->AppContainer->view->render($response, 'recipeposform', [
|
||||
'mode' => 'create',
|
||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
||||
'products' => $this->Database->products()
|
||||
'products' => $this->Database->products()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
else
|
||||
@ -63,7 +75,7 @@ class RecipesController extends BaseController
|
||||
'mode' => 'edit',
|
||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
||||
'recipePos' => $this->Database->recipes_pos($args['recipePosId']),
|
||||
'products' => $this->Database->products()
|
||||
'products' => $this->Database->products()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@
|
||||
"bootstrap-side-navbar": "https://github.com/samrayner/bootstrap-side-navbar.git#1.0.1",
|
||||
"datatables.net": "^1.10.19",
|
||||
"datatables.net-bs4": "^1.10.19",
|
||||
"datatables.net-responsive": "^2.2.3",
|
||||
"datatables.net-responsive-bs4": "^2.2.3",
|
||||
"datatables.net-colreorder": "^1.5.1",
|
||||
"datatables.net-colreorder-bs4": "^1.5.1",
|
||||
"datatables.net-responsive": "^2.2.3",
|
||||
"datatables.net-responsive-bs4": "^2.2.3",
|
||||
"datatables.net-select": "^1.2.7",
|
||||
"datatables.net-select-bs4": "^1.2.7",
|
||||
"jquery": "^3.3.1",
|
||||
|
@ -49,6 +49,15 @@ a.discrete-link:focus {
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
.fullscreen {
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
/* Navigation style customizations */
|
||||
#mainNav {
|
||||
background-color: #e5e5e5 !important;
|
||||
|
@ -120,3 +120,10 @@ $(document).on('click', '.recipe-pos-order-missing-button', function(e)
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$(document).on('click', '.recipe-pos-show-note-button', function(e)
|
||||
{
|
||||
var note = $(e.currentTarget).attr('data-recipe-pos-note');
|
||||
|
||||
bootbox.alert(note);
|
||||
});
|
||||
|
@ -11,6 +11,12 @@
|
||||
'select': 'single'
|
||||
});
|
||||
|
||||
var rowSelect = GetUriParam("row");
|
||||
if (typeof rowSelect !== "undefined")
|
||||
{
|
||||
recipesTables.row(rowSelect).select();
|
||||
}
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
@ -93,3 +99,17 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
recipesTables.on('select', function(e, dt, type, indexes)
|
||||
{
|
||||
if (type === 'row')
|
||||
{
|
||||
var selectedRecipeId = $(recipesTables.row(indexes[0]).node()).data("recipe-id");
|
||||
window.location.href = U('/recipes?recipe=' + selectedRecipeId.toString() + "&row=" + indexes[0].toString());
|
||||
}
|
||||
});
|
||||
|
||||
$("#selectedRecipeToggleFullscreenButton").on('click', function(e)
|
||||
{
|
||||
$("#selectedRecipeCard").toggleClass("fullscreen");
|
||||
});
|
||||
|
@ -70,9 +70,15 @@
|
||||
<span class="nav-link-text">{{ $L('Batteries overview') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Shopping list') }}" data-nav-for-page="shoppinglist">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/shoppinglist') }}">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<span class="nav-link-text">{{ $L('Shopping list') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Recipes') }}" data-nav-for-page="recipes">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/recipes') }}">
|
||||
<i class="fas fa-lemon"></i>
|
||||
<i class="fas fa-cocktail"></i>
|
||||
<span class="nav-link-text">{{ $L('Recipes') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
@ -89,12 +95,6 @@
|
||||
<span class="nav-link-text">{{ $L('Consume') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Shopping list') }}" data-nav-for-page="shoppinglist">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/shoppinglist') }}">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<span class="nav-link-text">{{ $L('Shopping list') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Inventory') }}" data-nav-for-page="inventory">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/inventory') }}">
|
||||
<i class="fas fa-list"></i>
|
||||
|
@ -22,7 +22,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4 pb-3">
|
||||
<div class="col-xs-12 col-md-7 pb-3">
|
||||
<form id="recipe-form" novalidate>
|
||||
|
||||
<div class="form-group">
|
||||
@ -41,7 +41,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-8 pb-3">
|
||||
<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') }}">
|
||||
@ -69,7 +69,7 @@
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-primary recipe-pos-order-missing-button @if(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled_with_shopping_list == 1){{ disabled }}@endif" href="#" title="{{ $L('Order missing amount') }}" data-recipe-name="{{ $recipe->name }}" data-product-id="{{ $recipePosition->product_id }}" data-product-amount="{{ FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->missing_amount }}" data-product-name="{{ FindObjectInArrayByPropertyValue($products, 'id', $recipePosition->product_id)->name }}">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<i class="fas fa-cart-plus"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
@ -79,12 +79,10 @@
|
||||
{{ $recipePosition->amount }} {{ FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $recipePosition->product_id)->qu_id_stock)->name }}
|
||||
<span class="timeago-contextual">@if(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled == 1) {{ $L('Enough in stock') }} @else {{ $L('Not enough in stock, #1 missing, #2 already on shopping list', FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->missing_amount, FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->amount_on_shopping_list) }} @endif</span>
|
||||
</td>
|
||||
<td>
|
||||
@if(strlen($recipePosition->note) > 50)
|
||||
{{ substr($recipePosition->note, 0, 50) }}...
|
||||
@else
|
||||
{{ $recipePosition->note }}
|
||||
@endif
|
||||
<td class="fit-content">
|
||||
<a class="btn btn-sm btn-info recipe-pos-show-note-button @if(empty($recipePosition->note)) disabled @endif" href="#" title="{{ $L('Show notes') }}" data-recipe-pos-note="{{ $recipePosition->note }}">
|
||||
<i class="fas fa-eye"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
@ -16,15 +16,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-xs-12 col-md-6 col-xl-3">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 pb-3">
|
||||
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
|
||||
<input type="text" class="form-control" id="search">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<table id="recipes-table" class="table table-sm table-striped dt-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -35,7 +31,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($recipes as $recipe)
|
||||
<tr>
|
||||
<tr data-recipe-id="{{ $recipe->id }}">
|
||||
<td class="fit-content">
|
||||
<a class="btn btn-sm btn-info" href="{{ $U('/recipe/') }}{{ $recipe->id }}">
|
||||
<i class="fas fa-edit"></i>
|
||||
@ -44,20 +40,48 @@
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-primary recipe-order-missing-button @if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1){{ disabled }}@endif" href="#" title="{{ $L('Order missing products') }}" data-recipe-id="{{ $recipe->id }}" data-recipe-name="{{ $recipe->name }}">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<i class="fas fa-cart-plus"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ $recipe->name }}
|
||||
</td>
|
||||
<td>
|
||||
@if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1){{ $L('Yes') }}@else{{ $L('No') }}@endif
|
||||
<span class="timeago-contextual">@if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1) {{ $L('Enough in stock') }} @else {{ $L('Not enough in stock, #1 ingredients missing', FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->missing_products_count) }} @endif</span>
|
||||
@if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1)<i class="fas fa-check text-success"></i>@elseif(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1)<i class="fas fa-exclamation text-warning"></i>@else<i class="fas fa-times text-danger"></i>@endif
|
||||
<span class="timeago-contextual">@if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1){{ $L('Enough in stock') }}@elseif(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1){{ $L('Not enough in stock, #1 ingredients missing but already on the shopping list', FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->missing_products_count) }}@else{{ $L('Not enough in stock, #1 ingredients missing', FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->missing_products_count) }}@endif</span>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if($selectedRecipe !== null)
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div id="selectedRecipeCard" class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-cocktail"></i> {{ $selectedRecipe->name }}
|
||||
<a id="selectedRecipeToggleFullscreenButton" class="btn btn-sm btn-outline-secondary py-0 float-right" href="#" title="{{ $L('Expand to fullscreen') }}">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="mb-0">{{ $L('Ingredients') }}</h5>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
@foreach($selectedRecipePositions as $selectedRecipePosition)
|
||||
<li class="list-group-item">
|
||||
{{ $selectedRecipePosition->amount }} {{ FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $selectedRecipePosition->product_id)->qu_id_stock)->name }} {{ FindObjectInArrayByPropertyValue($products, 'id', $selectedRecipePosition->product_id)->name }}
|
||||
<span class="timeago-contextual">@if(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $selectedRecipePosition->id)->need_fulfilled == 1) {{ $L('Enough in stock') }} @else {{ $L('Not enough in stock, #1 missing, #2 already on shopping list', FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $selectedRecipePosition->id)->missing_amount, FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $selectedRecipePosition->id)->amount_on_shopping_list) }} @endif</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<div class="card-body">
|
||||
<h5>{{ $L('Preparation') }}</h5>
|
||||
{!! nl2br(htmlentities($selectedRecipe->description)) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@stop
|
||||
|
10
yarn.lock
10
yarn.lock
@ -10,7 +10,7 @@
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.1.0.tgz#f35f5ba91366b7a58b0b6a4f22ff0907fe002219"
|
||||
|
||||
"TagManager@https://github.com/max-favilli/tagmanager.git#3.0.2", "tagmanager@https://github.com/max-favilli/tagmanager.git#3.0.2":
|
||||
"TagManager@https://github.com/max-favilli/tagmanager.git#3.0.2":
|
||||
version "3.0.1"
|
||||
resolved "https://github.com/max-favilli/tagmanager.git#df9eb9935c8585a392dfc00602f890caf233fa94"
|
||||
dependencies:
|
||||
@ -29,8 +29,8 @@ bootstrap@4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.0.0.tgz#ceb03842c145fcc1b9b4e15da2a05656ba68469a"
|
||||
|
||||
bootstrap@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.1.1.tgz#3aec85000fa619085da8d2e4983dfd67cf2114cb"
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.1.2.tgz#aee2a93472e61c471fc79fb475531dcbc87de326"
|
||||
|
||||
chart.js@2.7.1:
|
||||
version "2.7.1"
|
||||
@ -185,8 +185,8 @@ startbootstrap-sb-admin@^4.0.0:
|
||||
jquery.easing "^1.4.1"
|
||||
|
||||
swagger-ui-dist@^3.17.3:
|
||||
version "3.17.3"
|
||||
resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.17.3.tgz#dfb96408ccc46775155f7369190c5d4b2016fe5c"
|
||||
version "3.17.4"
|
||||
resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.17.4.tgz#7b4d3842b052cbadebec784265b2e17fdda6a232"
|
||||
|
||||
tempusdominus-bootstrap-4@^5.0.1:
|
||||
version "5.0.1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user