2017-04-15 23:16:20 +02:00
|
|
|
|
$('#save-product-button').on('click', function(e)
|
|
|
|
|
|
{
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
if (Grocy.EditMode === 'create')
|
|
|
|
|
|
{
|
|
|
|
|
|
Grocy.PostJson('/api/add-object/products', $('#product-form').serializeJSON(),
|
|
|
|
|
|
function(result)
|
|
|
|
|
|
{
|
|
|
|
|
|
window.location.href = '/products';
|
|
|
|
|
|
},
|
|
|
|
|
|
function(xhr)
|
|
|
|
|
|
{
|
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Grocy.PostJson('/api/edit-object/products/' + Grocy.EditObjectId, $('#product-form').serializeJSON(),
|
|
|
|
|
|
function(result)
|
|
|
|
|
|
{
|
|
|
|
|
|
window.location.href = '/products';
|
|
|
|
|
|
},
|
|
|
|
|
|
function(xhr)
|
|
|
|
|
|
{
|
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(function()
|
|
|
|
|
|
{
|
|
|
|
|
|
$('#name').focus();
|
2017-04-16 23:11:03 +02:00
|
|
|
|
$('#product-form').validator();
|
|
|
|
|
|
$('#product-form').validator('validate');
|
2017-04-15 23:16:20 +02:00
|
|
|
|
});
|
2017-04-17 16:51:49 +02:00
|
|
|
|
|
|
|
|
|
|
$('#barcode').keydown(function(event)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (event.keyCode === 13) //Enter
|
|
|
|
|
|
{
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|