From c8ebc1b5e220c0ed3e56386db45e0f7906d9e3c3 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 27 Nov 2024 15:14:02 +0100 Subject: [PATCH] updating publicInfo dinamycally --- .../Components/AuctionPublicViewComponent.cs | 2 - .../Content/Js/MgMessageHandler.js | 67 +++++++++++-------- .../Views/PublicInfo.cshtml | 48 ++++++++++--- 3 files changed, 76 insertions(+), 41 deletions(-) diff --git a/Nop.Plugin.Misc.AuctionPlugin/Components/AuctionPublicViewComponent.cs b/Nop.Plugin.Misc.AuctionPlugin/Components/AuctionPublicViewComponent.cs index 1981dad..62f095a 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Components/AuctionPublicViewComponent.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Components/AuctionPublicViewComponent.cs @@ -178,8 +178,6 @@ public class AuctionPublicViewComponent : NopViewComponent lastProductToAuction = null; } - - productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer); productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer); diff --git a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js index b1bcadd..98df791 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js +++ b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js @@ -9,7 +9,7 @@ if (!liveScreen) { toastr.info(`
${myObject.message}
`, myObject.title, { "closeButton": true, - "positionClass": "toast-top-right", + "positionClass": "toast-bottom-left", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, @@ -47,7 +47,7 @@ if (!liveScreen) { toastr.success(`

${myObject.currentPrice}

${myObject.productName}

`, "New bid arrived", { "closeButton": true, - "positionClass": "toast-top-right", + "positionClass": "toast-bottom-left", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, @@ -71,6 +71,7 @@ var productToAuctionDto = myObject.auctionDto.productToAuctionDtos[0]; var publicProductBidBox = document.getElementById("publicProductBidBox"); var liveScreen = document.getElementById("auctionProductLiveScreenBox"); + var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId); if (!liveScreen) { var messageTitle = ""; var messageText = ""; @@ -78,12 +79,12 @@ switch (productToAuctionDto.auctionStatus) { case AuctionStatus.None: messageTitle = `Item reset`; - messageText = `The bids on item with index ${myObject.auctionDto.productToAuctionDtos[0].SortIndex} has been resetted`; + messageText = `The bids on item with index ${productToAuctionDto.sortIndex} has been resetted`; messageColor = "#6c757d"; break; case AuctionStatus.Active: messageTitle = `Item activated`; - messageText = `The bids on item with index ${myObject.auctionDto.productToAuctionDtos[0].SortIndex} has been activated`; + messageText = `The bids on item with index ${productToAuctionDto.sortIndex} has been activated`; messageColor = "#4caf50"; break; case AuctionStatus.FirstWarning: @@ -118,7 +119,7 @@ toastr.success(`

${messageText}

`, messageTitle, { "closeButton": true, - "positionClass": "toast-top-right", + "positionClass": "toast-bottom-left", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, @@ -140,6 +141,14 @@ if (liveScreen) { reloadOnUpdate(); } + if (publicInfo) { + var functionName = "refreshPublicInfo" + productToAuctionDto.productId; + /*if (typeof window[functionName] === "function" + productToAuctionDto.productId) {*/ + window[functionName](myObject); // Dynamically call the function + //} else { + //console.error("Function " + functionName + " does not exist."); + //} + } // var publicProductBidBox = document.getElementById("publicProductBidBox"); // if (publicProductBidBox) @@ -147,32 +156,32 @@ // refreshPublicBidBox(myObject); // } }, - openItemMessage: function (data) { - var myObject = JSON.parse(data); - toastr.success(`

${myObject.nextBidPrice}

${myObject.productName}

`, "Item auction is OPENED!", { - "closeButton": true, - "positionClass": "toast-top-right", - "newestOnTop": true, - "progressBar": true, - "preventDuplicates": false, - "onclick": null, - "showDuration": "30000", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": animation, - "hideMethod": "fadeOut" - }); - $('.toast-success').css("background-color", "#4caf50"); + //openItemMessage: function (data) { + // var myObject = JSON.parse(data); + // toastr.success(`

${myObject.nextBidPrice}

${myObject.productName}

`, "Item auction is OPENED!", { + // "closeButton": true, + // "positionClass": "toast-top-right", + // "newestOnTop": true, + // "progressBar": true, + // "preventDuplicates": false, + // "onclick": null, + // "showDuration": "30000", + // "hideDuration": "1000", + // "timeOut": "5000", + // "extendedTimeOut": "1000", + // "showEasing": "swing", + // "hideEasing": "linear", + // "showMethod": animation, + // "hideMethod": "fadeOut" + // }); + // $('.toast-success').css("background-color", "#4caf50"); - var publicProductBidBox = document.getElementById("publicProductBidBox"); - if (publicProductBidBox) { - refreshPublicBidBox(myObject); - } + // var publicProductBidBox = document.getElementById("publicProductBidBox"); + // if (publicProductBidBox) { + // refreshPublicBidBox(myObject); + // } - }, + //}, // Add more handlers as needed default: function (data) { diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml index 51e9801..3bd4299 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml @@ -4,6 +4,7 @@