diff --git a/public/js/grocy.js b/public/js/grocy.js index 2031b7e8..adb5f8b7 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -664,6 +664,9 @@ $.extend(true, $.fn.dataTable.defaults, { } }); +// serializeJSON defaults +$.serializeJSON.defaultOptions.checkboxUncheckedValue = "0"; + $(Grocy.UserPermissions).each(function(index, item) { if (item.has_permission == 0) diff --git a/public/viewjs/choreform.js b/public/viewjs/choreform.js index 9250c6c7..bbad9f8d 100644 --- a/public/viewjs/choreform.js +++ b/public/viewjs/choreform.js @@ -2,7 +2,7 @@ { e.preventDefault(); - var jsonData = $('#chore-form').serializeJSON({ checkboxUncheckedValue: "0" }); + var jsonData = $('#chore-form').serializeJSON(); if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) { jsonData.assignment_config = $("#assignment_config").val().join(","); diff --git a/public/viewjs/components/userfieldsform.js b/public/viewjs/components/userfieldsform.js index 00d6c14c..b6691307 100644 --- a/public/viewjs/components/userfieldsform.js +++ b/public/viewjs/components/userfieldsform.js @@ -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(); diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 09fdf7b8..f8726087 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -65,7 +65,7 @@ $('.save-product-button').on('click', function(e) { e.preventDefault(); - var jsonData = $('#product-form').serializeJSON({ checkboxUncheckedValue: "0" }); + var jsonData = $('#product-form').serializeJSON(); var parentProductId = jsonData.product_id; delete jsonData.product_id; jsonData.parent_product_id = parentProductId; diff --git a/public/viewjs/recipeposform.js b/public/viewjs/recipeposform.js index 1754dc8b..299e0848 100644 --- a/public/viewjs/recipeposform.js +++ b/public/viewjs/recipeposform.js @@ -4,7 +4,7 @@ $('#save-recipe-pos-button').on('click', function(e) { e.preventDefault(); - var jsonData = $('#recipe-pos-form').serializeJSON({ checkboxUncheckedValue: "0" }); + var jsonData = $('#recipe-pos-form').serializeJSON(); jsonData.recipe_id = Grocy.EditObjectParentId; delete jsonData.display_amount; diff --git a/views/choreform.blade.php b/views/choreform.blade.php index 1f2b3ba5..00ff4952 100644 --- a/views/choreform.blade.php +++ b/views/choreform.blade.php @@ -205,9 +205,6 @@