mirror of
https://github.com/grocy/grocy.git
synced 2025-10-12 16:44:55 +00:00
Modularize product picker
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('#product_id').on('change', function(e)
|
||||
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
{
|
||||
var productId = $(e.target).val();
|
||||
|
||||
@@ -52,39 +52,22 @@ $('#product_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (possibleOptionElement.length > 0 && possibleOptionElement.text().length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
if (Grocy.EditMode === 'edit')
|
||||
{
|
||||
$('#product_id').addClass('suppress-next-custom-validate-event');
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||
|
||||
if (Grocy.Components.ProductPicker.InProductAddWorkflow() === false)
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
}
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
if (Grocy.Components.ProductPicker.GetValue().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user