mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
This commit's contents were auto-generated. They wrap all viewjs
in functions and define a common prologue.
New file contents:
```js
function VIEWNAMEView(Grocy, scope = null)
{
var $scope = $;
if(scope != null)
{
$scope = $(scope).find;
}
// original contents indented with \t
}
```
82 lines
2.0 KiB
JavaScript
82 lines
2.0 KiB
JavaScript
function userobjectformView(Grocy, scope = null)
|
|
{
|
|
var $scope = $;
|
|
if (scope != null)
|
|
{
|
|
$scope = $(scope).find;
|
|
}
|
|
|
|
import { WindowMessageBag } from '../helpers/messagebag';
|
|
|
|
Grocy.Use("userfieldsform");
|
|
|
|
$('#save-userobject-button').on('click', function(e)
|
|
{
|
|
e.preventDefault();
|
|
|
|
if ($(".combobox-menu-visible").length)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var jsonData = {};
|
|
jsonData.userentity_id = Grocy.EditObjectParentId;
|
|
|
|
Grocy.FrontendHelpers.BeginUiBusy("userobject-form");
|
|
|
|
if (Grocy.EditMode === 'create')
|
|
{
|
|
Grocy.Api.Post('objects/userobjects', jsonData,
|
|
function(result)
|
|
{
|
|
Grocy.EditObjectId = result.created_object_id;
|
|
Grocy.Components.UserfieldsForm.Save(function()
|
|
{
|
|
if (GetUriParam("embedded") !== undefined)
|
|
{
|
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
|
}
|
|
else
|
|
{
|
|
window.location.href = U('/userobjects/' + Grocy.EditObjectParentName);
|
|
}
|
|
});
|
|
},
|
|
function(xhr)
|
|
{
|
|
Grocy.FrontendHelpers.EndUiBusy("userobject-form");
|
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
|
}
|
|
);
|
|
}
|
|
else
|
|
{
|
|
Grocy.Api.Put('objects/userobjects/' + Grocy.EditObjectId, jsonData,
|
|
function(result)
|
|
{
|
|
Grocy.Components.UserfieldsForm.Save(function()
|
|
{
|
|
if (GetUriParam("embedded") !== undefined)
|
|
{
|
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
|
}
|
|
else
|
|
{
|
|
window.location.href = U('/userobjects/' + Grocy.EditObjectParentName);
|
|
}
|
|
});
|
|
},
|
|
function(xhr)
|
|
{
|
|
Grocy.FrontendHelpers.EndUiBusy("userobject-form");
|
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
|
}
|
|
);
|
|
}
|
|
});
|
|
|
|
Grocy.Components.UserfieldsForm.Load();
|
|
$("#userfields-form").removeClass("border").removeClass("border-info").removeClass("p-2").find("h2").addClass("d-none");
|
|
|
|
}
|