From d82fd09fbaea10a0c652b7c6caef56d546087c29 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 8 Nov 2020 15:09:10 +0100 Subject: [PATCH] UI test/review --- changelog/60_UNRELEASED_2020-xx-xx.md | 2 +- config-dist.php | 1 - localization/strings.pot | 6 -- public/js/grocy.js | 24 ++++++ public/viewjs/batteriesoverview.js | 4 +- public/viewjs/components/productcard.js | 2 +- public/viewjs/consume.js | 6 ++ public/viewjs/productform.js | 6 -- public/viewjs/purchase.js | 5 ++ public/viewjs/shoppinglist.js | 32 -------- public/viewjs/shoppinglistsettings.js | 5 -- public/viewjs/stockoverview.js | 14 ---- public/viewjs/taskform.js | 18 ++++- services/StockService.php | 12 ++- views/barcodescannertesting.blade.php | 2 +- views/batteries.blade.php | 2 +- views/batteriesjournal.blade.php | 2 +- views/batteriesoverview.blade.php | 12 ++- views/batteriessettings.blade.php | 2 +- views/batteryform.blade.php | 2 +- views/batterytracking.blade.php | 2 +- views/calendar.blade.php | 2 +- views/choreform.blade.php | 2 +- views/chores.blade.php | 2 +- views/choresjournal.blade.php | 2 +- views/choresoverview.blade.php | 8 +- views/choressettings.blade.php | 2 +- views/choretracking.blade.php | 2 +- views/components/batterycard.blade.php | 4 +- views/components/chorecard.blade.php | 4 +- views/components/productcard.blade.php | 6 +- views/consume.blade.php | 4 +- views/equipmentform.blade.php | 2 +- views/inventory.blade.php | 2 +- views/locationform.blade.php | 2 +- views/locations.blade.php | 2 +- views/login.blade.php | 2 +- views/manageapikeys.blade.php | 2 +- views/mealplan.blade.php | 2 +- views/productbarcodesform.blade.php | 2 +- views/productform.blade.php | 4 +- views/productgroupform.blade.php | 2 +- views/productgroups.blade.php | 2 +- views/products.blade.php | 2 +- views/purchase.blade.php | 4 +- views/quantityunitconversionform.blade.php | 2 +- views/quantityunitform.blade.php | 2 +- views/quantityunitpluraltesting.blade.php | 2 +- views/quantityunits.blade.php | 2 +- views/recipeform.blade.php | 2 +- views/recipeposform.blade.php | 2 +- views/recipessettings.blade.php | 2 +- views/shoppinglist.blade.php | 86 +++++++++++++--------- views/shoppinglistform.blade.php | 2 +- views/shoppinglistitemform.blade.php | 2 +- views/shoppinglistsettings.blade.php | 13 +--- views/shoppinglocationform.blade.php | 2 +- views/shoppinglocations.blade.php | 2 +- views/stockentries.blade.php | 2 +- views/stockentryform.blade.php | 2 +- views/stockjournal.blade.php | 2 +- views/stockjournalsummary.blade.php | 2 +- views/stockoverview.blade.php | 16 ++-- views/stocksettings.blade.php | 43 ++++++----- views/taskcategories.blade.php | 2 +- views/taskcategoryform.blade.php | 2 +- views/taskform.blade.php | 2 +- views/tasks.blade.php | 12 +-- views/taskssettings.blade.php | 2 +- views/transfer.blade.php | 2 +- views/userentities.blade.php | 2 +- views/userentityform.blade.php | 2 +- views/userfieldform.blade.php | 2 +- views/userfields.blade.php | 2 +- views/userform.blade.php | 2 +- views/userobjectform.blade.php | 2 +- views/userobjects.blade.php | 2 +- views/userpermissions.blade.php | 2 +- views/users.blade.php | 2 +- views/usersettings.blade.php | 2 +- 80 files changed, 233 insertions(+), 226 deletions(-) diff --git a/changelog/60_UNRELEASED_2020-xx-xx.md b/changelog/60_UNRELEASED_2020-xx-xx.md index 1ee84067..1b2db73d 100644 --- a/changelog/60_UNRELEASED_2020-xx-xx.md +++ b/changelog/60_UNRELEASED_2020-xx-xx.md @@ -137,7 +137,7 @@ ### General & other improvements/fixes - UI refresh / style improvements (thanks @zsarnett for the idea and initial work on this) - Improved mobile views (thanks @4lloyd for the idea and initial work on this) - - The buttons on the top of each page and the filter row is now collapsed (use the ellipsis/filter button to show them) + - The buttons on the top of each page and the filter row is now collapsed (use the ellipsis/filter button to show them, this also superseded the shopping list compact view) - Tables are horizontally scrollable (instead of collapsing columns which don't fit) - Added a "Clear filter"-button on all pages (with filters) to quickly reset applied filters - The data path (previously fixed to the `data` folder) is now configurable, making it possible to run multiple grocy instances from the same directory (with different `config.php` files / different database, etc.) (thanks @fgrsnau) diff --git a/config-dist.php b/config-dist.php index fa70aaef..425ef9f7 100644 --- a/config-dist.php +++ b/config-dist.php @@ -124,7 +124,6 @@ DefaultUserSetting('show_purchased_date_on_purchase', false); // Wheter the purc // Shopping list settings DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set DefaultUserSetting('shopping_list_show_calendar', false); -DefaultUserSetting('shopping_list_disable_auto_compact_view_on_mobile', false); // Recipe settings DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group diff --git a/localization/strings.pot b/localization/strings.pot index bab60afa..28568f86 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1655,9 +1655,6 @@ msgstr "" msgid "per day" msgstr "" -msgid "Compact view" -msgstr "" - msgid "Normal view" msgstr "" @@ -1730,9 +1727,6 @@ msgstr "" msgid "Show a month-view calendar" msgstr "" -msgid "Don't automatically switch to the compact view on mobile devices" -msgstr "" - msgid "Edit note on %s" msgstr "" diff --git a/public/js/grocy.js b/public/js/grocy.js index 065b3f4c..2031b7e8 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -707,3 +707,27 @@ $('.dropdown-item').has('.form-check input[type=checkbox]').on('click', function $(e.target).find('input[type=checkbox]').click(); } }) + +$('.table').on('column-sizing.dt', function(e, settings) +{ + var dtScrollWidth = $('.dataTables_scroll').width(); + var tableWidth = $('.table').width(); + + if (dtScrollWidth < tableWidth) + { + $('.dataTables_scrollBody').addClass("grab-cursor"); + } else + { + $('.dataTables_scrollBody').removeClass("grab-cursor"); + } +}); + +$(window).on("message", function(e) +{ + var data = e.originalEvent.data; + + if (data.Message === "Reload") + { + window.location.reload(); + } +}); diff --git a/public/viewjs/batteriesoverview.js b/public/viewjs/batteriesoverview.js index 65108df0..4ff3357a 100644 --- a/public/viewjs/batteriesoverview.js +++ b/public/viewjs/batteriesoverview.js @@ -25,7 +25,7 @@ $("#clear-filter-button").on("click", function() { $("#search").val(""); $("#status-filter").val("all"); - batteriesOverviewTable.column(4).search("").draw(); + batteriesOverviewTable.column(5).search("").draw(); batteriesOverviewTable.search("").draw(); }); @@ -40,7 +40,7 @@ $("#status-filter").on("change", function() // Transfer CSS classes of selected element to dropdown element (for background) $(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control"); - batteriesOverviewTable.column(4).search(value).draw(); + batteriesOverviewTable.column(5).search(value).draw(); }); $(".status-filter-message").on("click", function() diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js index 2b3b5f03..3d4d3195 100644 --- a/public/viewjs/components/productcard.js +++ b/public/viewjs/components/productcard.js @@ -88,7 +88,7 @@ Grocy.Components.ProductCard.Refresh = function(productId) $('#productcard-product-edit-button').attr("href", U("/product/" + productDetails.product.id.toString() + '?' + 'returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative))); $('#productcard-product-journal-button').attr("href", U("/stockjournal?embedded&product=" + productDetails.product.id.toString())); - $('#productcard-product-stock-button').attr("href", U("/stockentries?product=" + productDetails.product.id.toString())); + $('#productcard-product-stock-button').attr("href", U("/stockentries?embedded&product=" + productDetails.product.id.toString())); $('#productcard-product-stock-button').removeClass("disabled"); $('#productcard-product-edit-button').removeClass("disabled"); $('#productcard-product-journal-button').removeClass("disabled"); diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index f2f94a69..264f203a 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -388,6 +388,12 @@ $('#amount').on('focus', function(e) $(this).select(); }); +$('#price').on('focus', function(e) +{ + $(this).select(); +}); + + $('#consume-form input').keyup(function(event) { Grocy.FrontendHelpers.ValidateForm('consume-form'); diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index bdf400c5..0e9495e6 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -415,12 +415,6 @@ Grocy.FrontendHelpers.ValidateForm('product-form'); $("#allow_partial_units_in_stock").click(); $("#allow_partial_units_in_stock").click(); -$(document).on('click', '#save-product-button-continue', function() -{ - Grocy.ProductEditFormRedirectUri = "reload"; - $('#save-product-button').click(); -}); - $(document).on('click', '.qu-conversion-delete-button', function(e) { var objectId = $(e.currentTarget).attr('data-qu-conversion-id'); diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index c92cbfe6..1ac83612 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -355,6 +355,11 @@ $('#amount').on('focus', function(e) } }); +$('#price').on('focus', function(e) +{ + $(this).select(); +}); + $('#purchase-form input').keyup(function(event) { Grocy.FrontendHelpers.ValidateForm('purchase-form'); diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 947954a2..45ac063f 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -423,41 +423,9 @@ $(document).on("click", "#clear-description-button", function(e) $("#save-description-button").click(); }); -$(".switch-view-mode-button").on('click', function(e) -{ - e.preventDefault(); - - $("#shoppinglist-main").toggleClass("fullscreen"); - $(".dataTables_scrollHeadInner").width(""); // Remove absolute width on element set by DataTables - $(".dataTables_scrollHeadInner table").width(""); // Remove absolute width on element set by DataTables - $("body").toggleClass("fullscreen-card"); - $("#shopping-list-normal-view-button").toggleClass("d-none"); - $("#mainNav").toggleClass("d-none"); - - if ($("body").hasClass("fullscreen-card")) - { - window.location.hash = "#compact"; - } - else - { - window.history.replaceState(null, null, " "); - } -}); - $("#description").trigger("summernote.change"); $("#save-description-button").addClass("disabled"); -if (window.location.hash === "#compact") -{ - $("#shopping-list-compact-view-button").click(); -} - -// Auto switch to compact view on mobile when enabled -if ($(window).width() < 768 & window.location.hash !== "#compact" && !BoolVal(Grocy.UserSettings.shopping_list_disable_auto_compact_view_on_mobile)) -{ - $("#shopping-list-compact-view-button").click(); -} - $(window).on("message", function(e) { var data = e.originalEvent.data; diff --git a/public/viewjs/shoppinglistsettings.js b/public/viewjs/shoppinglistsettings.js index 9872f696..68460c61 100644 --- a/public/viewjs/shoppinglistsettings.js +++ b/public/viewjs/shoppinglistsettings.js @@ -7,8 +7,3 @@ if (BoolVal(Grocy.UserSettings.shopping_list_show_calendar)) { $("#shopping-list-show-calendar").prop("checked", true); } - -if (BoolVal(Grocy.UserSettings.shopping_list_disable_auto_compact_view_on_mobile)) -{ - $("#shopping-list-disable-auto-compact-view-on-mobile").prop("checked", true); -} diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index be9690b1..f64e97d0 100755 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -11,20 +11,6 @@ ], }); -$('#stock-overview-table').on('column-sizing.dt', function(e, settings) -{ - var dtScrollWidth = $('.dataTables_scroll').width(); - var stockTableWidth = $('#stock-overview-table').width(); - - if (dtScrollWidth < stockTableWidth) - { - $('.dataTables_scrollBody').addClass("grab-cursor"); - } else - { - $('.dataTables_scrollBody').removeClass("grab-cursor"); - } -}); - $('#stock-overview-table tbody').removeClass("d-none"); stockOverviewTable.columns.adjust().draw(); $('.dataTables_scrollBody').addClass("dragscroll"); diff --git a/public/viewjs/taskform.js b/public/viewjs/taskform.js index b7f124da..3bbe90bc 100644 --- a/public/viewjs/taskform.js +++ b/public/viewjs/taskform.js @@ -17,7 +17,14 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/tasks'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/tasks'); + } }); }, function(xhr) @@ -34,7 +41,14 @@ { Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/tasks'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/tasks'); + } }); }, function(xhr) diff --git a/services/StockService.php b/services/StockService.php index 1c639687..156fb9f7 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -549,8 +549,16 @@ class StockService extends BaseService $lastPrice = $productLastPurchased->price; $lastQuFactorPurchaseToStock = $productLastPurchased->qu_factor_purchase_to_stock; $lastShoppingLocation = $productLastPurchased->shopping_location_id; - $avgPrice = $this->getDatabase()->products_average_price()->where('product_id', $productId)->fetch()->price; - $oldestPrice = $this->getDatabase()->products_oldest_stock_unit_price()->where('product_id', $productId)->fetch()->price; + $avgPriceRow = $this->getDatabase()->products_average_price()->where('product_id', $productId)->fetch(); + if ($avgPriceRow) + { + $avgPrice = $avgPriceRow->price; + } + $oldestPriceRow = $this->getDatabase()->products_oldest_stock_unit_price()->where('product_id', $productId)->fetch(); + if ($oldestPriceRow) + { + $oldestPrice = $avgPriceRow->price; + } } $product = $this->getDatabase()->products($productId); diff --git a/views/barcodescannertesting.blade.php b/views/barcodescannertesting.blade.php index e1d2bdc1..bf9903d6 100644 --- a/views/barcodescannertesting.blade.php +++ b/views/barcodescannertesting.blade.php @@ -16,7 +16,7 @@ -
+
diff --git a/views/batteries.blade.php b/views/batteries.blade.php index 71fde193..7aefc2e4 100644 --- a/views/batteries.blade.php +++ b/views/batteries.blade.php @@ -38,7 +38,7 @@
-
+
diff --git a/views/batteriesjournal.blade.php b/views/batteriesjournal.blade.php index 8c31b170..f887e569 100644 --- a/views/batteriesjournal.blade.php +++ b/views/batteriesjournal.blade.php @@ -19,7 +19,7 @@
-
+
diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index 49481b2c..871d0b3d 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -37,14 +37,14 @@ data-status-filter="overdue" class="error-message status-filter-message responsive-button">
- {{ $__t('Clear filter') }} @@ -89,6 +89,7 @@ {{ $__t('Battery') }} + {{ $__t('Used in') }} {{ $__t('Last charged') }} {{ $__t('Next planned charge cycle') }} Hidden status @@ -128,9 +129,9 @@ href="#"> {{ $__t('Show battery details') }} - + href="{{ $U('/batteriesjournal?embedded&battery=') }}{{ $currentBatteryEntry->battery_id }}"> {{ $__t('Journal for this battery') }} {{ FindObjectInArrayByPropertyValue($batteries, 'id', $currentBatteryEntry->battery_id)->name }} + + {{ FindObjectInArrayByPropertyValue($batteries, 'id', $currentBatteryEntry->battery_id)->used_in }} + {{ $currentBatteryEntry->last_tracked_time }}
-
+
diff --git a/views/batteryform.blade.php b/views/batteryform.blade.php index 340bd794..d8aa9d43 100644 --- a/views/batteryform.blade.php +++ b/views/batteryform.blade.php @@ -15,7 +15,7 @@
-
+
diff --git a/views/batterytracking.blade.php b/views/batterytracking.blade.php index 7de08b86..81bedba5 100644 --- a/views/batterytracking.blade.php +++ b/views/batterytracking.blade.php @@ -9,7 +9,7 @@

@yield('title')

-
+
diff --git a/views/calendar.blade.php b/views/calendar.blade.php index afcffdaf..4a1d7186 100644 --- a/views/calendar.blade.php +++ b/views/calendar.blade.php @@ -38,7 +38,7 @@
-
+