From 6605eeafd0b679def6a5e977c7d435d7dd98e4f0 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 17 Jan 2025 17:22:37 +0100 Subject: [PATCH] Optimized tooltip hide handling --- controllers/StockController.php | 5 +++-- public/js/grocy.js | 8 ++------ public/js/grocy_datatables.js | 2 +- public/js/grocy_menu_layout.js | 2 +- public/viewjs/batteriesoverview.js | 2 -- public/viewjs/choresoverview.js | 2 -- public/viewjs/mealplan.js | 12 ------------ public/viewjs/recipes.js | 2 -- public/viewjs/shoppinglist.js | 6 ------ public/viewjs/stockentries.js | 4 ---- public/viewjs/stockoverview.js | 5 ----- public/viewjs/tasks.js | 6 ------ 12 files changed, 7 insertions(+), 49 deletions(-) diff --git a/controllers/StockController.php b/controllers/StockController.php index 68a87e70..408c29c7 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -137,10 +137,11 @@ class StockController extends BaseController public function Overview(Request $request, Response $response, array $args) { $usersService = $this->getUsersService(); - $nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_due_soon_days']; + $userSettings = $usersService->GetUserSettings(GROCY_USER_ID); + $nextXDays = $userSettings['stock_due_soon_days']; $where = 'is_in_stock_or_below_min_stock = 1'; - if (boolval($usersService->GetUserSettings(GROCY_USER_ID)['stock_overview_show_all_out_of_stock_products'])) + if (boolval($userSettings['stock_overview_show_all_out_of_stock_products'])) { $where = '1=1'; } diff --git a/public/js/grocy.js b/public/js/grocy.js index 74e6adf3..db73e7c6 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -876,13 +876,9 @@ $('[data-toggle="tooltip"][data-html="true"]').on("shown.bs.tooltip", function() RefreshLocaleNumberDisplay(".tooltip"); }) -$(document).on("click", "#clear-filter-button", function(e) -{ - $(".tooltip").tooltip("hide"); -}); - $(document).on("click", '.btn, a, button', function(e) { - // Remove focus after click + // Remove focus and hide any tooltips after click document.activeElement.blur(); + $(".tooltip").tooltip("hide"); }); diff --git a/public/js/grocy_datatables.js b/public/js/grocy_datatables.js index d450a75e..7891eeb0 100644 --- a/public/js/grocy_datatables.js +++ b/public/js/grocy_datatables.js @@ -73,7 +73,7 @@ $.extend(true, $.fn.dataTable.defaults, { { var rowGroup = JSON.parse(Grocy.UserSettings[settingKey]); - // Check if there way changed. the draw event is called often therefore we have to check if it's really necessary + // The draw event is called often therefore we have to check if it's really necessary if (rowGroup.enable !== api.rowGroup().enabled() || ("dataSrc" in rowGroup && rowGroup.dataSrc !== api.rowGroup().dataSrc())) { diff --git a/public/js/grocy_menu_layout.js b/public/js/grocy_menu_layout.js index 00d53e9a..a4208de5 100644 --- a/public/js/grocy_menu_layout.js +++ b/public/js/grocy_menu_layout.js @@ -1,5 +1,5 @@ $('.navbar-sidenav [data-toggle="tooltip"]').tooltip({ - template: '' + template: '' }) $("#sidenavToggler").click(function(e) diff --git a/public/viewjs/batteriesoverview.js b/public/viewjs/batteriesoverview.js index 37c46e87..02b9fe6d 100644 --- a/public/viewjs/batteriesoverview.js +++ b/public/viewjs/batteriesoverview.js @@ -54,8 +54,6 @@ $(document).on('click', '.track-charge-cycle-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var batteryId = $(e.currentTarget).attr('data-battery-id'); diff --git a/public/viewjs/choresoverview.js b/public/viewjs/choresoverview.js index 3d300713..9fff4fd8 100644 --- a/public/viewjs/choresoverview.js +++ b/public/viewjs/choresoverview.js @@ -84,8 +84,6 @@ $(document).on('click', '.track-chore-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var choreId = $(e.currentTarget).attr('data-chore-id'); diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js index 13edb516..fada7fe1 100644 --- a/public/viewjs/mealplan.js +++ b/public/viewjs/mealplan.js @@ -754,8 +754,6 @@ $(document).on("keydown", "#servings", function(e) $(document).on('click', '.recipe-order-missing-button', function(e) { - $(".tooltip").tooltip("hide"); - var objectName = $(e.currentTarget).attr('data-recipe-name'); var objectId = $(e.currentTarget).attr('data-recipe-id'); var button = $(this); @@ -818,8 +816,6 @@ $(document).on('click', '.product-consume-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var productId = $(e.currentTarget).attr('data-product-id'); @@ -864,8 +860,6 @@ $(document).on('click', '.product-consume-button', function(e) $(document).on('click', '.recipe-consume-button', function(e) { - $(".tooltip").tooltip("hide"); - var objectName = $(e.currentTarget).attr('data-recipe-name'); var objectId = $(e.currentTarget).attr('data-recipe-id'); var mealPlanEntryId = $(e.currentTarget).attr('data-mealplan-entry-id'); @@ -918,8 +912,6 @@ $(document).on('click', '.recipe-consume-button', function(e) $(document).on("click", ".display-recipe-button", function(e) { - $(".tooltip").tooltip("hide"); - var objectId = $(e.currentTarget).attr('data-recipe-id'); var servings = $(e.currentTarget).attr('data-mealplan-servings'); @@ -957,8 +949,6 @@ $(document).on("click", ".mealplan-entry-done-button", function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id"); Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 1 }, function(result) @@ -976,8 +966,6 @@ $(document).on("click", ".mealplan-entry-undone-button", function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id"); Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 0 }, function(result) diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index 69534339..ec4ba11a 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -444,8 +444,6 @@ $(document).on('click', '.ingredient-done-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - $(e.currentTarget).parent().toggleClass("text-strike-through"); }); diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 93ea0023..6eb85b6b 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -121,8 +121,6 @@ $(document).on('click', '.shoppinglist-delete-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id'); Grocy.FrontendHelpers.BeginUiBusy(); @@ -242,8 +240,6 @@ $(document).on('click', '.shopping-list-stock-add-workflow-list-item-button', fu { e.preventDefault(); - $(".tooltip").tooltip("hide"); - var href = $(e.currentTarget).attr('href'); $("#shopping-list-stock-add-workflow-purchase-form-frame").attr("src", href); @@ -325,8 +321,6 @@ $(document).on('click', '.order-listitem-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var listItemId = $(e.currentTarget).attr('data-item-id'); diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js index 1d442a0c..97f1bf95 100644 --- a/public/viewjs/stockentries.js +++ b/public/viewjs/stockentries.js @@ -66,8 +66,6 @@ $(document).on('click', '.stock-consume-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var productId = $(e.currentTarget).attr('data-product-id'); @@ -115,8 +113,6 @@ $(document).on('click', '.product-open-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var productId = $(e.currentTarget).attr('data-product-id'); diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index efa3a532..a3bc336c 100755 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -128,8 +128,6 @@ $(document).on('click', '.product-consume-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var productId = $(e.currentTarget).attr('data-product-id'); @@ -181,8 +179,6 @@ $(document).on('click', '.product-open-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var productId = $(e.currentTarget).attr('data-product-id'); @@ -329,7 +325,6 @@ function RefreshProductRow(productId) { animateCSS("#product-" + productId + "-row", "fadeOut", function() { - $("#product-" + productId + "-row").tooltip("hide"); $("#product-" + productId + "-row").addClass("d-none"); }); } diff --git a/public/viewjs/tasks.js b/public/viewjs/tasks.js index 0e46b5e5..8687c9da 100644 --- a/public/viewjs/tasks.js +++ b/public/viewjs/tasks.js @@ -67,8 +67,6 @@ $(document).on('click', '.do-task-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var taskId = $(e.currentTarget).attr('data-task-id'); @@ -82,7 +80,6 @@ $(document).on('click', '.do-task-button', function(e) { animateCSS("#task-" + taskId + "-row", "fadeOut", function() { - $("#task-" + taskId + "-row").tooltip("hide"); $("#task-" + taskId + "-row").remove(); }); } @@ -110,8 +107,6 @@ $(document).on('click', '.undo-task-button', function(e) { e.preventDefault(); - $(".tooltip").tooltip("hide"); - Grocy.FrontendHelpers.BeginUiBusy(); var taskId = $(e.currentTarget).attr('data-task-id'); @@ -159,7 +154,6 @@ $(document).on('click', '.delete-task-button', function(e) { animateCSS("#task-" + objectId + "-row", "fadeOut", function() { - $("#task-" + objectId + "-row").tooltip("hide"); $("#task-" + objectId + "-row").remove(); }); },