Optimized Userfield save event handling (fixes #2458)

This commit is contained in:
Bernd Bestel 2025-01-13 21:00:06 +01:00
parent a734d1c3ae
commit c8ccc0b529
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
26 changed files with 184 additions and 105 deletions

View File

@ -58,6 +58,7 @@
### Userfields ### Userfields
- Fixed that Userfield default values were not initialized for the `stock` entity (so affecting the purchase and inventory page) - Fixed that Userfield default values were not initialized for the `stock` entity (so affecting the purchase and inventory page)
- Fixed that uploading bigger or multiple files (so when the upload usually takes a little longer) didn't work (Userfield type "File")
### General ### General

View File

@ -362,8 +362,12 @@ html {
min-height: inherit; min-height: inherit;
} }
.dropdown-toggle::after { .dropdown-toggle:after {
margin-left: -0.15em !important; vertical-align: 0;
margin: 0;
border: none;
content: '\f107';
font-family: 'Font Awesome 6 Free';
} }
/* Third party component customizations - Tempus Dominus */ /* Third party component customizations - Tempus Dominus */

View File

@ -491,11 +491,11 @@ Grocy.FrontendHelpers.RunWebhook = function(webhook, data, repetitions = 1)
$(document).on("keyup paste change", "input, textarea", function() $(document).on("keyup paste change", "input, textarea", function()
{ {
$(this).closest("form").addClass("is-dirty"); $(this).addClass("is-dirty").closest("form").addClass("is-dirty");
}); });
$(document).on("click", "select", function() $(document).on("click", "select", function()
{ {
$(this).closest("form").addClass("is-dirty"); $(this).addClass("is-dirty").closest("form").addClass("is-dirty");
}); });
// Auto saving user setting controls // Auto saving user setting controls

View File

@ -36,7 +36,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("battery-form"); Grocy.FrontendHelpers.EndUiBusy("battery-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -60,7 +60,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("battery-form"); Grocy.FrontendHelpers.EndUiBusy("battery-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -46,7 +46,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("chore-form"); Grocy.FrontendHelpers.EndUiBusy("chore-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -73,7 +73,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("chore-form"); Grocy.FrontendHelpers.EndUiBusy("chore-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -344,7 +344,7 @@ $("#reschedule-chore-save-button").on("click", function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}); });
@ -369,7 +369,7 @@ $("#reschedule-chore-clear-button").on("click", function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}); });

View File

@ -12,10 +12,21 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
return; return;
} }
var jsonData = {}; var editedUserfieldInputs = $("#userfields-form .userfield-input.is-dirty").not("div");
$("#userfields-form .userfield-input").not("div").each(function() if (!editedUserfieldInputs.length)
{ {
if (success)
{
success();
}
return;
}
editedUserfieldInputs.each(function(index, item)
{
var jsonData = {};
var input = $(this); var input = $(this);
var fieldName = input.attr("data-userfield-name"); var fieldName = input.attr("data-userfield-name");
var fieldValue = input.val(); var fieldValue = input.val();
@ -30,33 +41,21 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
} }
else if (input.attr("type") == "file") else if (input.attr("type") == "file")
{ {
var oldFile = input.data('old-file') if (input.hasAttr("data-old-file"))
if (oldFile)
{ {
Grocy.Api.Delete('files/userfiles/' + oldFile, null, null, var oldFile = input.attr("data-old-file");
function(xhr) if (oldFile)
{ {
Grocy.FrontendHelpers.ShowGenericError('Could not delete file', xhr); jsonData[fieldName] = "";
}); }
jsonData[fieldName] = "";
} }
if (input[0].files.length > 0) if (input[0].files.length > 0)
{ {
// Files service requires an extension // Files service requires an extension
var fileName = RandomString() + '.' + CleanFileName(input[0].files[0].name.split('.').reverse()[0]); var newFile = RandomString() + '.' + CleanFileName(input[0].files[0].name.split('.').reverse()[0]);
jsonData[fieldName] = btoa(newFile) + '_' + btoa(CleanFileName(input[0].files[0].name));
jsonData[fieldName] = btoa(fileName) + '_' + btoa(CleanFileName(input[0].files[0].name));
Grocy.Api.UploadFile(input[0].files[0], 'userfiles', fileName,
function(result)
{
},
function(xhr)
{
// When navigating away immediately from the current page, this is maybe a false positive - so ignore this for now
// Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
} }
} }
else if ($(this).hasAttr("multiple")) else if ($(this).hasAttr("multiple"))
@ -67,24 +66,100 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
{ {
jsonData[fieldName] = fieldValue; jsonData[fieldName] = fieldValue;
} }
});
Grocy.Api.Put('userfields/' + $("#userfields-form").data("entity") + '/' + Grocy.EditObjectId, jsonData, Grocy.Api.Put('userfields/' + $("#userfields-form").data("entity") + '/' + Grocy.EditObjectId, jsonData,
function(result) function(result)
{
if (success)
{ {
success(); if (typeof newFile !== 'undefined' && typeof oldFile !== 'undefined') // Delete and Upload
} {
}, Grocy.Api.DeleteFile(oldFile, 'userfiles',
function(xhr) function(result)
{ {
if (error) Grocy.Api.UploadFile(input[0].files[0], 'userfiles', newFile,
function(result2)
{
if (success && index === editedUserfieldInputs.length - 1) // Last item
{
success();
}
},
function(xhr)
{
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
if (error && index === editedUserfieldInputs.length - 1) // Last item
{
error();
}
}
);
},
function(xhr)
{
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
if (error && index === editedUserfieldInputs.length - 1) // Last item
{
error();
}
}
);
}
else if (typeof newFile !== 'undefined') // Upload only
{
Grocy.Api.UploadFile(input[0].files[0], 'userfiles', newFile,
function(result2)
{
if (success && index === editedUserfieldInputs.length - 1) // Last item
{
success();
}
},
function(xhr)
{
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
if (error && index === editedUserfieldInputs.length - 1) // Last item
{
error();
}
}
);
}
else if (typeof oldFile !== 'undefined') // Delete only
{
Grocy.Api.DeleteFile(oldFile, 'userfiles',
function(result)
{
if (success && index === editedUserfieldInputs.length - 1) // Last item
{
success();
}
},
function(xhr)
{
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
if (error && index === editedUserfieldInputs.length - 1) // Last item
{
error();
}
}
);
}
else // Nothing else to do
{
if (success && index === editedUserfieldInputs.length - 1) // Last item
{
success();
}
}
},
function(xhr)
{ {
error(); if (error && index === editedUserfieldInputs.length - 1) // Last item
{
error();
}
} }
} );
); });
} }
Grocy.Components.UserfieldsForm.Load = function() Grocy.Components.UserfieldsForm.Load = function()
@ -155,14 +230,13 @@ Grocy.Components.UserfieldsForm.Load = function()
if (value) if (value)
{ {
var fileName = atob(value.split('_')[1]); var fileName = atob(value.split('_')[1]);
var fileSrc = value.split('_')[0]; var fileSrc = atob(value.split('_')[0]);
var formGroup = input.parent().parent().parent(); var formGroup = input.parent().parent().parent();
formGroup.find("label.custom-file-label").text(fileName); formGroup.find("label.custom-file-label").text(fileName);
formGroup.find(".userfield-file-show").attr('href', U('/files/userfiles/' + value)); formGroup.find(".userfield-file-show").attr('href', U('/files/userfiles/' + value));
formGroup.find('.userfield-file-show').removeClass('d-none'); formGroup.find('.userfield-file-show').removeClass('d-none');
formGroup.find('img.userfield-current-file') formGroup.find('img.userfield-current-file').attr('src', U('/files/userfiles/' + value + '?force_serve_as=picture&best_fit_width=250&best_fit_height=250'));
.attr('src', U('/files/userfiles/' + value + '?force_serve_as=picture&best_fit_width=250&best_fit_height=250'));
formGroup.find('.userfield-file-delete').click( formGroup.find('.userfield-file-delete').click(
function() function()
@ -170,6 +244,7 @@ Grocy.Components.UserfieldsForm.Load = function()
formGroup.find("label.custom-file-label").text(__t("No file selected")); formGroup.find("label.custom-file-label").text(__t("No file selected"));
formGroup.find(".userfield-file-show").addClass('d-none'); formGroup.find(".userfield-file-show").addClass('d-none');
input.attr('data-old-file', fileSrc); input.attr('data-old-file', fileSrc);
input.addClass("is-dirty");
} }
); );

View File

@ -43,7 +43,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("equipment-form"); Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -56,7 +56,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("equipment-form"); Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -64,7 +64,7 @@
{ {
if (Grocy.DeleteInstructionManualOnSave) if (Grocy.DeleteInstructionManualOnSave)
{ {
Grocy.Api.DeleteFile(Grocy.InstructionManualFileNameName, 'equipmentmanuals', {}, Grocy.Api.DeleteFile(Grocy.InstructionManualFileNameName, 'equipmentmanuals',
function(result) function(result)
{ {
// Nothing to do // Nothing to do
@ -72,7 +72,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("equipment-form"); Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}; };
@ -92,7 +92,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("equipment-form"); Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -105,7 +105,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("equipment-form"); Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -36,7 +36,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("location-form"); Grocy.FrontendHelpers.EndUiBusy("location-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -60,7 +60,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("location-form"); Grocy.FrontendHelpers.EndUiBusy("location-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -512,7 +512,7 @@ $(document).on("click", ".remove-recipe-button, .remove-note-button, .remove-pro
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}); });
@ -540,7 +540,7 @@ $('#save-add-recipe-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -553,7 +553,7 @@ $('#save-add-recipe-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -582,7 +582,7 @@ $('#save-add-note-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -595,7 +595,7 @@ $('#save-add-note-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -630,7 +630,7 @@ $('#save-add-product-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -643,7 +643,7 @@ $('#save-add-product-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -843,7 +843,7 @@ $(document).on('click', '.product-consume-button', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}, },
@ -901,7 +901,7 @@ $(document).on('click', '.recipe-consume-button', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}, },
@ -967,7 +967,7 @@ $(document).on("click", ".mealplan-entry-done-button", function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}); });
@ -986,7 +986,7 @@ $(document).on("click", ".mealplan-entry-undone-button", function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}); });

View File

@ -27,7 +27,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("mealplansection-form"); Grocy.FrontendHelpers.EndUiBusy("mealplansection-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -48,7 +48,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("mealplansection-form"); Grocy.FrontendHelpers.EndUiBusy("mealplansection-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -13,7 +13,7 @@
if (Grocy.ProductEditFormRedirectUri == "reload") if (Grocy.ProductEditFormRedirectUri == "reload")
{ {
window.location.reload(); window.location.reload();
return return;
} }
var returnTo = GetUriParam('returnto'); var returnTo = GetUriParam('returnto');
@ -42,7 +42,7 @@
(xhr) => (xhr) =>
{ {
Grocy.FrontendHelpers.EndUiBusy("product-form"); Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -107,7 +107,7 @@ $('.save-product-button').on('click', function(e)
(xhr) => (xhr) =>
{ {
Grocy.FrontendHelpers.EndUiBusy("product-form"); Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}); });
return; return;
} }
@ -116,7 +116,7 @@ $('.save-product-button').on('click', function(e)
{ {
jsonData.picture_file_name = null; jsonData.picture_file_name = null;
Grocy.Api.DeleteFile(Grocy.ProductPictureFileName, 'productpictures', {}, Grocy.Api.DeleteFile(Grocy.ProductPictureFileName, 'productpictures',
function(result) function(result)
{ {
// Nothing to do // Nothing to do
@ -124,7 +124,7 @@ $('.save-product-button').on('click', function(e)
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("product-form"); Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -29,7 +29,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("product-group-form"); Grocy.FrontendHelpers.EndUiBusy("product-group-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -46,7 +46,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("product-group-form"); Grocy.FrontendHelpers.EndUiBusy("product-group-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -45,7 +45,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("quconversion-form"); Grocy.FrontendHelpers.EndUiBusy("quconversion-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -77,7 +77,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("quconversion-form"); Grocy.FrontendHelpers.EndUiBusy("quconversion-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -57,7 +57,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("quantityunit-form"); Grocy.FrontendHelpers.EndUiBusy("quantityunit-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -93,7 +93,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("quantityunit-form"); Grocy.FrontendHelpers.EndUiBusy("quantityunit-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -15,7 +15,7 @@
(xhr) => (xhr) =>
{ {
Grocy.FrontendHelpers.EndUiBusy("recipe-form"); Grocy.FrontendHelpers.EndUiBusy("recipe-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -56,7 +56,7 @@ $('.save-recipe').on('click', function(e)
{ {
jsonData.picture_file_name = null; jsonData.picture_file_name = null;
Grocy.Api.DeleteFile(Grocy.RecipePictureFileName, 'recipepictures', {}, Grocy.Api.DeleteFile(Grocy.RecipePictureFileName, 'recipepictures',
function(result) function(result)
{ {
// Nothing to do // Nothing to do
@ -64,7 +64,7 @@ $('.save-recipe').on('click', function(e)
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("recipe-form"); Grocy.FrontendHelpers.EndUiBusy("recipe-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -317,7 +317,7 @@ $('#save-recipe-include-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -330,7 +330,7 @@ $('#save-recipe-include-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -52,7 +52,7 @@ $('#save-recipe-pos-button').on('click', function(e)
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("recipe-pos-form"); Grocy.FrontendHelpers.EndUiBusy("recipe-pos-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -67,7 +67,7 @@ $('#save-recipe-pos-button').on('click', function(e)
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("recipe-pos-form"); Grocy.FrontendHelpers.EndUiBusy("recipe-pos-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -483,7 +483,7 @@ $('#save-add-to-mealplan-button').on('click', function(e)
}, },
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
}); });

View File

@ -36,7 +36,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("shoppinglocation-form"); Grocy.FrontendHelpers.EndUiBusy("shoppinglocation-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -60,7 +60,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("shoppinglocation-form"); Grocy.FrontendHelpers.EndUiBusy("shoppinglocation-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -36,7 +36,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("task-category-form"); Grocy.FrontendHelpers.EndUiBusy("task-category-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -60,7 +60,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("task-category-form"); Grocy.FrontendHelpers.EndUiBusy("task-category-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -56,7 +56,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("task-form"); Grocy.FrontendHelpers.EndUiBusy("task-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -80,7 +80,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("task-form"); Grocy.FrontendHelpers.EndUiBusy("task-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -34,7 +34,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("userentity-form"); Grocy.FrontendHelpers.EndUiBusy("userentity-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -55,7 +55,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("userentity-form"); Grocy.FrontendHelpers.EndUiBusy("userentity-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -38,7 +38,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("userfield-form"); Grocy.FrontendHelpers.EndUiBusy("userfield-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -59,7 +59,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("userfield-form"); Grocy.FrontendHelpers.EndUiBusy("userfield-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -13,7 +13,7 @@
(xhr) => (xhr) =>
{ {
Grocy.FrontendHelpers.EndUiBusy("user-form"); Grocy.FrontendHelpers.EndUiBusy("user-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -63,7 +63,7 @@ $('#save-user-button').on('click', function(e)
{ {
jsonData.picture_file_name = null; jsonData.picture_file_name = null;
Grocy.Api.DeleteFile(Grocy.UserPictureFileName, 'userpictures', {}, Grocy.Api.DeleteFile(Grocy.UserPictureFileName, 'userpictures',
function(result) function(result)
{ {
// Nothing to do // Nothing to do
@ -71,7 +71,7 @@ $('#save-user-button').on('click', function(e)
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("user-form"); Grocy.FrontendHelpers.EndUiBusy("user-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -38,7 +38,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("userobject-form"); Grocy.FrontendHelpers.EndUiBusy("userobject-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }
@ -62,7 +62,7 @@
function(xhr) function(xhr)
{ {
Grocy.FrontendHelpers.EndUiBusy("userobject-form"); Grocy.FrontendHelpers.EndUiBusy("userobject-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
} }
); );
} }

View File

@ -80,7 +80,6 @@ class FilesService extends BaseService
if (file_exists($filePath)) if (file_exists($filePath))
{ {
$fileNameWithoutExtension = pathinfo($filePath, PATHINFO_FILENAME); $fileNameWithoutExtension = pathinfo($filePath, PATHINFO_FILENAME);
$fileExtension = pathinfo($filePath, PATHINFO_EXTENSION);
// Then the file is an image // Then the file is an image
if (getimagesize($filePath) !== false) if (getimagesize($filePath) !== false)