Show generic error message for product edit requests on product edit page (closes #2774)

This commit is contained in:
Bernd Bestel 2026-08-16 19:57:01 +02:00
parent f77d89af51
commit b3fbb387ca
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 31 additions and 30 deletions

View File

@ -15,6 +15,7 @@
- Fixed that the status filter on the master data products page always displayed "All" after selection (only affected Chrome/Edge)
- Fixed that the "This means _n QU_ will be removed/added from stock"-hint on the inventory page wasn't updated when changing the quantity unit only
- Fixed that the product open button on the stock overview page wasn't disabled after opening the last unit
- Fixed that when changing a product name to one that already exists, no corresponding error message was shown on the product edit page
### Shopping list

View File

@ -78,7 +78,7 @@
});
}
$('.save-product-button').on('click', function(e)
$('.save-product-button').on('click', function (e)
{
e.preventDefault();
@ -117,11 +117,11 @@ $('.save-product-button').on('click', function(e)
jsonData.picture_file_name = null;
Grocy.Api.DeleteFile(Grocy.ProductPictureFileName, 'productpictures',
function(result)
function (result)
{
// Nothing to do
},
function(xhr)
function (xhr)
{
Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
@ -131,10 +131,10 @@ $('.save-product-button').on('click', function(e)
Grocy.Api.Put('objects/products/' + Grocy.EditObjectId, jsonData,
(result) => saveProductPicture(result, location, jsonData),
function(xhr)
function (xhr)
{
Grocy.FrontendHelpers.EndUiBusy("product-form");
console.error(xhr);
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}
);
});
@ -150,7 +150,7 @@ if (GetUriParam("flow") !== undefined || GetUriParam("returnto") !== undefined)
$(".save-product-button[data-location='return']").addClass("d-none");
}
$('.input-group-qu').on('change', function(e)
$('.input-group-qu').on('change', function (e)
{
$("#tare_weight_qu_info").text($("#qu_id_stock option:selected").text());
$("#quick_consume_qu_info").text($("#qu_id_stock option:selected").text());
@ -160,7 +160,7 @@ $('.input-group-qu').on('change', function(e)
Grocy.FrontendHelpers.ValidateForm('product-form');
});
$('#product-form input').keyup(function(event)
$('#product-form input').keyup(function (event)
{
Grocy.FrontendHelpers.ValidateForm('product-form');
$(".input-group-qu").trigger("change");
@ -177,12 +177,12 @@ $('#product-form input').keyup(function(event)
}
});
$('#location_id').change(function(event)
$('#location_id').change(function (event)
{
Grocy.FrontendHelpers.ValidateForm('product-form');
});
$('#product-form input').keydown(function(event)
$('#product-form input').keydown(function (event)
{
if (event.keyCode === 13) // Enter
{
@ -199,7 +199,7 @@ $('#product-form input').keydown(function(event)
}
});
$("#enable_tare_weight_handling").on("click", function()
$("#enable_tare_weight_handling").on("click", function ()
{
if (this.checked)
{
@ -213,7 +213,7 @@ $("#enable_tare_weight_handling").on("click", function()
Grocy.FrontendHelpers.ValidateForm("product-form");
});
$("#product-picture").on("change", function(e)
$("#product-picture").on("change", function (e)
{
$("#product-picture-label").removeClass("d-none");
$("#product-picture-label-none").addClass("d-none");
@ -223,7 +223,7 @@ $("#product-picture").on("change", function(e)
});
Grocy.DeleteProductPictureOnSave = false;
$("#delete-current-product-picture-button").on("click", function(e)
$("#delete-current-product-picture-button").on("click", function (e)
{
Grocy.DeleteProductPictureOnSave = true;
$("#current-product-picture").addClass("d-none");
@ -259,17 +259,17 @@ Grocy.Components.UserfieldsForm.Load();
$("#name").trigger("keyup");
$('.input-group-qu').trigger('change');
Grocy.FrontendHelpers.ValidateForm('product-form');
setTimeout(function()
setTimeout(function ()
{
$('#name').focus();
}, Grocy.FormFocusDelay);
$(document).on('click', '.product-grocycode-label-print', function(e)
$(document).on('click', '.product-grocycode-label-print', function (e)
{
e.preventDefault();
var productId = $(e.currentTarget).attr('data-product-id');
Grocy.Api.Get('stock/products/' + productId + '/printlabel', function(labelData)
Grocy.Api.Get('stock/products/' + productId + '/printlabel', function (labelData)
{
if (Grocy.Webhooks.labelprinter !== undefined)
{
@ -278,7 +278,7 @@ $(document).on('click', '.product-grocycode-label-print', function(e)
});
});
$(document).on('click', '.qu-conversion-delete-button', function(e)
$(document).on('click', '.qu-conversion-delete-button', function (e)
{
var objectId = $(e.currentTarget).attr('data-qu-conversion-id');
@ -295,17 +295,17 @@ $(document).on('click', '.qu-conversion-delete-button', function(e)
className: 'btn-danger'
}
},
callback: function(result)
callback: function (result)
{
if (result === true)
{
Grocy.Api.Delete('objects/quantity_unit_conversions/' + objectId, {},
function(result)
function (result)
{
Grocy.ProductEditFormRedirectUri = "reload";
$('#save-product-button').click();
},
function(xhr)
function (xhr)
{
console.error(xhr);
}
@ -315,7 +315,7 @@ $(document).on('click', '.qu-conversion-delete-button', function(e)
});
});
$(document).on('click', '.barcode-delete-button', function(e)
$(document).on('click', '.barcode-delete-button', function (e)
{
var objectId = $(e.currentTarget).attr('data-barcode-id');
@ -332,17 +332,17 @@ $(document).on('click', '.barcode-delete-button', function(e)
className: 'btn-danger'
}
},
callback: function(result)
callback: function (result)
{
if (result === true)
{
Grocy.Api.Delete('objects/product_barcodes/' + objectId, {},
function(result)
function (result)
{
Grocy.ProductEditFormRedirectUri = "reload";
$('#save-product-button').click();
},
function(xhr)
function (xhr)
{
console.error(xhr);
}
@ -353,7 +353,7 @@ $(document).on('click', '.barcode-delete-button', function(e)
});
var quIdStockBefore = $("#qu_id_stock").val();
$('#qu_id_stock').change(function(e)
$('#qu_id_stock').change(function (e)
{
// Preset qu_id_purchase / qu_id_consume / qu_id_price by qu_id_stock if unset or identical
@ -382,7 +382,7 @@ $('#qu_id_stock').change(function(e)
Grocy.FrontendHelpers.ValidateForm('product-form');
});
$(window).on("message", function(e)
$(window).on("message", function (e)
{
var data = e.originalEvent.data;
@ -395,7 +395,7 @@ $(window).on("message", function(e)
if (Grocy.EditMode == "create" && GetUriParam("copy-of") != undefined)
{
Grocy.Api.Get('objects/products/' + GetUriParam("copy-of"),
function(sourceProduct)
function (sourceProduct)
{
if (sourceProduct.parent_product_id != null)
{
@ -465,7 +465,7 @@ if (Grocy.EditMode == "create" && GetUriParam("copy-of") != undefined)
Grocy.FrontendHelpers.ValidateForm('product-form');
},
function(xhr)
function (xhr)
{
console.error(xhr);
}
@ -504,14 +504,14 @@ else if (Grocy.EditMode === 'create')
}
}
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductPicker.GetPicker().on('change', function (e)
{
var parentProductId = $(e.target).val();
if (parentProductId)
{
Grocy.Api.Get('objects/products/' + parentProductId,
function(parentProduct)
function (parentProduct)
{
if (BoolVal(parentProduct.cumulate_min_stock_amount_of_sub_products))
{
@ -523,7 +523,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$('#min_stock_amount').removeAttr("disabled");
}
},
function(xhr)
function (xhr)
{
console.error(xhr);
}