mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 11:06:36 +00:00
Simplified "checkboxUncheckedValue" handling
This commit is contained in:
@@ -31,23 +31,26 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
||||
else if (input.attr("type") == "file")
|
||||
{
|
||||
var old_file = input.data('old-file')
|
||||
if (old_file) {
|
||||
if (old_file)
|
||||
{
|
||||
Grocy.Api.Delete('files/userfiles/' + old_file, null, null,
|
||||
function (xhr) {
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError('Could not delete file', xhr);
|
||||
});
|
||||
jsonData[fieldName] = "";
|
||||
}
|
||||
if (input[0].files.length > 0){
|
||||
if (input[0].files.length > 0)
|
||||
{
|
||||
// Files service requires an extension
|
||||
var fileName = RandomString() + '.' + input[0].files[0].name.split('.').reverse()[0];
|
||||
|
||||
jsonData[fieldName] = btoa(fileName) + '_' + btoa(input[0].files[0].name);
|
||||
Grocy.Api.UploadFile(input[0].files[0], 'userfiles', fileName,
|
||||
function (result)
|
||||
function(result)
|
||||
{
|
||||
},
|
||||
function (xhr)
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
@@ -111,7 +114,8 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
}
|
||||
if (input.attr('type') == "file")
|
||||
{
|
||||
if (value != null && !value.isEmpty()) {
|
||||
if (value != null && !value.isEmpty())
|
||||
{
|
||||
var file_name = atob(value.split('_')[1]);
|
||||
var file_src = value.split('_')[0];
|
||||
input.hide();
|
||||
@@ -123,7 +127,8 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
file_info.find('img.userfield-current-file')
|
||||
.attr('src', U('/files/userfiles/' + value + '?force_serve_as=picture&best_fit_width=250&best_fit_height=250'))
|
||||
file_info.find('button.userfield-file-delete').click(
|
||||
function () {
|
||||
function()
|
||||
{
|
||||
file_info.addClass('d-none');
|
||||
input.data('old-file', file_src);
|
||||
input.show();
|
||||
|
Reference in New Issue
Block a user