mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Simplified "checkboxUncheckedValue" handling
This commit is contained in:
@@ -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)
|
||||
|
@@ -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(",");
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user