mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
fix stockdetail refresh rows after clicking undo
This commit is contained in:
parent
3cc5e31794
commit
40316314c7
|
|
@ -76,15 +76,15 @@ $(document).on('click', '.stock-consume-button', function(e)
|
|||
Grocy.Api.Get('stock/products/' + productId,
|
||||
function(result)
|
||||
{
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + bookingResponse.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse.id + ',' + stockRowId + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
if (wasSpoiled)
|
||||
{
|
||||
toastMessage += " (" + __t("Spoiled") + ")";
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.EndUiBusy();
|
||||
toastr.success(toastMessage);
|
||||
RefreshStockDetailRow(stockRowId);
|
||||
toastr.success(toastMessage);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
|
@ -301,3 +301,18 @@ $(window).on("message", function(e)
|
|||
RefreshStockDetailRow(data.Payload);
|
||||
}
|
||||
});
|
||||
|
||||
function UndoStockBookingEntry(bookingId, stockRowId)
|
||||
{
|
||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
||||
function(result)
|
||||
{
|
||||
window.postMessage(WindowMessageBag("StockDetailChanged", stockRowId), Grocy.BaseUrl);
|
||||
toastr.success(__t("Booking successfully undone"));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ $('#save-stockedit-button').on('click', function(e)
|
|||
Grocy.Api.Put("stock", jsonData,
|
||||
function(result)
|
||||
{
|
||||
var successMessage = __t('Stock entry successfully updated') + '<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('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>';
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("StockDetailChanged", stockRowId), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
|
|
@ -135,17 +135,3 @@ if (Grocy.Components.DateTimePicker)
|
|||
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
|
||||
});
|
||||
}
|
||||
|
||||
function UndoStockBooking(bookingId)
|
||||
{
|
||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
||||
function(result)
|
||||
{
|
||||
toastr.success(__t("Booking successfully undone"));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user