mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Prevent productpicker workflow modal from being opened twice (fixes #229)
This commit is contained in:
parent
3cf8ebeb89
commit
b310aa55c5
@ -111,6 +111,7 @@ if (addBarcode !== undefined)
|
|||||||
$('#barcode-lookup-disabled-hint').removeClass('d-none');
|
$('#barcode-lookup-disabled-hint').removeClass('d-none');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||||
$('#product_id_text_input').on('blur', function(e)
|
$('#product_id_text_input').on('blur', function(e)
|
||||||
{
|
{
|
||||||
if (Grocy.Components.ProductPicker.GetPicker().hasClass("combobox-menu-visible"))
|
if (Grocy.Components.ProductPicker.GetPicker().hasClass("combobox-menu-visible"))
|
||||||
@ -129,6 +130,11 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (Grocy.Components.ProductPicker.PopupOpen === true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var optionElement = $("#product_id option:contains('" + input + "')").first();
|
var optionElement = $("#product_id option:contains('" + input + "')").first();
|
||||||
if (input.length > 0 && optionElement.length === 0 && typeof GetUriParam('addbarcodetoselection') === "undefined")
|
if (input.length > 0 && optionElement.length === 0 && typeof GetUriParam('addbarcodetoselection') === "undefined")
|
||||||
{
|
{
|
||||||
@ -138,11 +144,13 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
addProductWorkflowsAdditionalCssClasses = "d-none";
|
addProductWorkflowsAdditionalCssClasses = "d-none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = true;
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
message: __t('"%s" could not be resolved to a product, how do you want to proceed?', input),
|
message: __t('"%s" could not be resolved to a product, how do you want to proceed?', input),
|
||||||
title: __t('Create or assign product'),
|
title: __t('Create or assign product'),
|
||||||
onEscape: function()
|
onEscape: function()
|
||||||
{
|
{
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||||
Grocy.Components.ProductPicker.SetValue('');
|
Grocy.Components.ProductPicker.SetValue('');
|
||||||
},
|
},
|
||||||
size: 'large',
|
size: 'large',
|
||||||
@ -153,6 +161,7 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
className: 'btn-secondary responsive-button',
|
className: 'btn-secondary responsive-button',
|
||||||
callback: function()
|
callback: function()
|
||||||
{
|
{
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||||
Grocy.Components.ProductPicker.SetValue('');
|
Grocy.Components.ProductPicker.SetValue('');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -161,6 +170,7 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
className: 'btn-success add-new-product-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses,
|
className: 'btn-success add-new-product-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses,
|
||||||
callback: function()
|
callback: function()
|
||||||
{
|
{
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||||
window.location.href = U('/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative));
|
window.location.href = U('/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -169,6 +179,7 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
className: 'btn-info add-new-barcode-dialog-button responsive-button',
|
className: 'btn-info add-new-barcode-dialog-button responsive-button',
|
||||||
callback: function()
|
callback: function()
|
||||||
{
|
{
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||||
window.location.href = U(Grocy.CurrentUrlRelative + '?addbarcodetoselection=' + encodeURIComponent(input));
|
window.location.href = U(Grocy.CurrentUrlRelative + '?addbarcodetoselection=' + encodeURIComponent(input));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -177,6 +188,7 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
className: 'btn-warning add-new-product-with-barcode-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses,
|
className: 'btn-warning add-new-product-with-barcode-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses,
|
||||||
callback: function()
|
callback: function()
|
||||||
{
|
{
|
||||||
|
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||||
window.location.href = U('/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative));
|
window.location.href = U('/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user