Optimized tooltip hide handling

This commit is contained in:
Bernd Bestel 2025-01-17 17:22:37 +01:00
parent ded742a7c1
commit 6605eeafd0
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
12 changed files with 7 additions and 49 deletions

View File

@ -137,10 +137,11 @@ class StockController extends BaseController
public function Overview(Request $request, Response $response, array $args) public function Overview(Request $request, Response $response, array $args)
{ {
$usersService = $this->getUsersService(); $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'; $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'; $where = '1=1';
} }

View File

@ -876,13 +876,9 @@ $('[data-toggle="tooltip"][data-html="true"]').on("shown.bs.tooltip", function()
RefreshLocaleNumberDisplay(".tooltip"); RefreshLocaleNumberDisplay(".tooltip");
}) })
$(document).on("click", "#clear-filter-button", function(e)
{
$(".tooltip").tooltip("hide");
});
$(document).on("click", '.btn, a, button', function(e) $(document).on("click", '.btn, a, button', function(e)
{ {
// Remove focus after click // Remove focus and hide any tooltips after click
document.activeElement.blur(); document.activeElement.blur();
$(".tooltip").tooltip("hide");
}); });

View File

@ -73,7 +73,7 @@ $.extend(true, $.fn.dataTable.defaults, {
{ {
var rowGroup = JSON.parse(Grocy.UserSettings[settingKey]); 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() if (rowGroup.enable !== api.rowGroup().enabled()
|| ("dataSrc" in rowGroup && rowGroup.dataSrc !== api.rowGroup().dataSrc())) || ("dataSrc" in rowGroup && rowGroup.dataSrc !== api.rowGroup().dataSrc()))
{ {

View File

@ -1,5 +1,5 @@
$('.navbar-sidenav [data-toggle="tooltip"]').tooltip({ $('.navbar-sidenav [data-toggle="tooltip"]').tooltip({
template: '<div class="tooltip navbar-sidenav-tooltip" role="tooltip" style="pointer-events: none;"><div class="arrow"></div><div class="tooltip-inner"></div></div>' template: '<div class="tooltip navbar-sidenav-tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
}) })
$("#sidenavToggler").click(function(e) $("#sidenavToggler").click(function(e)

View File

@ -54,8 +54,6 @@ $(document).on('click', '.track-charge-cycle-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var batteryId = $(e.currentTarget).attr('data-battery-id'); var batteryId = $(e.currentTarget).attr('data-battery-id');

View File

@ -84,8 +84,6 @@ $(document).on('click', '.track-chore-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var choreId = $(e.currentTarget).attr('data-chore-id'); var choreId = $(e.currentTarget).attr('data-chore-id');

View File

@ -754,8 +754,6 @@ $(document).on("keydown", "#servings", function(e)
$(document).on('click', '.recipe-order-missing-button', function(e) $(document).on('click', '.recipe-order-missing-button', function(e)
{ {
$(".tooltip").tooltip("hide");
var objectName = $(e.currentTarget).attr('data-recipe-name'); var objectName = $(e.currentTarget).attr('data-recipe-name');
var objectId = $(e.currentTarget).attr('data-recipe-id'); var objectId = $(e.currentTarget).attr('data-recipe-id');
var button = $(this); var button = $(this);
@ -818,8 +816,6 @@ $(document).on('click', '.product-consume-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id'); 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) $(document).on('click', '.recipe-consume-button', function(e)
{ {
$(".tooltip").tooltip("hide");
var objectName = $(e.currentTarget).attr('data-recipe-name'); var objectName = $(e.currentTarget).attr('data-recipe-name');
var objectId = $(e.currentTarget).attr('data-recipe-id'); var objectId = $(e.currentTarget).attr('data-recipe-id');
var mealPlanEntryId = $(e.currentTarget).attr('data-mealplan-entry-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) $(document).on("click", ".display-recipe-button", function(e)
{ {
$(".tooltip").tooltip("hide");
var objectId = $(e.currentTarget).attr('data-recipe-id'); var objectId = $(e.currentTarget).attr('data-recipe-id');
var servings = $(e.currentTarget).attr('data-mealplan-servings'); var servings = $(e.currentTarget).attr('data-mealplan-servings');
@ -957,8 +949,6 @@ $(document).on("click", ".mealplan-entry-done-button", function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id"); var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id");
Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 1 }, Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 1 },
function(result) function(result)
@ -976,8 +966,6 @@ $(document).on("click", ".mealplan-entry-undone-button", function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id"); var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id");
Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 0 }, Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 0 },
function(result) function(result)

View File

@ -444,8 +444,6 @@ $(document).on('click', '.ingredient-done-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
$(e.currentTarget).parent().toggleClass("text-strike-through"); $(e.currentTarget).parent().toggleClass("text-strike-through");
}); });

View File

@ -121,8 +121,6 @@ $(document).on('click', '.shoppinglist-delete-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id'); var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id');
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
@ -242,8 +240,6 @@ $(document).on('click', '.shopping-list-stock-add-workflow-list-item-button', fu
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
var href = $(e.currentTarget).attr('href'); var href = $(e.currentTarget).attr('href');
$("#shopping-list-stock-add-workflow-purchase-form-frame").attr("src", 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(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var listItemId = $(e.currentTarget).attr('data-item-id'); var listItemId = $(e.currentTarget).attr('data-item-id');

View File

@ -66,8 +66,6 @@ $(document).on('click', '.stock-consume-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id'); var productId = $(e.currentTarget).attr('data-product-id');
@ -115,8 +113,6 @@ $(document).on('click', '.product-open-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id'); var productId = $(e.currentTarget).attr('data-product-id');

View File

@ -128,8 +128,6 @@ $(document).on('click', '.product-consume-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id'); var productId = $(e.currentTarget).attr('data-product-id');
@ -181,8 +179,6 @@ $(document).on('click', '.product-open-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id'); var productId = $(e.currentTarget).attr('data-product-id');
@ -329,7 +325,6 @@ function RefreshProductRow(productId)
{ {
animateCSS("#product-" + productId + "-row", "fadeOut", function() animateCSS("#product-" + productId + "-row", "fadeOut", function()
{ {
$("#product-" + productId + "-row").tooltip("hide");
$("#product-" + productId + "-row").addClass("d-none"); $("#product-" + productId + "-row").addClass("d-none");
}); });
} }

View File

@ -67,8 +67,6 @@ $(document).on('click', '.do-task-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var taskId = $(e.currentTarget).attr('data-task-id'); 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() animateCSS("#task-" + taskId + "-row", "fadeOut", function()
{ {
$("#task-" + taskId + "-row").tooltip("hide");
$("#task-" + taskId + "-row").remove(); $("#task-" + taskId + "-row").remove();
}); });
} }
@ -110,8 +107,6 @@ $(document).on('click', '.undo-task-button', function(e)
{ {
e.preventDefault(); e.preventDefault();
$(".tooltip").tooltip("hide");
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
var taskId = $(e.currentTarget).attr('data-task-id'); 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() animateCSS("#task-" + objectId + "-row", "fadeOut", function()
{ {
$("#task-" + objectId + "-row").tooltip("hide");
$("#task-" + objectId + "-row").remove(); $("#task-" + objectId + "-row").remove();
}); });
}, },