Added a compact view for shopping list (for mobile shopping) (closes #453)

This commit is contained in:
Bernd Bestel
2020-01-24 22:05:08 +01:00
parent fd5a72264d
commit ad54253d72
8 changed files with 62 additions and 11 deletions

View File

@@ -18,7 +18,8 @@
- Fixed that the productcard did not load correctly when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was set to `false` (thanks @kriddles) - Fixed that the productcard did not load correctly when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was set to `false` (thanks @kriddles)
- Fixed that the "Add as barcode to existing product" workflow did not work twice when not switching the page inbetween - Fixed that the "Add as barcode to existing product" workflow did not work twice when not switching the page inbetween
### Shopping list fixes ### Shopping list improvements/fixes
- Added a compact view to have better shopping list for shopping trips (new button "Compact view" in the header, additionally this is automatically enabled on mobile devices / when screen width is < 768 px)
- Fixed that when `FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS` was set to `false`, the shopping list appeared empty after some actions - Fixed that when `FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS` was set to `false`, the shopping list appeared empty after some actions
### Recipe improvements ### Recipe improvements

View File

@@ -1642,3 +1642,9 @@ msgstr ""
msgid "per day" msgid "per day"
msgstr "" msgstr ""
msgid "Compact view"
msgstr ""
msgid "Normal view"
msgstr ""

View File

@@ -57,6 +57,7 @@ a.discrete-link:focus {
top: 0; top: 0;
left: 0; left: 0;
overflow: auto; overflow: auto;
background-color: #ffffff;
} }
/* Fixes smooth scrolling on iOS */ /* Fixes smooth scrolling on iOS */
@@ -65,7 +66,7 @@ a.discrete-link:focus {
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.fullscreen-card .card-header { .fullscreen-card .card-header-fullscreen {
z-index: 9999; z-index: 9999;
width: 100%; width: 100%;
position: fixed; position: fixed;

View File

@@ -219,7 +219,14 @@ $("#selectedRecipeToggleFullscreenButton").on('click', function(e)
$("#selectedRecipeCard .card-header").toggleClass("fixed-top"); $("#selectedRecipeCard .card-header").toggleClass("fixed-top");
$("#selectedRecipeCard .card-body").toggleClass("mt-5"); $("#selectedRecipeCard .card-body").toggleClass("mt-5");
window.location.hash = "fullscreen"; if ($("body").hasClass("fullscreen-card"))
{
window.location.hash = "#fullscreen";
}
else
{
window.history.replaceState(null, null, " ");
}
}); });
$('#servings-scale').keyup(function(event) $('#servings-scale').keyup(function(event)

View File

@@ -340,5 +340,35 @@ $(document).on("click", "#clear-description-button", function(e)
$("#save-description-button").click(); $("#save-description-button").click();
}); });
$(".fullscreen-shopping-list-button").on('click', function(e)
{
e.preventDefault();
$("#shoppinglist-main").toggleClass("fullscreen");
$("body").toggleClass("fullscreen-card");
$("#shopping-list-normal-view-button").toggleClass("d-none");
$("#mainNav").toggleClass("d-none");
if ($("body").hasClass("fullscreen-card"))
{
window.location.hash = "#fullscreen";
}
else
{
window.history.replaceState(null, null, " ");
}
});
$("#description").trigger("summernote.change"); $("#description").trigger("summernote.change");
$("#save-description-button").addClass("disabled"); $("#save-description-button").addClass("disabled");
if (window.location.hash === "#fullscreen")
{
$("#shopping-list-compact-view-button").click();
}
// Auto switch to compact view on mobile
if ($(window).width() < 768)
{
$("#shopping-list-compact-view-button").click();
}

View File

@@ -59,7 +59,7 @@
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane fade show active" id="instruction-manual-tab"> <div class="tab-pane fade show active" id="instruction-manual-tab">
<div id="selectedEquipmentInstructionManualCard" class="card"> <div id="selectedEquipmentInstructionManualCard" class="card">
<div class="card-header"> <div class="card-header card-header-fullscreen">
<i class="fas fa-toolbox"></i> <span class="selected-equipment-name"></span>&nbsp;&nbsp; <i class="fas fa-toolbox"></i> <span class="selected-equipment-name"></span>&nbsp;&nbsp;
<a class="btn btn-sm btn-outline-info py-0 equipment-edit-button hide-on-fullscreen-card" href="#"> <a class="btn btn-sm btn-outline-info py-0 equipment-edit-button hide-on-fullscreen-card" href="#">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>
@@ -79,7 +79,7 @@
</div> </div>
<div class="tab-pane fade" id="description-tab"> <div class="tab-pane fade" id="description-tab">
<div id="selectedEquipmentDescriptionCard" class="card"> <div id="selectedEquipmentDescriptionCard" class="card">
<div class="card-header"> <div class="card-header card-header-fullscreen">
<i class="fas fa-toolbox"></i> <span class="selected-equipment-name"></span>&nbsp;&nbsp; <i class="fas fa-toolbox"></i> <span class="selected-equipment-name"></span>&nbsp;&nbsp;
<a class="btn btn-sm btn-outline-info py-0 equipment-edit-button hide-on-fullscreen-card" href="#"> <a class="btn btn-sm btn-outline-info py-0 equipment-edit-button hide-on-fullscreen-card" href="#">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>

View File

@@ -129,7 +129,7 @@
@if($selectedRecipe !== null) @if($selectedRecipe !== null)
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<div class="card-header"> <div class="card-header card-header-fullscreen">
<i class="fas fa-cocktail"></i> {{ $selectedRecipe->name }}&nbsp;&nbsp; <i class="fas fa-cocktail"></i> {{ $selectedRecipe->name }}&nbsp;&nbsp;
<a id="selectedRecipeConsumeButton" class="btn btn-sm btn-outline-success py-0 hide-when-embedded hide-on-fullscreen-card @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->need_fulfilled == 0) disabled @endif" href="#" data-toggle="tooltip" title="{{ $__t('Consume all ingredients needed by this recipe') }}" data-recipe-id="{{ $selectedRecipe->id }}" data-recipe-name="{{ $selectedRecipe->name }}"> <a id="selectedRecipeConsumeButton" class="btn btn-sm btn-outline-success py-0 hide-when-embedded hide-on-fullscreen-card @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->need_fulfilled == 0) disabled @endif" href="#" data-toggle="tooltip" title="{{ $__t('Consume all ingredients needed by this recipe') }}" data-recipe-id="{{ $selectedRecipe->id }}" data-recipe-name="{{ $selectedRecipe->name }}">
<i class="fas fa-utensils"></i> <i class="fas fa-utensils"></i>

View File

@@ -17,7 +17,7 @@
@section('content') @section('content')
@if(GROCY_FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS) @if(GROCY_FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS)
<div class="row border-bottom pb-2 mb-2 d-print-none"> <div class="row border-bottom pb-2 mb-2 d-print-none hide-on-fullscreen-card">
<div class="col-xs-12 col-md-4"> <div class="col-xs-12 col-md-4">
<label for="selected-shopping-list">{{ $__t('Selected shopping list') }}</label> <label for="selected-shopping-list">{{ $__t('Selected shopping list') }}</label>
<select class="form-control" id="selected-shopping-list"> <select class="form-control" id="selected-shopping-list">
@@ -37,6 +37,9 @@
<a id="print-shopping-list-button" class="btn btn-outline-dark responsive-button" href="#"> <a id="print-shopping-list-button" class="btn btn-outline-dark responsive-button" href="#">
<i class="fas fa-print"></i> {{ $__t('Print') }} <i class="fas fa-print"></i> {{ $__t('Print') }}
</a> </a>
<a id="shopping-list-compact-view-button" class="btn btn-outline-dark responsive-button float-right fullscreen-shopping-list-button" href="#">
<i class="fas fa-compress-arrows-alt"></i> {{ $__t('Compact view') }}
</a>
<!--<div class="dropdown d-inline-block"> <!--<div class="dropdown d-inline-block">
<button class="btn btn-outline-dark responsive-button dropdown-toggle" data-toggle="dropdown"><i class="fas fa-file-export"></i> {{ $__t('Output') }}</button> <button class="btn btn-outline-dark responsive-button dropdown-toggle" data-toggle="dropdown"><i class="fas fa-file-export"></i> {{ $__t('Output') }}</button>
<div class="dropdown-menu"> <div class="dropdown-menu">
@@ -49,7 +52,7 @@
<input type="hidden" name="selected-shopping-list" id="selected-shopping-list" value="1"> <input type="hidden" name="selected-shopping-list" id="selected-shopping-list" value="1">
@endif @endif
<div class="row d-print-none"> <div class="row d-print-none hide-on-fullscreen-card">
<div class="col"> <div class="col">
<h1> <h1>
@yield('title') @yield('title')
@@ -70,7 +73,7 @@
</div> </div>
</div> </div>
<div class="row mt-3 d-print-none"> <div class="row mt-3 d-print-none hide-on-fullscreen-card">
<div class="col-xs-12 col-md-4"> <div class="col-xs-12 col-md-4">
<label for="search">{{ $__t('Search') }}</label> <i class="fas fa-search"></i> <label for="search">{{ $__t('Search') }}</label> <i class="fas fa-search"></i>
<input type="text" class="form-control" id="search"> <input type="text" class="form-control" id="search">
@@ -84,8 +87,11 @@
</div> </div>
</div> </div>
<div class="row d-print-none"> <div id="shoppinglist-main" class="row d-print-none">
<div class="col-xs-12 col-md-8 pb-3"> <div class="col-xs-12 col-md-8 pb-3">
<a id="shopping-list-normal-view-button" class="btn btn-outline-dark btn-block fullscreen-shopping-list-button d-none" href="#">
<i class="fas fa-expand-arrows-alt"></i> {{ $__t('Normal view') }}
</a>
<table id="shoppinglist-table" class="table table-sm table-striped dt-responsive"> <table id="shoppinglist-table" class="table table-sm table-striped dt-responsive">
<thead> <thead>
<tr> <tr>
@@ -149,7 +155,7 @@
</div> </div>
</div> </div>
<div class="row mt-3 d-print-none"> <div class="row mt-3 d-print-none hide-on-fullscreen-card">
<div class="col-xs-12 col-md-8"> <div class="col-xs-12 col-md-8">
<div class="form-group"> <div class="form-group">
<label class="text-larger font-weight-bold" for="notes">{{ $__t('Notes') }}</label> <label class="text-larger font-weight-bold" for="notes">{{ $__t('Notes') }}</label>