mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Optimized initial focus / workflow handling for recipeposform and shoppinglistitemform
This commit is contained in:
parent
fdf5559c25
commit
f01ca33c33
@ -20,6 +20,27 @@ $('#save-recipe-pos-button').on('click', function(e)
|
||||
|
||||
Grocy.FrontendHelpers.BeginUiBusy("recipe-pos-form");
|
||||
|
||||
if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
||||
{
|
||||
var jsonDataBarcode = {};
|
||||
jsonDataBarcode.barcode = GetUriParam("barcode");
|
||||
jsonDataBarcode.product_id = jsonData.product_id;
|
||||
|
||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||
function(result)
|
||||
{
|
||||
$("#flow-info-InplaceAddBarcodeToExistingProduct").addClass("d-none");
|
||||
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||
$('#barcode-lookup-hint').removeClass('d-none');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.EndUiBusy("inventory-form");
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.Api.Post('objects/recipes_pos', jsonData,
|
||||
@ -94,11 +115,37 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
|
||||
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
|
||||
|
||||
if (Grocy.Components.ProductPicker.InProductAddWorkflow() === false)
|
||||
if (!Grocy.Components.ProductPicker.InAnyFlow())
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
if (GetUriParam("product") !== undefined || Grocy.EditMode == "edit")
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
$("#display_amount").focus();
|
||||
}, 250);
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
|
||||
if (Grocy.Components.ProductPicker.InProductModifyWorkflow())
|
||||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
|
||||
if (Grocy.EditMode == "create")
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ if (GetUriParam("amount") !== undefined)
|
||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||
}
|
||||
|
||||
if (GetUriParam("embedded") !== undefined)
|
||||
if (!Grocy.Components.ProductPicker.InAnyFlow())
|
||||
{
|
||||
if (GetUriParam("product") !== undefined || Grocy.EditMode == "edit")
|
||||
{
|
||||
@ -282,7 +282,10 @@ if (GetUriParam("embedded") !== undefined)
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
}
|
||||
|
||||
$("#display_amount").focus();
|
||||
setTimeout(function()
|
||||
{
|
||||
$("#display_amount").focus();
|
||||
}, 250);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -292,6 +295,18 @@ if (GetUriParam("embedded") !== undefined)
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
|
||||
if (Grocy.Components.ProductPicker.InProductModifyWorkflow())
|
||||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
|
||||
var eitherRequiredFields = $("#product_id,#product_id_text_input,#note");
|
||||
eitherRequiredFields.prop('required', "");
|
||||
|
Loading…
x
Reference in New Issue
Block a user