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 @@
- track_date_only == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="track_date_only" name="track_date_only" value="1"> @@ -222,9 +219,6 @@
- rollover == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="rollover" name="rollover" value="1"> @@ -240,9 +234,6 @@ @if(GROCY_FEATURE_FLAG_STOCK)
- consume_product_on_execution == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="consume_product_on_execution" name="consume_product_on_execution" value="1"> diff --git a/views/components/datetimepicker.blade.php b/views/components/datetimepicker.blade.php index 275b4a39..83131dc4 100644 --- a/views/components/datetimepicker.blade.php +++ b/views/components/datetimepicker.blade.php @@ -69,9 +69,6 @@ @if(isset($shortcutValue) && isset($shortcutLabel))
- - type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
- + for="userfield-{{ $userfield->name }}">{{ $userfield->caption }}
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_PRESET_LIST) diff --git a/views/consume.blade.php b/views/consume.blade.php index 5b8a40f4..3fbdf2b9 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -60,9 +60,6 @@
-
-
-
- is_freezer == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="is_freezer" name="is_freezer" value="1"> diff --git a/views/productform.blade.php b/views/productform.blade.php index bb3abd86..53a8003d 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -64,9 +64,6 @@
-
- cumulate_min_stock_amount_of_sub_products == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="cumulate_min_stock_amount_of_sub_products" name="cumulate_min_stock_amount_of_sub_products" value="1"> @@ -261,9 +255,6 @@
- allow_partial_units_in_stock == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="allow_partial_units_in_stock" name="allow_partial_units_in_stock" value="1"> @@ -274,9 +265,6 @@
- enable_tare_weight_handling == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="enable_tare_weight_handling" name="enable_tare_weight_handling" value="1"> @@ -306,9 +294,6 @@ @if(GROCY_FEATURE_FLAG_RECIPES)
- not_check_stock_fulfillment_for_recipes == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="not_check_stock_fulfillment_for_recipes" name="not_check_stock_fulfillment_for_recipes" value="1"> diff --git a/views/quantityunitconversionform.blade.php b/views/quantityunitconversionform.blade.php index 1645d1f8..adefdace 100644 --- a/views/quantityunitconversionform.blade.php +++ b/views/quantityunitconversionform.blade.php @@ -96,9 +96,6 @@
-
- not_check_shoppinglist == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="not_check_shoppinglist" name="not_check_shoppinglist" value="1"> diff --git a/views/recipeposform.blade.php b/views/recipeposform.blade.php index 55653bb1..514dd3ea 100644 --- a/views/recipeposform.blade.php +++ b/views/recipeposform.blade.php @@ -48,9 +48,6 @@
- only_check_single_unit_in_stock == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="only_check_single_unit_in_stock" name="only_check_single_unit_in_stock" value="1"> @@ -80,9 +77,6 @@
- not_check_stock_fulfillment == 1 || FindObjectInArrayByPropertyValue($products, 'id', $recipePos->product_id)->not_check_stock_fulfillment_for_recipes == 1)) checked @endif class="form-check-input custom-control-input" type="checkbox" id="not_check_stock_fulfillment" name="not_check_stock_fulfillment" value="1"> diff --git a/views/stockentryform.blade.php b/views/stockentryform.blade.php index 90f9403f..f24565f6 100644 --- a/views/stockentryform.blade.php +++ b/views/stockentryform.blade.php @@ -124,9 +124,6 @@
- open == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="open" name="open" value="1"> diff --git a/views/transfer.blade.php b/views/transfer.blade.php index 11dbc9a7..4cedccfc 100644 --- a/views/transfer.blade.php +++ b/views/transfer.blade.php @@ -49,9 +49,6 @@
-
- show_in_sidebar_menu == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="show_in_sidebar_menu" name="show_in_sidebar_menu" value="1"> diff --git a/views/userfieldform.blade.php b/views/userfieldform.blade.php index 90a5078b..0a1e834a 100644 --- a/views/userfieldform.blade.php +++ b/views/userfieldform.blade.php @@ -98,9 +98,6 @@
- show_as_column_in_tables == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="show_as_column_in_tables" name="show_as_column_in_tables" value="1">