2017-04-15 23:16:20 +02:00
|
|
|
|
$('#save-quantityunit-button').on('click', function(e)
|
|
|
|
|
{
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
if (Grocy.EditMode === 'create')
|
|
|
|
|
{
|
|
|
|
|
Grocy.PostJson('/api/add-object/quantity_units', $('#quantityunit-form').serializeJSON(),
|
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = '/quantityunits';
|
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Grocy.PostJson('/api/edit-object/quantity_units/' + Grocy.EditObjectId, $('#quantityunit-form').serializeJSON(),
|
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = '/quantityunits';
|
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(function()
|
|
|
|
|
{
|
|
|
|
|
$('#name').focus();
|
2017-04-16 23:11:03 +02:00
|
|
|
|
$('#quantityunit-form').validator();
|
|
|
|
|
$('#quantityunit-form').validator('validate');
|
2017-04-15 23:16:20 +02:00
|
|
|
|
});
|