Added possibility to manage rechargeable batteries

This commit is contained in:
Bernd Bestel
2017-11-05 12:41:00 +01:00
parent dad6322bac
commit 2d5ed67ae1
13 changed files with 603 additions and 5 deletions

38
views/batteryform.js Normal file
View File

@@ -0,0 +1,38 @@
$('#save-battery-button').on('click', function(e)
{
e.preventDefault();
if (Grocy.EditMode === 'create')
{
Grocy.PostJson('/api/add-object/batteries', $('#battery-form').serializeJSON(),
function(result)
{
window.location.href = '/batteries';
},
function(xhr)
{
console.error(xhr);
}
);
}
else
{
Grocy.PostJson('/api/edit-object/batteries/' + Grocy.EditObjectId, $('#battery-form').serializeJSON(),
function(result)
{
window.location.href = '/batteries';
},
function(xhr)
{
console.error(xhr);
}
);
}
});
$(function()
{
$('#name').focus();
$('#battery-form').validator();
$('#battery-form').validator('validate');
});