mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 11:27:03 +00:00
Fixed the "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product (fixes #222)
This commit is contained in:
@@ -20,3 +20,5 @@
|
|||||||
- This involved some string changes which results in a needed (re)translation of about 20 strings (excluding demo data)
|
- This involved some string changes which results in a needed (re)translation of about 20 strings (excluding demo data)
|
||||||
- Also applies to quantity units, n-plural forms can be entered on the quantity unit edit page
|
- Also applies to quantity units, n-plural forms can be entered on the quantity unit edit page
|
||||||
- It's not required to install the PHP gettext extension, on both, server and client, managed implementations of gettext are used ([oscarotero/Gettext](https://github.com/oscarotero/Gettext) & [oscarotero/gettext-translator](https://github.com/oscarotero/gettext-translator))
|
- It's not required to install the PHP gettext extension, on both, server and client, managed implementations of gettext are used ([oscarotero/Gettext](https://github.com/oscarotero/Gettext) & [oscarotero/gettext-translator](https://github.com/oscarotero/gettext-translator))
|
||||||
|
- Some other small fixes
|
||||||
|
- The "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product
|
||||||
|
@@ -32,6 +32,33 @@
|
|||||||
Grocy.Api.Post(apiUrl, jsonData,
|
Grocy.Api.Post(apiUrl, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
|
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||||
|
if (addBarcode !== undefined)
|
||||||
|
{
|
||||||
|
var existingBarcodes = productDetails.product.barcode || '';
|
||||||
|
if (existingBarcodes.length === 0)
|
||||||
|
{
|
||||||
|
productDetails.product.barcode = addBarcode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
productDetails.product.barcode += ',' + addBarcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
|
||||||
|
function(result)
|
||||||
|
{
|
||||||
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
|
window.history.replaceState({ }, document.title, U("/consume"));
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
$("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
||||||
if ($("#use_specific_stock_entry").is(":checked"))
|
if ($("#use_specific_stock_entry").is(":checked"))
|
||||||
{
|
{
|
||||||
|
@@ -30,7 +30,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
|
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
|
||||||
function (result) { },
|
function(result)
|
||||||
|
{
|
||||||
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
|
window.history.replaceState({ }, document.title, U("/inventory"));
|
||||||
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
@@ -41,24 +46,17 @@
|
|||||||
Grocy.FrontendHelpers.EndUiBusy("inventory-form");
|
Grocy.FrontendHelpers.EndUiBusy("inventory-form");
|
||||||
toastr.success(__t('Stock amount of %s is now %s %s', productDetails.product.name, productDetails.stock_amount, __n(productDetails.stock_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + result.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
toastr.success(__t('Stock amount of %s is now %s %s', productDetails.product.name, productDetails.stock_amount, __n(productDetails.stock_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + result.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||||
|
|
||||||
if (addBarcode !== undefined)
|
$('#inventory-change-info').addClass('d-none');
|
||||||
{
|
$("#tare-weight-handling-info").addClass("d-none");
|
||||||
window.location.href = U('/inventory');
|
$("#new_amount").attr("min", "0");
|
||||||
}
|
$("#new_amount").attr("step", "1");
|
||||||
else
|
$("#new_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '0'));
|
||||||
{
|
$('#new_amount').val('');
|
||||||
$('#inventory-change-info').addClass('d-none');
|
$('#new_amount_qu_unit').text("");
|
||||||
$("#tare-weight-handling-info").addClass("d-none");
|
Grocy.Components.DateTimePicker.Clear();
|
||||||
$("#new_amount").attr("min", "0");
|
Grocy.Components.ProductPicker.SetValue('');
|
||||||
$("#new_amount").attr("step", "1");
|
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||||
$("#new_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '0'));
|
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||||
$('#new_amount').val('');
|
|
||||||
$('#new_amount_qu_unit').text("");
|
|
||||||
Grocy.Components.DateTimePicker.Clear();
|
|
||||||
Grocy.Components.ProductPicker.SetValue('');
|
|
||||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
|
||||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
|
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
|
||||||
function (result) { },
|
function(result)
|
||||||
|
{
|
||||||
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
|
window.history.replaceState({ }, document.title, U("/purchase"));
|
||||||
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("purchase-form");
|
Grocy.FrontendHelpers.EndUiBusy("purchase-form");
|
||||||
@@ -50,11 +55,7 @@
|
|||||||
|
|
||||||
var successMessage = __t('Added %s %s of %s to stock', result.amount, __n(result.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + result.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Added %s %s of %s to stock', result.amount, __n(result.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + result.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
if (addBarcode !== undefined)
|
if (GetUriParam("flow") === "shoppinglistitemtostock" && typeof GetUriParam("embedded") !== undefined)
|
||||||
{
|
|
||||||
window.location.href = U('/purchase');
|
|
||||||
}
|
|
||||||
else if (GetUriParam("flow") === "shoppinglistitemtostock" && typeof GetUriParam("embedded") !== undefined)
|
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("AfterItemAdded", GetUriParam("listitemid")), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("AfterItemAdded", GetUriParam("listitemid")), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||||
|
Reference in New Issue
Block a user