mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Revamped modal iframe dialog handling
This commit is contained in:
@@ -113,9 +113,6 @@ button.disabled {
|
||||
|
||||
iframe.embed-responsive {
|
||||
border: 0;
|
||||
width: 1px;
|
||||
min-width: 100%;
|
||||
min-height: 700px;
|
||||
}
|
||||
|
||||
/* Hide the default up/down arrow buttons for number inputs because we use our own buttons in numberpicker */
|
||||
@@ -278,6 +275,21 @@ a:not([href]) {
|
||||
z-index: 99998;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.form .modal-dialog {
|
||||
max-width: 650px;
|
||||
}
|
||||
|
||||
.table .modal-dialog {
|
||||
max-width: 90%;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
max-height: 100vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Third party component customizations - DataTables */
|
||||
.dataTable td {
|
||||
vertical-align: middle !important;
|
||||
|
@@ -538,28 +538,39 @@ if ($(".custom-file-label").length > 0)
|
||||
$("<style>").html('.custom-file-label::after { content: "' + __t("Select file") + '"; }').appendTo("head");
|
||||
}
|
||||
|
||||
ResizeResponsiveEmbeds = function(fillEntireViewport = false)
|
||||
ResizeResponsiveEmbeds = function()
|
||||
{
|
||||
if (!fillEntireViewport)
|
||||
$("iframe.embed-responsive").each(function()
|
||||
{
|
||||
var maxHeight = $("body").height() - $("#mainNav").outerHeight() - 62;
|
||||
}
|
||||
else
|
||||
{
|
||||
var maxHeight = $("body").height();
|
||||
}
|
||||
$(this).attr("height", $(this)[0].contentWindow.document.body.scrollHeight.toString() + "px");
|
||||
});
|
||||
|
||||
var maxHeight = $("body").height() - $("#mainNav").outerHeight() - 62;
|
||||
if ($("body").hasClass("fullscreen-card"))
|
||||
{
|
||||
maxHeight = $("body").height();
|
||||
}
|
||||
$("embed.embed-responsive").attr("height", maxHeight.toString() + "px");
|
||||
}
|
||||
$(window).on('resize', function()
|
||||
$(window).on("resize", function()
|
||||
{
|
||||
ResizeResponsiveEmbeds($("body").hasClass("fullscreen-card"));
|
||||
ResizeResponsiveEmbeds();
|
||||
});
|
||||
|
||||
if (GetUriParam("embedded"))
|
||||
$("iframe").on("load", function()
|
||||
{
|
||||
window.parent.iframeResize({ "checkOrigin": false, "warningTimeout": 0, "license": "GPLv3" }, "iframe.embed-responsive");
|
||||
}
|
||||
ResizeResponsiveEmbeds();
|
||||
});
|
||||
$(document).on("shown.bs.modal", function(e)
|
||||
{
|
||||
ResizeResponsiveEmbeds();
|
||||
});
|
||||
$("body").children().each(function(index, child)
|
||||
{
|
||||
new ResizeObserver(function()
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ResizeResponsiveEmbeds"), Grocy.BaseUrl);
|
||||
}).observe(child);
|
||||
});
|
||||
|
||||
function WindowMessageBag(message, payload = null)
|
||||
{
|
||||
@@ -696,13 +707,34 @@ $(window).on("message", function(e)
|
||||
{
|
||||
var data = e.originalEvent.data;
|
||||
|
||||
if (data.Message === "ShowSuccessMessage")
|
||||
if (data.Message == "ShowSuccessMessage")
|
||||
{
|
||||
toastr.success(data.Payload);
|
||||
}
|
||||
else if (data.Message === "CloseAllModals")
|
||||
else if (data.Message == "CloseLastModal")
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
else if (data.Message == "ResizeResponsiveEmbeds")
|
||||
{
|
||||
ResizeResponsiveEmbeds();
|
||||
}
|
||||
else if (data.Message == "IframeModal")
|
||||
{
|
||||
IframeModal(data.Payload.Link, data.Payload.DialogType);
|
||||
}
|
||||
else if (data.Message == "Reload")
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else if (data.Message == "BroadcastMessage")
|
||||
{
|
||||
// data.Payload is the original WindowMessageBag => distribute to this window + all child iframes
|
||||
window.postMessage(data.Payload, Grocy.BaseUrl);
|
||||
$("iframe.embed-responsive").each(function()
|
||||
{
|
||||
$(this)[0].contentWindow.postMessage(data.Payload, Grocy.BaseUrl);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -710,25 +742,46 @@ $(document).on("click", ".show-as-dialog-link", function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var link = $(e.currentTarget).attr("href");
|
||||
var element = $(e.currentTarget);
|
||||
var link = element.attr("href");
|
||||
|
||||
var dialogType = "form";
|
||||
if (element.hasAttr("data-dialog-type"))
|
||||
{
|
||||
dialogType = element.attr("data-dialog-type")
|
||||
}
|
||||
|
||||
if (window.top != window.self)
|
||||
{
|
||||
window.top.postMessage(WindowMessageBag("IframeModal", { "Link": link, "DialogType": dialogType }), Grocy.BaseUrl);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IframeModal(link, dialogType);
|
||||
}
|
||||
});
|
||||
|
||||
function IframeModal(link, dialogClass = "form")
|
||||
{
|
||||
bootbox.dialog({
|
||||
message: '<iframe class="embed-responsive" src="' + link + '"></iframe>',
|
||||
size: 'large',
|
||||
backdrop: true,
|
||||
closeButton: false,
|
||||
className: dialogClass,
|
||||
buttons: {
|
||||
cancel: {
|
||||
label: __t('Close'),
|
||||
className: 'btn-secondary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Init Bootstrap tooltips
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
@@ -780,16 +833,6 @@ $('.dropdown-item').has('.form-check input[type=checkbox]').on('click', function
|
||||
}
|
||||
});
|
||||
|
||||
$(window).on("message", function(e)
|
||||
{
|
||||
var data = e.originalEvent.data;
|
||||
|
||||
if (data.Message === "Reload")
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-toggle="tooltip"][data-html="true"]').on("shown.bs.tooltip", function()
|
||||
{
|
||||
RefreshLocaleNumberDisplay(".tooltip");
|
||||
|
@@ -320,7 +320,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
|
||||
// Delete state settings
|
||||
dataTable.state.clear();
|
||||
}
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -330,7 +330,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
|
||||
className: 'btn-primary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -124,7 +124,7 @@ Grocy.Components.BarcodeScanner.StartScanning = function()
|
||||
window.localStorage.removeItem("cameraId");
|
||||
setTimeout(function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ Grocy.Components.BarcodeScanner.StopScanning = function()
|
||||
Grocy.Components.BarcodeScanner.DecodedCodesCount = 0;
|
||||
Grocy.Components.BarcodeScanner.DecodedCodesErrorCount = 0;
|
||||
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
|
||||
Grocy.Components.BarcodeScanner.TorchOn = function(track)
|
||||
|
@@ -91,9 +91,9 @@
|
||||
|
||||
if (GetUriParam("embedded") !== undefined)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", jsonForm.product_id)), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -159,7 +159,7 @@ $(".selectedEquipmentInstructionManualToggleFullscreenButton").on('click', funct
|
||||
card.find(".card-header").toggleClass("fixed-top");
|
||||
card.find(".card-body").toggleClass("mt-5");
|
||||
$("body").toggleClass("fullscreen-card");
|
||||
ResizeResponsiveEmbeds(true);
|
||||
ResizeResponsiveEmbeds();
|
||||
});
|
||||
|
||||
$("#selectedEquipmentDescriptionToggleFullscreenButton").on('click', function(e)
|
||||
|
@@ -130,9 +130,9 @@ $('#save-inventory-button').on('click', function(e)
|
||||
{
|
||||
Grocy.Components.UserfieldsForm.Save(function()
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", jsonForm.product_id)), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
});
|
||||
|
||||
}
|
||||
|
@@ -937,7 +937,7 @@ $(document).on("click", ".display-recipe-button", function(e)
|
||||
className: 'btn-secondary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,8 +27,8 @@
|
||||
Grocy.EditObjectId = result.created_object_id;
|
||||
Grocy.Components.UserfieldsForm.Save()
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -43,8 +43,8 @@
|
||||
Grocy.Api.Put('objects/product_barcodes/' + Grocy.EditObjectId, jsonData,
|
||||
function(result)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -23,7 +23,7 @@
|
||||
Grocy.EditObjectId = result.created_object_id;
|
||||
Grocy.Components.UserfieldsForm.Save(function()
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/productgroups"));
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
@@ -40,7 +40,7 @@
|
||||
{
|
||||
Grocy.Components.UserfieldsForm.Save(function()
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/productgroups"));
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
|
@@ -65,7 +65,7 @@ $(window).on("message", function(e)
|
||||
{
|
||||
var data = e.originalEvent.data;
|
||||
|
||||
if (data.Message === "CloseAllModals")
|
||||
if (data.Message === "CloseLastModal")
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
|
@@ -174,11 +174,11 @@ $('#save-purchase-button').on('click', function(e)
|
||||
{
|
||||
Grocy.Components.UserfieldsForm.Save(function()
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", jsonForm.product_id)), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("AfterItemAdded", GetUriParam("listitemid")), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -627,7 +627,7 @@ function UndoStockBooking(bookingId)
|
||||
Grocy.Api.Get('stock/bookings/' + bookingId.toString(),
|
||||
function(result)
|
||||
{
|
||||
window.postMessage(WindowMessageBag("ProductChanged", result.product_id), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", result.product_id)), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -652,7 +652,7 @@ function UndoStockTransaction(transactionId)
|
||||
Grocy.Api.Get('stock/transactions/' + transactionId.toString(),
|
||||
function(result)
|
||||
{
|
||||
window.postMessage(WindowMessageBag("ProductChanged", result[0].product_id), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", result[0].product_id)), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -37,8 +37,8 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -69,8 +69,8 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@@ -229,7 +229,7 @@ $(document).on('click', '.recipe-pos-edit-button', function(e)
|
||||
className: 'btn-secondary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ $("#recipe-pos-add-button").on("click", function(e)
|
||||
className: 'btn-secondary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ $('#save-recipe-pos-button').on('click', function(e)
|
||||
function(result)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("IngredientsChanged"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ $('#save-recipe-pos-button').on('click', function(e)
|
||||
function(result)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("IngredientsChanged"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -301,7 +301,7 @@ recipesTables.on('select', function(e, dt, type, indexes)
|
||||
className: 'btn-secondary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ $(".recipe-gallery-item").on("click", function(e)
|
||||
className: 'btn-secondary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -431,7 +431,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||
className: 'btn-secondary',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
}
|
||||
},
|
||||
printtp: {
|
||||
@@ -439,7 +439,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||
className: 'btn-secondary',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
var printHeader = $("#print-show-header").prop("checked");
|
||||
var thermalPrintDialog = bootbox.dialog({
|
||||
title: __t('Printing'),
|
||||
@@ -451,7 +451,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||
Grocy.Api.Get('print/shoppinglist/thermal?list=' + $("#selected-shopping-list").val() + '&printHeader=' + printHeader,
|
||||
function(result)
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -481,7 +481,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||
className: 'btn-primary responsive-button',
|
||||
callback: function()
|
||||
{
|
||||
bootbox.hideAll();
|
||||
$(".modal").last().modal("hide");
|
||||
$('.modal-backdrop').remove();
|
||||
$(".print-timestamp").text(moment().format("l LT"));
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", result.created_object_id), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
@@ -44,7 +44,7 @@
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", Grocy.EditObjectId), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -70,7 +70,7 @@ $('#save-shoppinglist-button').on('click', function(e)
|
||||
}
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ $('#save-shoppinglist-button').on('click', function(e)
|
||||
}
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -122,7 +122,7 @@ $('#save-shoppinglist-button').on('click', function(e)
|
||||
else
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -151,9 +151,13 @@ $('#save-shoppinglist-button').on('click', function(e)
|
||||
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
||||
function(productDetails)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", displayAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(displayAmount, $("#qu_id option:selected").text(), $("#qu_id option:selected").attr("data-qu-name-plural"), true), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||
if (GetUriParam("product") !== undefined)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", displayAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(displayAmount, $("#qu_id option:selected").text(), $("#qu_id option:selected").attr("data-qu-name-plural"), true), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||
}
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -164,7 +168,7 @@ $('#save-shoppinglist-button').on('click', function(e)
|
||||
else
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -84,11 +84,12 @@ $(document).on('click', '.stock-consume-button', function(e)
|
||||
{
|
||||
toastMessage += "<br>(" + __t("Spoiled") + ")";
|
||||
}
|
||||
toastMessage += '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse[0].id + ',' + stockRowId + ')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
toastMessage += '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse[0].id + ',' + stockRowId + ', ' + bookingResponse[0].product_id + ')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
|
||||
Grocy.FrontendHelpers.EndUiBusy();
|
||||
RefreshStockEntryRow(stockRowId);
|
||||
toastr.success(toastMessage);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", productId)), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -127,7 +128,7 @@ $(document).on('click', '.product-open-button', function(e)
|
||||
{
|
||||
button.addClass("disabled");
|
||||
Grocy.FrontendHelpers.EndUiBusy();
|
||||
toastr.success(__t('Marked %1$s of %2$s as opened', openAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(openAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse[0].id + ',' + stockRowId + ')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
toastr.success(__t('Marked %1$s of %2$s as opened', openAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(openAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse[0].id + ',' + stockRowId + ', ' + productId + ')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
|
||||
if (result.product.move_on_open == 1 && result.default_consume_location != null)
|
||||
{
|
||||
@@ -135,6 +136,7 @@ $(document).on('click', '.product-open-button', function(e)
|
||||
}
|
||||
|
||||
RefreshStockEntryRow(stockRowId);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", productId)), Grocy.BaseUrl);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -309,20 +311,25 @@ $(window).on("message", function(e)
|
||||
{
|
||||
var data = e.originalEvent.data;
|
||||
|
||||
if (data.Message === "StockEntryChanged")
|
||||
if (data.Message == "StockEntryChanged")
|
||||
{
|
||||
RefreshStockEntryRow(data.Payload);
|
||||
}
|
||||
else if (data.Message == "ProductChanged")
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||
|
||||
function UndoStockBookingEntry(bookingId, stockRowId)
|
||||
function UndoStockBookingEntry(bookingId, stockRowId, productId)
|
||||
{
|
||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||
function(result)
|
||||
{
|
||||
window.postMessage(WindowMessageBag("StockEntryChanged", stockRowId), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("StockEntryChanged", stockRowId)), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", productId)), Grocy.BaseUrl);
|
||||
toastr.success(__t("Booking successfully undone"));
|
||||
},
|
||||
function(xhr)
|
||||
|
@@ -62,10 +62,11 @@
|
||||
{
|
||||
var successMessage = __t('Stock entry successfully updated') + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(\'' + result.id + '\',\'' + Grocy.EditObjectRowId + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
|
||||
window.parent.postMessage(WindowMessageBag("StockEntryChanged", Grocy.EditObjectRowId), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("StockEntryChanged", Grocy.EditObjectRowId)), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", Grocy.EditObjectProductId)), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
|
@@ -70,9 +70,9 @@
|
||||
|
||||
if (GetUriParam("embedded") !== undefined)
|
||||
{
|
||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||
window.top.postMessage(WindowMessageBag("BroadcastMessage", WindowMessageBag("ProductChanged", jsonForm.product_id)), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user