Make it possible to add pictures to recipes (closes #136)

This commit is contained in:
Bernd Bestel
2019-01-26 20:06:01 +01:00
parent 03720940d4
commit ad09630dbe
4 changed files with 86 additions and 1 deletions

View File

@@ -29,6 +29,10 @@
@if($mode == 'edit')
<script>Grocy.EditObjectId = {{ $recipe->id }};</script>
@if(!empty($recipe->picture_file_name))
<script>Grocy.RecipePictureFileName = '{{ $recipe->picture_file_name }}';</script>
@endif
@endif
</div>
</div>
@@ -48,6 +52,15 @@
<textarea id="description" class="form-control" name="description">@if($mode == 'edit'){{ $recipe->description }}@endif</textarea>
</div>
<div class="form-group">
<label for="recipe-picture">{{ $L('Picture') }}</label>
<div class="custom-file">
<input type="file" class="custom-file-input" id="recipe-picture" accept="image/*">
<label class="custom-file-label" for="recipe-picture">{{ $L('No file selected') }}</label>
</div>
<p class="form-text text-muted small">{{ $L('If you don\'t select a file, the current picture will not be altered') }}</p>
</div>
<button id="save-recipe-button" class="btn btn-success">{{ $L('Save') }}</button>
</form>
@@ -147,6 +160,19 @@
</table>
</div>
</div>
<div class="row mt-5">
<div class="col">
<label class="mt-2">{{ $L('Current picture') }}</label>
<button id="delete-current-recipe-picture-button" class="btn btn-sm btn-danger @if(empty($recipe->picture_file_name)) disabled @endif"><i class="fas fa-trash"></i> {{ $L('Delete') }}</button>
@if(!empty($recipe->picture_file_name))
<p><img id="current-recipe-picture" src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name)) }}" class="img-fluid img-thumbnail mt-2"></p>
<p id="delete-current-recipe-picture-on-save-hint" class="form-text text-muted font-italic d-none">{{ $L('The current picture will be deleted when you save the recipe') }}</p>
@else
<p id="no-current-recipe-picture-hint" class="form-text text-muted font-italic">{{ $L('No picture available') }}</p>
@endif
</div>
</div>
</div>
</div>

View File

@@ -73,6 +73,10 @@
<h3 class="mb-0">{{ $selectedRecipeSubRecipe->name }}</h3>
</div>
@if(!empty($selectedRecipeSubRecipe->picture_file_name))
<p><img src="{{ $U('/api/files/recipepictures/' . base64_encode($selectedRecipeSubRecipe->picture_file_name)) }}" class="img-fluid"></p>
@endif
@php $selectedRecipeSubRecipePositionsFiltered = FindAllObjectsInArrayByPropertyValue($selectedRecipeSubRecipesPositions, 'recipe_id', $selectedRecipeSubRecipe->id); @endphp
@if(count($selectedRecipeSubRecipePositionsFiltered) > 0)
<div class="card-body">
@@ -105,6 +109,10 @@
@endforeach
<!-- Selected recipe -->
@if(!empty($selectedRecipe->picture_file_name))
<p><img src="{{ $U('/api/files/recipepictures/' . base64_encode($selectedRecipe->picture_file_name)) }}" class="img-fluid"></p>
@endif
@if($selectedRecipePositions->count() > 0)
<div class="card-body">
<h5 class="mb-0">{{ $L('Ingredients') }}</h5>