More initial form field focus optimizations

This commit is contained in:
Bernd Bestel 2025-01-12 17:57:50 +01:00
parent 7d6b76effb
commit 632162c1be
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
24 changed files with 111 additions and 29 deletions

View File

@ -31,11 +31,11 @@ $("#expected_barcode").on("keyup", function(e)
} }
}); });
$("#expected_barcode").focus();
setTimeout(function() setTimeout(function()
{ {
$("#barcodescanner-start-button").attr("disabled", ""); $("#barcodescanner-start-button").attr("disabled", "");
$("#barcodescanner-start-button").addClass("disabled"); $("#barcodescanner-start-button").addClass("disabled");
$("#expected_barcode").focus();
}, 500); }, 500);
if (GetUriParam("barcode") !== undefined) if (GetUriParam("barcode") !== undefined)

View File

@ -78,11 +78,14 @@ $('.combobox').combobox({
}); });
$('#battery_id').val(''); $('#battery_id').val('');
$('#battery_id_text_input').focus();
$('#battery_id_text_input').val(''); $('#battery_id_text_input').val('');
$('#battery_id_text_input').trigger('change'); $('#battery_id_text_input').trigger('change');
Grocy.Components.DateTimePicker.GetInputElement().trigger('input'); Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
Grocy.FrontendHelpers.ValidateForm('batterytracking-form'); Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
setTimeout(function()
{
$('#battery_id_text_input').focus();
}, 500);
$('#batterytracking-form input').keyup(function(event) $('#batterytracking-form input').keyup(function(event)
{ {

View File

@ -111,8 +111,11 @@ for (var i = 0; i < checkboxValues.length; i++)
} }
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();
$('#name').focus();
Grocy.FrontendHelpers.ValidateForm('chore-form'); Grocy.FrontendHelpers.ValidateForm('chore-form');
setTimeout(function()
{
$('#name').focus();
}, 500);
if (Grocy.EditMode == "edit") if (Grocy.EditMode == "edit")
{ {

View File

@ -111,10 +111,13 @@ $('.combobox').combobox({
clearIfNoMatch: false clearIfNoMatch: false
}); });
$('#chore_id_text_input').focus();
$('#chore_id_text_input').trigger('change'); $('#chore_id_text_input').trigger('change');
Grocy.Components.DateTimePicker.GetInputElement().trigger('input'); Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
Grocy.FrontendHelpers.ValidateForm('choretracking-form'); Grocy.FrontendHelpers.ValidateForm('choretracking-form');
setTimeout(function()
{
$('#chore_id_text_input').focus();
}, 500);
$('#choretracking-form input').keyup(function(event) $('#choretracking-form input').keyup(function(event)
{ {

View File

@ -661,7 +661,10 @@ if (GetUriParam("embedded") !== undefined)
} }
// Default input field // Default input field
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
$(document).on("change", "#scan-mode", function(e) $(document).on("change", "#scan-mode", function(e)
{ {

View File

@ -146,8 +146,11 @@ $('#delete-current-instruction-manual-button').on('click', function(e)
ResizeResponsiveEmbeds(); ResizeResponsiveEmbeds();
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();
$('#name').focus();
Grocy.FrontendHelpers.ValidateForm('equipment-form'); Grocy.FrontendHelpers.ValidateForm('equipment-form');
setTimeout(function()
{
$('#name').focus();
}, 500);
$("#instruction-manual").on("change", function(e) $("#instruction-manual").on("change", function(e)
{ {

View File

@ -357,7 +357,11 @@ Grocy.FrontendHelpers.ValidateForm('inventory-form');
if (Grocy.Components.ProductPicker.InAnyFlow() === false && GetUriParam("embedded") === undefined) if (Grocy.Components.ProductPicker.InAnyFlow() === false && GetUriParam("embedded") === undefined)
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
else else
{ {
@ -365,7 +369,11 @@ else
if (Grocy.Components.ProductPicker.InProductModifyWorkflow()) if (Grocy.Components.ProductPicker.InProductModifyWorkflow())
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
} }
@ -373,7 +381,11 @@ $('#display_amount').on('focus', function(e)
{ {
if (Grocy.Components.ProductPicker.GetValue().length === 0) if (Grocy.Components.ProductPicker.GetValue().length === 0)
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
else else
{ {

View File

@ -1,4 +1,7 @@
$('#username').focus(); setTimeout(function()
{
$('#username').focus();
}, 500);
if (GetUriParam('invalid') === 'true') if (GetUriParam('invalid') === 'true')
{ {

View File

@ -96,7 +96,10 @@ $("#add-api-key-button").on("click", function(e)
$("#add-api-key-modal").on("shown.bs.modal", function(e) $("#add-api-key-modal").on("shown.bs.modal", function(e)
{ {
$("#description").focus(); setTimeout(function()
{
$("#description").focus();
}, 500);
}); });
$("#new-api-key-button").on("click", function(e) $("#new-api-key-button").on("click", function(e)

View File

@ -77,4 +77,7 @@ $('#mealplansection-form input').keydown(function(event)
}); });
Grocy.FrontendHelpers.ValidateForm('mealplansection-form'); Grocy.FrontendHelpers.ValidateForm('mealplansection-form');
$('#name').focus(); setTimeout(function()
{
$('#name').focus();
}, 500);

View File

@ -142,7 +142,6 @@ $('.save-product-button').on('click', function(e)
if (GetUriParam("flow") == "InplaceNewProductWithName") if (GetUriParam("flow") == "InplaceNewProductWithName")
{ {
$('#name').val(GetUriParam("name")); $('#name').val(GetUriParam("name"));
$('#name').focus();
} }
if (GetUriParam("flow") !== undefined || GetUriParam("returnto") !== undefined) if (GetUriParam("flow") !== undefined || GetUriParam("returnto") !== undefined)
@ -258,9 +257,12 @@ barcodeTable.columns.adjust().draw();
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();
$("#name").trigger("keyup"); $("#name").trigger("keyup");
$('#name').focus();
$('.input-group-qu').trigger('change'); $('.input-group-qu').trigger('change');
Grocy.FrontendHelpers.ValidateForm('product-form'); Grocy.FrontendHelpers.ValidateForm('product-form');
setTimeout(function()
{
$('#name').focus();
}, 500);
$(document).on('click', '.product-grocycode-label-print', function(e) $(document).on('click', '.product-grocycode-label-print', function(e)
{ {

View File

@ -489,7 +489,10 @@ if (Grocy.Components.ProductPicker)
{ {
if (Grocy.Components.ProductPicker.InAnyFlow() === false && GetUriParam("embedded") === undefined) if (Grocy.Components.ProductPicker.InAnyFlow() === false && GetUriParam("embedded") === undefined)
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
else else
{ {
@ -497,7 +500,10 @@ if (Grocy.Components.ProductPicker)
if (Grocy.Components.ProductPicker.InProductModifyWorkflow()) if (Grocy.Components.ProductPicker.InProductModifyWorkflow())
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
} }
} }
@ -506,7 +512,10 @@ $('#display_amount').on('focus', function(e)
{ {
if (Grocy.Components.ProductPicker.GetValue().length === 0) if (Grocy.Components.ProductPicker.GetValue().length === 0)
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
else else
{ {

View File

@ -141,8 +141,11 @@ $('.input-group-qu').on('change', function(e)
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();
$('.input-group-qu').trigger('change'); $('.input-group-qu').trigger('change');
$('#from_qu_id').focus();
Grocy.FrontendHelpers.ValidateForm('quconversion-form'); Grocy.FrontendHelpers.ValidateForm('quconversion-form');
setTimeout(function()
{
$('#from_qu_id').focus();
}, 500);
if (GetUriParam("qu-unit") !== undefined) if (GetUriParam("qu-unit") !== undefined)
{ {

View File

@ -151,8 +151,11 @@ quConversionsTable.columns.adjust().draw();
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();
$("#name").trigger("keyup"); $("#name").trigger("keyup");
$('#name').focus();
Grocy.FrontendHelpers.ValidateForm('quantityunit-form'); Grocy.FrontendHelpers.ValidateForm('quantityunit-form');
setTimeout(function()
{
$('#name').focus();
}, 500);
$(document).on('click', '.qu-conversion-delete-button', function(e) $(document).on('click', '.qu-conversion-delete-button', function(e)
{ {

View File

@ -34,4 +34,7 @@ if (GetUriParam("qu") !== undefined)
$("#qu_id").trigger("change"); $("#qu_id").trigger("change");
} }
$("#amount").focus(); setTimeout(function()
{
$("#amount").focus();
}, 500);

View File

@ -106,7 +106,10 @@ $('#recipes-includes-table tbody').removeClass("d-none");
recipesIncludesTables.columns.adjust().draw(); recipesIncludesTables.columns.adjust().draw();
Grocy.FrontendHelpers.ValidateForm('recipe-form'); Grocy.FrontendHelpers.ValidateForm('recipe-form');
$("#name").focus(); setTimeout(function()
{
$("#name").focus();
}, 500);
$('#recipe-form input').keyup(function(event) $('#recipe-form input').keyup(function(event)
{ {

View File

@ -156,7 +156,10 @@ $('#display_amount').on('focus', function(e)
{ {
if (Grocy.Components.ProductPicker.GetValue().length === 0) if (Grocy.Components.ProductPicker.GetValue().length === 0)
{ {
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
else else
{ {

View File

@ -292,7 +292,7 @@ if (!Grocy.Components.ProductPicker.InAnyFlow())
setTimeout(function() setTimeout(function()
{ {
$("#display_amount").focus(); $("#display_amount").focus();
}, 300); }, 500);
} }
else else
{ {

View File

@ -518,7 +518,10 @@ if (GetUriParam("embedded") !== undefined)
if (typeof locationId === 'undefined') if (typeof locationId === 'undefined')
{ {
Grocy.Components.ProductPicker.GetPicker().trigger('change'); Grocy.Components.ProductPicker.GetPicker().trigger('change');
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);
} }
else else
{ {
@ -532,4 +535,7 @@ if (GetUriParam("embedded") !== undefined)
} }
// Default input field // Default input field
Grocy.Components.ProductPicker.GetInputElement().focus(); setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 500);

View File

@ -100,11 +100,11 @@ $("#show_in_sidebar_menu").on("click", function()
} }
}); });
Grocy.FrontendHelpers.ValidateForm('userentity-form');
setTimeout(function() setTimeout(function()
{ {
$('#name').focus(); $('#name').focus();
}, 500); }, 500);
Grocy.FrontendHelpers.ValidateForm('userentity-form');
// Click twice to trigger on-click but not change the actual checked state // Click twice to trigger on-click but not change the actual checked state
$("#show_in_sidebar_menu").click(); $("#show_in_sidebar_menu").click();

View File

@ -122,7 +122,10 @@ if (GetUriParam("entity"))
} }
else else
{ {
$('#entity').focus(); setTimeout(function()
{
$('#entity').focus();
}, 500);
} }
$("#type").trigger("change"); $("#type").trigger("change");

View File

@ -80,5 +80,8 @@ if (GetUriParam("entity"))
{ {
$("#entity-filter").val(GetUriParam("entity")); $("#entity-filter").val(GetUriParam("entity"));
$("#entity-filter").trigger("change"); $("#entity-filter").trigger("change");
$("#name").focus(); setTimeout(function()
{
$("#name").focus();
}, 500);
} }

View File

@ -155,7 +155,10 @@ if (GetUriParam("changepw") === "true")
} }
else else
{ {
$('#username').focus(); setTimeout(function()
{
$('#username').focus();
}, 500);
} }
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();

View File

@ -70,3 +70,8 @@
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();
$("#userfields-form").removeClass("border").removeClass("border-info").removeClass("p-2").find("h2").addClass("d-none"); $("#userfields-form").removeClass("border").removeClass("border-info").removeClass("p-2").find("h2").addClass("d-none");
setTimeout(function()
{
$(".userfield-input").first().focus();
}, 500);