mirror of
https://github.com/grocy/grocy.git
synced 2025-08-21 04:43:32 +00:00
Squashed commit
- Only refresh contextual number/datetime info/formatting where needed (closes #513) - Also refresh correlated stock journal entries on undo (closes #471) - Prefill "New amount" with the current stock amount on the inventory page (closes #434) - Ensure that the location_id of the stock and stock_log tables is never empty after migration 95 (references #421) - Load initial values of the /stockedit form server side to improve loading performance (references #421) - Use more or less the same input ordering as on the purchase page for the /stockedit page (references #421) - Also display the "Compact view" button on the shopping list page when FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS is disabled (references #453) - Ensure that the currently active sidebar menu item is visible - Optimized sidebar menu item grouping/spacing - Properly order the API documentation route groups and put the "by-barcode" routes into a separate group - Updated dependencies - Pulled translations from Transifex - Prepared changelog for next release
This commit is contained in:
@@ -26,14 +26,12 @@
|
||||
|
||||
jsonData.open = $("#open").is(":checked");
|
||||
|
||||
var stockRowId = GetUriParam('stockRowId');
|
||||
|
||||
Grocy.Api.Put("stock/entry/" + stockRowId, jsonData,
|
||||
Grocy.Api.Put("stock/entry/" + Grocy.EditObjectId, jsonData,
|
||||
function(result)
|
||||
{
|
||||
var successMessage = __t('Stock entry successfully updated') + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(\'' + result.id + '\',\'' + stockRowId + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var successMessage = __t('Stock entry successfully updated') + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(\'' + result.id + '\',\'' + Grocy.EditObjectId + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("StockDetailChanged", stockRowId), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("StockDetailChanged", Grocy.EditObjectId), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
@@ -90,55 +88,45 @@ Grocy.Components.DateTimePicker2.GetInputElement().on('keypress', function(e)
|
||||
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
|
||||
});
|
||||
|
||||
var stockRowId = GetUriParam('stockRowId');
|
||||
Grocy.Api.Get("stock/entry/" + stockRowId,
|
||||
function (stockEntry)
|
||||
Grocy.Api.Get('stock/products/' + Grocy.EditObjectProductId,
|
||||
function(productDetails)
|
||||
{
|
||||
Grocy.Components.LocationPicker.SetId(stockEntry.location_id);
|
||||
$('#amount').val(stockEntry.amount);
|
||||
$('#price').val(stockEntry.price);
|
||||
$("#open").prop('checked', BoolVal(stockEntry.open));
|
||||
Grocy.Components.DateTimePicker.SetValue(stockEntry.best_before_date);
|
||||
Grocy.Components.DateTimePicker2.SetValue(stockEntry.purchased_date);
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_stock.name);
|
||||
|
||||
Grocy.Api.Get('stock/products/' + stockEntry.product_id,
|
||||
function (productDetails)
|
||||
{
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_stock.name);
|
||||
if (productDetails.product.allow_partial_units_in_stock == 1)
|
||||
{
|
||||
$("#amount").attr("min", "0.01");
|
||||
$("#amount").attr("step", "0.01");
|
||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', 0.01.toLocaleString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#amount").attr("min", "1");
|
||||
$("#amount").attr("step", "1");
|
||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', '1'));
|
||||
}
|
||||
|
||||
if (productDetails.product.allow_partial_units_in_stock == 1)
|
||||
{
|
||||
$("#amount").attr("min", "0.01");
|
||||
$("#amount").attr("step", "0.01");
|
||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', 0.01.toLocaleString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#amount").attr("min", "1");
|
||||
$("#amount").attr("step", "1");
|
||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', '1'));
|
||||
}
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
$("#amount").attr("min", productDetails.product.tare_weight);
|
||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', parseFloat(productDetails.product.tare_weight).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: 2 })));
|
||||
$("#tare-weight-handling-info").removeClass("d-none");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#tare-weight-handling-info").addClass("d-none");
|
||||
}
|
||||
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
$("#amount").attr("min", productDetails.product.tare_weight);
|
||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s', parseFloat(productDetails.product.tare_weight).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: 2 })));
|
||||
$("#tare-weight-handling-info").removeClass("d-none");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#tare-weight-handling-info").addClass("d-none");
|
||||
}
|
||||
|
||||
},
|
||||
function (xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
},
|
||||
function (xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
|
||||
$("#amount").on("focus", function(e)
|
||||
{
|
||||
$(this).select();
|
||||
});
|
||||
$("#amount").focus();
|
||||
Grocy.FrontendHelpers.ValidateForm("stockedit-form");
|
||||
|
Reference in New Issue
Block a user