From ad54253d7299be091ace7fff7a1aedb33bc27010 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 24 Jan 2020 22:05:08 +0100 Subject: [PATCH] Added a compact view for shopping list (for mobile shopping) (closes #453) --- changelog/55_UNRELEASED_2019-xx-xx.md | 3 ++- localization/strings.pot | 6 ++++++ public/css/grocy.css | 3 ++- public/viewjs/recipes.js | 9 +++++++- public/viewjs/shoppinglist.js | 30 +++++++++++++++++++++++++++ views/equipment.blade.php | 4 ++-- views/recipes.blade.php | 2 +- views/shoppinglist.blade.php | 16 +++++++++----- 8 files changed, 62 insertions(+), 11 deletions(-) diff --git a/changelog/55_UNRELEASED_2019-xx-xx.md b/changelog/55_UNRELEASED_2019-xx-xx.md index ee5d1df9..7f708e61 100644 --- a/changelog/55_UNRELEASED_2019-xx-xx.md +++ b/changelog/55_UNRELEASED_2019-xx-xx.md @@ -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 "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 ### Recipe improvements diff --git a/localization/strings.pot b/localization/strings.pot index 9513456d..cff66011 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1642,3 +1642,9 @@ msgstr "" msgid "per day" msgstr "" + +msgid "Compact view" +msgstr "" + +msgid "Normal view" +msgstr "" diff --git a/public/css/grocy.css b/public/css/grocy.css index 63299909..ade4f655 100644 --- a/public/css/grocy.css +++ b/public/css/grocy.css @@ -57,6 +57,7 @@ a.discrete-link:focus { top: 0; left: 0; overflow: auto; + background-color: #ffffff; } /* Fixes smooth scrolling on iOS */ @@ -65,7 +66,7 @@ a.discrete-link:focus { -webkit-overflow-scrolling: touch; } -.fullscreen-card .card-header { +.fullscreen-card .card-header-fullscreen { z-index: 9999; width: 100%; position: fixed; diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index daaf27f4..87063fe8 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -219,7 +219,14 @@ $("#selectedRecipeToggleFullscreenButton").on('click', function(e) $("#selectedRecipeCard .card-header").toggleClass("fixed-top"); $("#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) diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 2991b6a6..27aa188e 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -340,5 +340,35 @@ $(document).on("click", "#clear-description-button", function(e) $("#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"); $("#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(); +} diff --git a/views/equipment.blade.php b/views/equipment.blade.php index cca752f8..04394f72 100644 --- a/views/equipment.blade.php +++ b/views/equipment.blade.php @@ -59,7 +59,7 @@