Javascript reorganization, public bidbox in list, handle ProductOverviewModel as well as ProductDetailModel...
This commit is contained in:
parent
ec55100b1d
commit
cebe224395
|
|
@ -101,7 +101,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(widgetZone);
|
ArgumentNullException.ThrowIfNull(widgetZone);
|
||||||
|
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop) || widgetZone.Equals(PublicWidgetZones.ProductBoxAddinfoAfter))
|
||||||
{
|
{
|
||||||
return typeof(AuctionPublicViewComponent);
|
return typeof(AuctionPublicViewComponent);
|
||||||
}
|
}
|
||||||
|
|
@ -130,6 +130,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
PublicWidgetZones.ProductDetailsOverviewTop,
|
PublicWidgetZones.ProductDetailsOverviewTop,
|
||||||
PublicWidgetZones.ProductBoxAddinfoBefore,
|
PublicWidgetZones.ProductBoxAddinfoBefore,
|
||||||
|
PublicWidgetZones.ProductBoxAddinfoAfter,
|
||||||
PublicWidgetZones.BodyStartHtmlTagAfter,
|
PublicWidgetZones.BodyStartHtmlTagAfter,
|
||||||
AdminWidgetZones.ProductDetailsButtons
|
AdminWidgetZones.ProductDetailsButtons
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,8 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
await _logger.InformationAsync("WidgetViewComponent called");
|
await _logger.InformationAsync("WidgetViewComponent called");
|
||||||
|
|
||||||
//ensure that widget is active and enabled
|
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||||
var currency = await _workContext.GetWorkingCurrencyAsync();
|
var currency = await _workContext.GetWorkingCurrencyAsync();
|
||||||
var store = await _storeContext.GetCurrentStoreAsync();
|
var store = await _storeContext.GetCurrentStoreAsync();
|
||||||
|
|
@ -97,6 +95,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
//var baseCurrency = allCurrencies.Where(x => x.Rate == 1);
|
//var baseCurrency = allCurrencies.Where(x => x.Rate == 1);
|
||||||
await _logger.InformationAsync($"WidgetViewComponent customer: {customer.Email}");
|
await _logger.InformationAsync($"WidgetViewComponent customer: {customer.Email}");
|
||||||
|
|
||||||
|
//ensure that widget is active and enabled
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
||||||
|
|
@ -105,9 +104,24 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
//if (!_auctionSettings.Enabled)
|
//if (!_auctionSettings.Enabled)
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
|
|
||||||
var productDetailsModel = (additionalData as ProductDetailsModel)!;
|
AuctionProductModel myWIPModel = new AuctionProductModel();
|
||||||
|
|
||||||
await _logger.InformationAsync($"WidgetViewComponent product: {productDetailsModel.Name}");
|
switch (additionalData)
|
||||||
|
{
|
||||||
|
case ProductOverviewModel productOverViewModel:
|
||||||
|
Console.WriteLine("The object is of type A.");
|
||||||
|
myWIPModel = await AuctionProductModel.CreateAsync(productOverViewModel, _myProductModelFactory, _productService);
|
||||||
|
break;
|
||||||
|
case ProductDetailsModel productDetailsModel:
|
||||||
|
Console.WriteLine("The object is of type B.");
|
||||||
|
myWIPModel = new AuctionProductModel(additionalData as ProductDetailsModel, _myProductModelFactory, _productService)!;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_logger.Error("The object is neither Overview nor DetailModel.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _logger.InformationAsync($"WidgetViewComponent product: {myWIPModel.Name}");
|
||||||
|
|
||||||
//if (productDetailsModel is null)
|
//if (productDetailsModel is null)
|
||||||
//{
|
//{
|
||||||
|
|
@ -116,7 +130,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
if (!(widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop) || widgetZone.Equals(PublicWidgetZones.ProductBoxAddinfoAfter)))
|
||||||
{
|
{
|
||||||
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
@ -126,7 +140,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
|
|
||||||
//is it under Auction?
|
//is it under Auction?
|
||||||
|
|
||||||
var productId = productDetailsModel.Id;
|
var productId = myWIPModel.Id;
|
||||||
|
|
||||||
//TODO: itt a ProductToAuctionMapping.Id-t kellene használni! - J.
|
//TODO: itt a ProductToAuctionMapping.Id-t kellene használni! - J.
|
||||||
var productToAuction = (await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId)).FirstOrDefault();
|
var productToAuction = (await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId)).FirstOrDefault();
|
||||||
|
|
@ -246,3 +260,4 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
|
using Nop.Services.Customers;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
using Nop.Web.Framework.Components;
|
using Nop.Web.Framework.Components;
|
||||||
using Nop.Web.Framework.Infrastructure;
|
using Nop.Web.Framework.Infrastructure;
|
||||||
|
|
@ -17,13 +19,13 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Components
|
||||||
{
|
{
|
||||||
|
|
||||||
[ViewComponent(Name = "LiveAnnouncement")]
|
[ViewComponent(Name = "LiveAnnouncement")]
|
||||||
public class LiveAnnouncementViewComponent(ILogger logger, ILockService lockService, IWorkContext workContext, IWidgetPluginManager widgetPluginManager, AuctionService auctionService, IHubContext<AuctionHub> auctionHubContext)
|
public class LiveAnnouncementViewComponent(ILogger logger, ILockService lockService, IWorkContext workContext, IWidgetPluginManager widgetPluginManager, AuctionService auctionService, IHubContext<AuctionHub> auctionHubContext, ICustomerService customerService)
|
||||||
: NopViewComponent
|
: NopViewComponent
|
||||||
{
|
{
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
var customer = await workContext.GetCurrentCustomerAsync();
|
var customer = await workContext.GetCurrentCustomerAsync();
|
||||||
|
var currency = await workContext.GetWorkingCurrencyAsync();
|
||||||
await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); Before lock; widgetZone: {widgetZone}", null, customer);
|
await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); Before lock; widgetZone: {widgetZone}", null, customer);
|
||||||
|
|
||||||
using (await lockService.SemaphoreSlim.UseWaitAsync())
|
using (await lockService.SemaphoreSlim.UseWaitAsync())
|
||||||
|
|
@ -84,7 +86,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Components
|
||||||
|
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml");
|
LiveAnnouncementViewModel myModel = new LiveAnnouncementViewModel();
|
||||||
|
|
||||||
|
myModel.CustomerId = customer.Id;
|
||||||
|
myModel.StoreId = customer.RegisteredInStoreId; //Temporary - A.
|
||||||
|
myModel.WorkingCurrency = currency;
|
||||||
|
myModel.IsAdmin = await customerService.IsAdminAsync(customer);
|
||||||
|
myModel.IsGuest = await customerService.IsGuestAsync(customer);
|
||||||
|
return View("~/Plugins/Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml", myModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,373 @@
|
||||||
|
window.sendBidMessage = function (ptaId, auctionId, bidPrice, productId) {
|
||||||
|
|
||||||
|
setBidButtonDisabledById("signalRBidButton" + ptaId, true);
|
||||||
|
|
||||||
|
var bidMessage = {
|
||||||
|
ProductAuctionMappingId: ptaId,
|
||||||
|
AuctionId: auctionId,
|
||||||
|
BidPrice: bidPrice,
|
||||||
|
ProductId: productId,
|
||||||
|
CustomerId: window.CustomerId
|
||||||
|
};
|
||||||
|
|
||||||
|
var content = JSON.stringify(bidMessage);
|
||||||
|
console.log("WTF " + content);
|
||||||
|
sendMessageToServer("BidRequestMessage", window.CustomerId, content);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
window.setBidButtonDisabledById = function (bidButtonElementId, disabled, updateDisabledState = true) {
|
||||||
|
if (!updateDisabledState) return;
|
||||||
|
|
||||||
|
setBidButtonDisabled(document.getElementById(bidButtonElementId), disabled, updateDisabledState);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.sendAuctionStatusChange = function (ptaId, auctionStatus) {
|
||||||
|
var customerId = window.CustomerId;
|
||||||
|
console.log("Send auctionstatus: " + customerId + ", " + ptaId);
|
||||||
|
// Create the message object
|
||||||
|
var auctionMessage = {
|
||||||
|
ProductToAuctionId: ptaId,
|
||||||
|
AuctionStatus: auctionStatus
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert to JSON and log
|
||||||
|
var content = JSON.stringify(auctionMessage);
|
||||||
|
console.log(content);
|
||||||
|
|
||||||
|
// Send the message via SignalR
|
||||||
|
sendMessageToServer("AuctionProductStatusRequest", customerId, content);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.refreshPublicBidBox = function (bidNotification, updateBidButtonDisabledState, ptaId) {
|
||||||
|
|
||||||
|
//now we are refreshing any widget that has this ptaId
|
||||||
|
|
||||||
|
var auctionDto = bidNotification.auctionDto;
|
||||||
|
var productToAuction = auctionDto.productToAuctionDtos[0];
|
||||||
|
/*var productAuctionMappingId = ptaId;*/
|
||||||
|
var winnerId = productToAuction.winnerCustomerId;
|
||||||
|
var isMyBid;
|
||||||
|
|
||||||
|
|
||||||
|
var widgetPriceElement = document.getElementById("price-value-" + productToAuction.ProductId);
|
||||||
|
var widgetPriceElementInList = $('.product-item[data-productid="' + productToAuction.ProductId + '"]');
|
||||||
|
var currency = window.WorkingCurrency;
|
||||||
|
console.log(currency);
|
||||||
|
|
||||||
|
var bidButtonElement = document.getElementById("signalRBidButton" + ptaId);
|
||||||
|
var storedBidPricePlaceholder = document.getElementById("bidPriceContainer" + ptaId);
|
||||||
|
var licitStepElement = document.getElementById("licitStepText" + ptaId);
|
||||||
|
var bidBox = document.getElementById("publicProductBidBox" + ptaId);
|
||||||
|
var bidBoxTitle = document.getElementById("bidBoxTitle" + ptaId);
|
||||||
|
console.log(bidNotification);
|
||||||
|
|
||||||
|
if (winnerId == window.CustomerId) {
|
||||||
|
isMyBid = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("ProductToAuctionId: " + ptaId);
|
||||||
|
|
||||||
|
//TODO: TESZT STATUS!!! - JTEST.
|
||||||
|
var status = productToAuction.auctionStatus;
|
||||||
|
//var status = AuctionStatus.TEST;
|
||||||
|
|
||||||
|
|
||||||
|
if (updateBidButtonDisabledState) {
|
||||||
|
setButtons(status, ptaId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (widgetPriceElement || widgetPriceElementInList) {
|
||||||
|
|
||||||
|
if (widgetPriceElement) {
|
||||||
|
/*if (productAuctionMappingId == ptaId) {*/
|
||||||
|
console.log("THIS IS FOR US! SORRY FOR SHOUTING");
|
||||||
|
if (currency.CurrencyCode == "EUR") {
|
||||||
|
widgetPriceElement.textContent = EURFormatter.format(bidNotification.currentPrice * window.WorkingCurrency.Rate); // Update the price
|
||||||
|
//licitStepElement.textContent = EURFormatter.format(bidNotification.nextStepAmount * window.WorkingCurrency.Rate);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
widgetPriceElement.textContent = HUFFormatter.format(bidNotification.currentPrice); // Update the price
|
||||||
|
//licitStepElement.textContent = HUFFormatter.format(bidNotification.nextStepAmount);
|
||||||
|
}
|
||||||
|
/*}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (productAuctionMappingId == ptaId) {*/
|
||||||
|
console.log("THIS IS FOR US! SORRY FOR SHOUTING");
|
||||||
|
if (currency.CurrencyCode == "EUR") {
|
||||||
|
//widgetPriceElement.textContent = EURFormatter.format(bidNotification.currentPrice * window.WorkingCurrency.Rate); // Update the price
|
||||||
|
licitStepElement.textContent = EURFormatter.format(bidNotification.nextStepAmount * window.WorkingCurrency.Rate);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//widgetPriceElement.textContent = HUFFormatter.format(bidNotification.currentPrice); // Update the price
|
||||||
|
licitStepElement.textContent = HUFFormatter.format(bidNotification.nextStepAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
storedBidPricePlaceholder.value = Number(bidNotification.nextBidPrice);
|
||||||
|
setBidButtonDisabled(bidButtonElement, !productToAuction.isActiveItem, updateBidButtonDisabledState);
|
||||||
|
|
||||||
|
var list;
|
||||||
|
if (isMyBid) {
|
||||||
|
console.log("This is my bid");
|
||||||
|
list = bidBox.classList;
|
||||||
|
list.add("bg-success");
|
||||||
|
list.remove("bg-primary");
|
||||||
|
|
||||||
|
bidButtonElement.textContent = window.LocalizationStrings.GoodJob;
|
||||||
|
bidBoxTitle.textContent = productToAuction.auctionStatus == AuctionStatus.Sold ? window.LocalizationStrings.YouWin : window.LocalizationStrings.YourBidLeading;
|
||||||
|
|
||||||
|
if (window.IsAdmin) {
|
||||||
|
console.log("I AM WEASEL!!! " + window.IsAdmin);
|
||||||
|
setBidButtonDisabled(bidButtonElement, !productToAuction.isActiveItem, updateBidButtonDisabledState);
|
||||||
|
} else {
|
||||||
|
console.log("I AM NOT WEASEL!!! " + window.IsAdmin);
|
||||||
|
setBidButtonDisabled(bidButtonElement, true, updateBidButtonDisabledState);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list = bidBox.classList;
|
||||||
|
list.add("bg-primary");
|
||||||
|
list.remove("bg-success");
|
||||||
|
bidBoxTitle.textContent = productToAuction.auctionStatus == AuctionStatus.Sold ? window.LocalizationStrings.Sold : window.LocalizationStrings.PlaceABid;
|
||||||
|
|
||||||
|
if (currency.CurrencyCode == "EUR") {
|
||||||
|
bidButtonElement.textContent = window.LocalizationStrings.BidButtonPrefix + EURFormatter.format(bidBoxPageViewModel.NextBidPriceInWorkingCurrency);
|
||||||
|
//bidButtonElement.textContent = EURFormatter.format(storedBidPricePlaceholder.value);
|
||||||
|
} else {
|
||||||
|
bidButtonElement.textContent = window.LocalizationStrings.BidButtonPrefix + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice);
|
||||||
|
//bidButtonElement.textContent = HUFFormatter.format(storedBidPricePlaceholder.value);
|
||||||
|
}
|
||||||
|
bidButtonElement.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`WidgetPrice updated to: ${bidNotification.currentPrice}`);
|
||||||
|
|
||||||
|
|
||||||
|
//} else {
|
||||||
|
// console.log("Not for this product");
|
||||||
|
//}
|
||||||
|
} else {
|
||||||
|
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setButtons(auctionStatus, ptaId) {
|
||||||
|
console.log("SetButtons called: " + auctionStatus);
|
||||||
|
|
||||||
|
// Button IDs and their default states for each AuctionStatus
|
||||||
|
//true = disabled
|
||||||
|
var buttonStates = {
|
||||||
|
[AuctionStatus.None]: {
|
||||||
|
signalRBidButton: true,
|
||||||
|
signalRFirstWarningButton: true,
|
||||||
|
signalRSecondWarningButton: true,
|
||||||
|
signalROpenItemButton: false,
|
||||||
|
signalRCloseItemButton: true,
|
||||||
|
signalRPauseItemButton: true,
|
||||||
|
signalRRevertBidButton: true,
|
||||||
|
signalRResetItemButton: true,
|
||||||
|
},
|
||||||
|
[AuctionStatus.Active]: {
|
||||||
|
signalRBidButton: false,
|
||||||
|
signalRFirstWarningButton: false,
|
||||||
|
signalRSecondWarningButton: true,
|
||||||
|
signalROpenItemButton: true,
|
||||||
|
signalRCloseItemButton: true,
|
||||||
|
signalRPauseItemButton: false,
|
||||||
|
signalRRevertBidButton: true,
|
||||||
|
signalRResetItemButton: true,
|
||||||
|
},
|
||||||
|
[AuctionStatus.FirstWarning]: {
|
||||||
|
signalRBidButton: false,
|
||||||
|
signalRFirstWarningButton: true,
|
||||||
|
signalRSecondWarningButton: false,
|
||||||
|
signalROpenItemButton: true,
|
||||||
|
signalRCloseItemButton: true,
|
||||||
|
signalRPauseItemButton: false,
|
||||||
|
signalRRevertBidButton: true,
|
||||||
|
signalRResetItemButton: true,
|
||||||
|
},
|
||||||
|
[AuctionStatus.SecondWarning]: {
|
||||||
|
signalRBidButton: false,
|
||||||
|
signalRFirstWarningButton: true,
|
||||||
|
signalRSecondWarningButton: true,
|
||||||
|
signalROpenItemButton: true,
|
||||||
|
signalRCloseItemButton: false,
|
||||||
|
signalRPauseItemButton: false,
|
||||||
|
signalRRevertBidButton: true,
|
||||||
|
signalRResetItemButton: true,
|
||||||
|
},
|
||||||
|
[AuctionStatus.Pause]: {
|
||||||
|
signalRBidButton: true,
|
||||||
|
signalRFirstWarningButton: true,
|
||||||
|
signalRSecondWarningButton: true,
|
||||||
|
signalROpenItemButton: false,
|
||||||
|
signalRCloseItemButton: true,
|
||||||
|
signalRPauseItemButton: true,
|
||||||
|
signalRRevertBidButton: false,
|
||||||
|
signalRResetItemButton: false,
|
||||||
|
},
|
||||||
|
[AuctionStatus.Sold]: {
|
||||||
|
signalRBidButton: true,
|
||||||
|
signalRFirstWarningButton: true,
|
||||||
|
signalRSecondWarningButton: true,
|
||||||
|
signalROpenItemButton: true,
|
||||||
|
signalRCloseItemButton: true,
|
||||||
|
signalRPauseItemButton: true,
|
||||||
|
signalRRevertBidButton: true,
|
||||||
|
signalRResetItemButton: true,
|
||||||
|
},
|
||||||
|
[AuctionStatus.NotSold]: {
|
||||||
|
signalRBidButton: true,
|
||||||
|
signalRFirstWarningButton: true,
|
||||||
|
signalRSecondWarningButton: true,
|
||||||
|
signalROpenItemButton: true,
|
||||||
|
signalRCloseItemButton: true,
|
||||||
|
signalRPauseItemButton: true,
|
||||||
|
signalRRevertBidButton: true,
|
||||||
|
signalRResetItemButton: true,
|
||||||
|
},
|
||||||
|
[AuctionStatus.TEST]: {
|
||||||
|
signalRBidButton: false,
|
||||||
|
signalRFirstWarningButton: false,
|
||||||
|
signalRSecondWarningButton: false,
|
||||||
|
signalROpenItemButton: false,
|
||||||
|
signalRCloseItemButton: false,
|
||||||
|
signalRPauseItemButton: false,
|
||||||
|
signalRRevertBidButton: false,
|
||||||
|
signalRResetItemButton: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get the states for the given auctionStatus
|
||||||
|
var states = buttonStates[auctionStatus];
|
||||||
|
if (!states) {
|
||||||
|
console.error("Unknown AuctionStatus: ", auctionStatus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply the states to each button
|
||||||
|
Object.keys(states).forEach((buttonId) => {
|
||||||
|
var button = document.getElementById(buttonId + ptaId);
|
||||||
|
if (button) {
|
||||||
|
button.disabled = states[buttonId];
|
||||||
|
button.hidden = states[buttonId];
|
||||||
|
} else {
|
||||||
|
console.warn(`Button with ID ${buttonId} not found.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function handleAuctionUpdate(auctionStatusNotification, myPtaId) {
|
||||||
|
var ids = auctionStatusNotification.auctionDto.productToAuctionDtos.map(pta => pta.id);
|
||||||
|
ids.forEach(ptaId => {
|
||||||
|
console.log(ptaId);
|
||||||
|
var productToAuctionDtos = auctionStatusNotification.auctionDto.productToAuctionDtos;
|
||||||
|
|
||||||
|
// Find the object with the matching Id
|
||||||
|
var matchingDto = productToAuctionDtos.find(pta => pta.id === ptaId);
|
||||||
|
|
||||||
|
if (matchingDto) {
|
||||||
|
console.log('Matching ProductToAuctionDto:', matchingDto);
|
||||||
|
UpdateBox(ptaId, matchingDto.productId, auctionStatusNotification.auctionDto, matchingDto);
|
||||||
|
} else {
|
||||||
|
console.log(`No ProductToAuctionDto found with Id: ${ptaId}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function UpdateBox(ptaId, productId, auctionDto, ptaDto) {
|
||||||
|
var widgetPriceElement = document.getElementById("price-value-" + productId);
|
||||||
|
var widgetPriceElementInList = $('.product-item[data-productid="' + productId + '"]');
|
||||||
|
var bidButtonElement = document.getElementById("signalRBidButton" + ptaId);
|
||||||
|
var licitStepElement = document.getElementById("licitStepText" + ptaId);
|
||||||
|
var bidBoxTitle = document.getElementById("bidBoxTitle" + ptaId);
|
||||||
|
|
||||||
|
var productAuctionMappingId = ptaId;
|
||||||
|
let isMyBid = false;
|
||||||
|
|
||||||
|
//TODO: TESZT STATUS!!! - JTEST.
|
||||||
|
let itemStatus = ptaDto.auctionStatus;
|
||||||
|
//var itemStatus = AuctionStatus.TEST;
|
||||||
|
let winnerId = ptaDto.winnerCustomerId;
|
||||||
|
if (winnerId == window.CustomerId) {
|
||||||
|
isMyBid = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log("handle auction update called" + productAuctionMappingId);
|
||||||
|
console.log("auction status:" + itemStatus);
|
||||||
|
if (widgetPriceElement || widgetPriceElementInList) {
|
||||||
|
|
||||||
|
/*if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {*/
|
||||||
|
console.log("THIS IS FOR US! SORRY FOR SHOUTING");
|
||||||
|
switch (itemStatus) {
|
||||||
|
case AuctionStatus.None:
|
||||||
|
location.reload();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AuctionStatus.Active:
|
||||||
|
if (isMyBid) {
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.YourBidLeading;
|
||||||
|
} else {
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.PlaceABid;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AuctionStatus.Pause:
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.AuctionPaused;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AuctionStatus.FirstWarning:
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.FirstWarning;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AuctionStatus.SecondWarning:
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.SecondWarning;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AuctionStatus.Sold:
|
||||||
|
if (isMyBid) {
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.YouWin;
|
||||||
|
} else {
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.ItemClosed;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AuctionStatus.NotSold:
|
||||||
|
bidBoxTitle.textContent = window.LocalizationStrings.ItemClosed;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.warn("Unknown AuctionStatus: ", itemStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*console.log(`Status updated to: ${auctionStatusNotification.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`);*/
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
//else {
|
||||||
|
// console.log("Not for this product");
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
||||||
|
}
|
||||||
|
setButtons(itemStatus, ptaId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
window.RequestCount = 0;
|
window.RequestCount = 0;
|
||||||
window.ConnectionId = "";
|
window.ConnectionId = "";
|
||||||
|
/*window.CustomerId = 0;*/
|
||||||
|
/*window.StoreId = 0;*/
|
||||||
|
/*window.WorkingCurrency;*/
|
||||||
|
/*window.IsAdmin = false;*/
|
||||||
|
/*window.IsGuest = false;*/
|
||||||
|
|
||||||
// AuctionStatus Enum
|
// AuctionStatus Enum
|
||||||
window.AuctionStatus = Object.freeze({
|
window.AuctionStatus = Object.freeze({
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
//var productAuctionMappingId = productToAuctionDto.id;
|
//var productAuctionMappingId = productToAuctionDto.id;
|
||||||
//console.log(productAuctionMappingId);
|
//console.log(productAuctionMappingId);
|
||||||
|
|
||||||
var publicProductBidBox = document.getElementById("publicProductBidBox");
|
var publicProductBidBox = document.getElementById("publicProductBidBox" + productToAuctionDto.id);
|
||||||
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
||||||
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
console.log("isMyRequest: " + isMyRequest + "; lastRequestId: " + lastRequestId + "; messageWrapper.RequestId: " + messageWrapper.requestId);
|
console.log("isMyRequest: " + isMyRequest + "; lastRequestId: " + lastRequestId + "; messageWrapper.RequestId: " + messageWrapper.requestId);
|
||||||
|
|
||||||
refreshPublicBidBox(bidNotification, isMyRequest);
|
refreshPublicBidBox(bidNotification, isMyRequest, productToAuctionDto.id);
|
||||||
}
|
}
|
||||||
if (publicInfo) {
|
if (publicInfo) {
|
||||||
var functionName = "refreshPublicInfo" + productToAuctionDto.productId;
|
var functionName = "refreshPublicInfo" + productToAuctionDto.productId;
|
||||||
|
|
@ -92,7 +92,10 @@
|
||||||
|
|
||||||
var auctionDto = auctionStatusNotification.auctionDto;
|
var auctionDto = auctionStatusNotification.auctionDto;
|
||||||
var productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
var productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
||||||
var publicProductBidBox = document.getElementById("publicProductBidBox");
|
//get the list of pta? should be 1
|
||||||
|
console.log("PtaId: "+productToAuctionDto.id);
|
||||||
|
|
||||||
|
var publicProductBidBox = document.getElementById("publicProductBidBox" + productToAuctionDto.id);
|
||||||
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
||||||
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
||||||
|
|
||||||
|
|
@ -163,7 +166,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicProductBidBox) {
|
if (publicProductBidBox) {
|
||||||
handleAuctionUpdate(auctionStatusNotification);
|
handleAuctionUpdate(auctionStatusNotification, productToAuctionDto.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveScreen) {
|
if (liveScreen) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
using Nop.Services.Catalog;
|
||||||
|
using Nop.Web.Models.Catalog;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
{
|
||||||
|
public record AuctionProductModel : ProductDetailsModel
|
||||||
|
{
|
||||||
|
protected readonly MyProductModelFactory _factory;
|
||||||
|
protected readonly IProductService _productService;
|
||||||
|
|
||||||
|
public AuctionProductModel(){}
|
||||||
|
|
||||||
|
public AuctionProductModel(ProductDetailsModel dModel, MyProductModelFactory factory, IProductService productService)
|
||||||
|
: base(dModel)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
_productService = productService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<AuctionProductModel> CreateAsync(
|
||||||
|
ProductOverviewModel oModel,
|
||||||
|
MyProductModelFactory factory,
|
||||||
|
IProductService productService)
|
||||||
|
{
|
||||||
|
|
||||||
|
var product = await productService.GetProductByIdAsync(oModel.Id);
|
||||||
|
var detailsModel = await factory.PrepareProductDetailsModelAsync(product);
|
||||||
|
|
||||||
|
return new AuctionProductModel(detailsModel, factory, productService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Nop.Core.Domain.Directory;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
using Nop.Web.Framework.Models;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
{
|
||||||
|
public record LiveAnnouncementViewModel : BaseNopModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
|
public int StoreId { get; set; }
|
||||||
|
|
||||||
|
public Currency WorkingCurrency { get; set; }
|
||||||
|
|
||||||
|
public bool IsAdmin { get; set; }
|
||||||
|
|
||||||
|
public bool IsGuest { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -140,6 +140,9 @@
|
||||||
<None Update="Content\Images\wallpaper.jpg">
|
<None Update="Content\Images\wallpaper.jpg">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Content\Js\Auction.js">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Content\Js\MgMessageHandler.js">
|
<None Update="Content\Js\MgMessageHandler.js">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
@using Nop.Web.Framework;
|
@using Nop.Web.Framework;
|
||||||
@using Nop.Web.Framework.UI;
|
@using Nop.Web.Framework.UI;
|
||||||
@using Nop.Services.Configuration;
|
@using Nop.Services.Configuration;
|
||||||
|
@model LiveAnnouncementViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
// NopHtml.AddScriptParts(ResourceLocation.Footer, "https://cdn.datatables.net/scroller/2.4.3/js/scroller.dataTables.js");
|
// NopHtml.AddScriptParts(ResourceLocation.Footer, "https://cdn.datatables.net/scroller/2.4.3/js/scroller.dataTables.js");
|
||||||
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/MgMessageHandler.js");
|
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/MgMessageHandler.js");
|
||||||
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js");
|
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js");
|
||||||
|
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/Auction.js");
|
||||||
NopHtml.AddCssFileParts("~/Plugins/Misc.AuctionPlugin/Content/Css/toastr.min.css");
|
NopHtml.AddCssFileParts("~/Plugins/Misc.AuctionPlugin/Content/Css/toastr.min.css");
|
||||||
NopHtml.AddCssFileParts("https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css");
|
NopHtml.AddCssFileParts("https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css");
|
||||||
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/toastr.js");
|
NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/toastr.js");
|
||||||
|
|
@ -30,3 +32,49 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
window.LocalizationStrings = {
|
||||||
|
YourBidLeading: "@T("Plugins.Misc.AuctionPlugin.YourBidLeading")",
|
||||||
|
PlaceABid: "@T("Plugins.Misc.AuctionPlugin.PlaceABid")",
|
||||||
|
AuctionPaused: "@T("Plugins.Misc.AuctionPlugin.AuctionPaused")",
|
||||||
|
FirstWarning: "@T("Plugins.Misc.AuctionPlugin.FirstWarning")",
|
||||||
|
SecondWarning: "@T("Plugins.Misc.AuctionPlugin.SecondWarning")",
|
||||||
|
YouWin: "@T("Plugins.Misc.AuctionPlugin.YouWin")",
|
||||||
|
ItemClosed: "@T("Plugins.Misc.AuctionPlugin.ItemClosed")",
|
||||||
|
GoodJob: "@T("Plugins.Misc.AuctionPlugin.GoodJob")",
|
||||||
|
YouWin: "@T("Plugins.Misc.AuctionPlugin.YouWin")",
|
||||||
|
YourBidLeading: "@T("Plugins.Misc.AuctionPlugin.YourBidLeading")",
|
||||||
|
Sold: "@T("Plugins.Misc.AuctionPlugin.Sold")",
|
||||||
|
BidButtonPrefix: "@T("Plugins.Misc.AuctionPlugin.BidButtonPrefix")"
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var liveAnnouncementViewModel;
|
||||||
|
|
||||||
|
$(window).load(function () {
|
||||||
|
try {
|
||||||
|
// Deserialize the Razor model into JavaScript
|
||||||
|
liveAnnouncementViewModel = @Html.Raw(Json.Serialize(Model));
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e); // Logs any error during deserialization
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure liveAnnouncementViewModel is defined before accessing its properties
|
||||||
|
if (liveAnnouncementViewModel) {
|
||||||
|
console.log("liveAnnouncementViewModel.CustomerId: " + liveAnnouncementViewModel.CustomerId);
|
||||||
|
|
||||||
|
// Set global variables
|
||||||
|
window.CustomerId = liveAnnouncementViewModel.CustomerId;
|
||||||
|
window.StoreId = liveAnnouncementViewModel.StoreId;
|
||||||
|
window.WorkingCurrency = liveAnnouncementViewModel.WorkingCurrency;
|
||||||
|
window.IsAdmin = liveAnnouncementViewModel.IsAdmin;
|
||||||
|
window.IsGuest = liveAnnouncementViewModel.IsGuest;
|
||||||
|
|
||||||
|
console.log("Window.CustomerId: " + window.CustomerId + ", " + "window.StoreId: " + window.StoreId + "window.isAdmin: " + window.IsAdmin);
|
||||||
|
} else {
|
||||||
|
console.log("liveAnnouncementViewModel is undefined or null.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -7,668 +7,338 @@
|
||||||
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.old-product-price {
|
.old-product-price {
|
||||||
text-decoration: unset !important;
|
text-decoration: unset !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
if (!Model.IsGuest)
|
if (!Model.IsGuest)
|
||||||
{
|
{
|
||||||
if (Model.FirstProductToAuction != null)
|
if (Model.FirstProductToAuction != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
var bgClass = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId ? "bg-success" : "bg-primary";
|
var bgClass = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId ? "bg-success" : "bg-primary";
|
||||||
var bidButtonActive = Model.IsItemActive && (Model.FirstProductToAuction.WinnerCustomerId != Model.CustomerId || Model.IsAdmin);
|
var bidButtonActive = Model.IsItemActive && (Model.FirstProductToAuction.WinnerCustomerId != Model.CustomerId || Model.IsAdmin);
|
||||||
var auctionStatus = Model.FirstProductToAuction.AuctionStatus;
|
var auctionStatus = Model.FirstProductToAuction.AuctionStatus;
|
||||||
var lastBidIsMine = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId;
|
var lastBidIsMine = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId;
|
||||||
|
|
||||||
|
|
||||||
var title = auctionStatus switch
|
var title = auctionStatus switch
|
||||||
{
|
{
|
||||||
AuctionStatus.Sold => lastBidIsMine ? @T("Plugins.Misc.AuctionPlugin.YouWin") : @T("Plugins.Misc.AuctionPlugin.Sold"),
|
AuctionStatus.Sold => lastBidIsMine ? @T("Plugins.Misc.AuctionPlugin.YouWin") : @T("Plugins.Misc.AuctionPlugin.Sold"),
|
||||||
AuctionStatus.NotSold => @T("Plugins.Misc.AuctionPlugin.Finished"),
|
AuctionStatus.NotSold => @T("Plugins.Misc.AuctionPlugin.Finished"),
|
||||||
_ => lastBidIsMine ? @T("Plugins.Misc.AuctionPlugin.YourBidLeading") : @T("Plugins.Misc.AuctionPlugin.PlaceABid")
|
_ => lastBidIsMine ? @T("Plugins.Misc.AuctionPlugin.YourBidLeading") : @T("Plugins.Misc.AuctionPlugin.PlaceABid")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (Model.WidgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
||||||
|
{
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between" id="otherAuctionItems">
|
||||||
|
<a href="@(string.IsNullOrEmpty(Model.LastProductUrl) ? "#" : Model.LastProductUrl)" @(string.IsNullOrEmpty(Model.LastProductUrl) ? "disabled" : string.Empty)>
|
||||||
|
<div class="card mb-3" style="max-width: 540px;">
|
||||||
|
<div class="row g-0">
|
||||||
|
@*<div class="col-md-4">
|
||||||
|
<img src="@(string.IsNullOrEmpty(Model.LastProductImageUrl) ? "https://placehold.co/400" : Model.LastProductImageUrl)" class="img-fluid rounded-start" alt="...">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">*@
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">@(string.IsNullOrEmpty(Model.LastProductUrl) ? @T("Plugins.Misc.AuctionPlugin.StartOfList") : @T("Plugins.Misc.AuctionPlugin.BackToLast"))</h5>
|
||||||
|
<p class="card-text">@(string.IsNullOrEmpty(Model.LastProductName) ? "---" : Model.LastProductName)</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="@(string.IsNullOrEmpty(Model.NextProductUrl) ? "#" : Model.NextProductUrl)" @(string.IsNullOrEmpty(Model.NextProductUrl) ? "disabled" : string.Empty)>
|
||||||
|
<div class="card mb-3" style="max-width: 540px;">
|
||||||
|
<div class="row g-0">
|
||||||
|
@*<div class="col-md-4">
|
||||||
|
<img src="@(string.IsNullOrEmpty(Model.NextProductImageUrl) ? "https://placehold.co/400" : Model.NextProductImageUrl)" class="img-fluid rounded-start" alt="...">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">*@
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">@(string.IsNullOrEmpty(Model.NextProductUrl) ? @T("Plugins.Misc.AuctionPlugin.EndOfList") : @T("Plugins.Misc.AuctionPlugin.ComingUp"))</h5>
|
||||||
|
<p class="card-text">@(string.IsNullOrEmpty(Model.NextProductName) ? "---" : Model.NextProductName)</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<div id="publicProductBidBox@(Model.ProductToAuctionId)" class="p-3 @bgClass text-white">
|
||||||
|
<input id="bidPriceContainer@(Model.ProductToAuctionId)" value="@Model.NextBidPrice" hidden/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-3"><strong>#@Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault()!.SortIndex</strong></div>
|
||||||
|
<div class="col-9"><a target="_blank" class="btn btn-secondary btn-sm float-end" href="https://youtube.com/live/6yfnmyQE7Uw?feature=share"><i class="fa-brands fa-youtube"></i> Youtube live</a></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4 id="bidBoxTitle@(Model.ProductToAuctionId)">@title</h4>
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="m-auto">
|
||||||
|
<strong>Base Price:</strong>
|
||||||
|
@{
|
||||||
|
if (Model.WorkingCurrency.CurrencyCode == "EUR")
|
||||||
|
{
|
||||||
|
|
||||||
|
<span class="value">@($"{((decimal)Model.BasePriceInWorkingCurrency).ToString("C", new CultureInfo("de-DE"))}")</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="value">@($"{((decimal)Model.BasePrice).ToString("C", new CultureInfo("hu-HU"))}")</span>
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<div class="d-flex justify-content-between" id="otherAuctionItems">
|
|
||||||
<a href="@(string.IsNullOrEmpty(Model.LastProductUrl) ? "#" : Model.LastProductUrl)" @(string.IsNullOrEmpty(Model.LastProductUrl) ? "disabled" : string.Empty)>
|
|
||||||
<div class="card mb-3" style="max-width: 540px;">
|
|
||||||
<div class="row g-0">
|
|
||||||
@*<div class="col-md-4">
|
|
||||||
<img src="@(string.IsNullOrEmpty(Model.LastProductImageUrl) ? "https://placehold.co/400" : Model.LastProductImageUrl)" class="img-fluid rounded-start" alt="...">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">*@
|
<div class="m-auto">
|
||||||
<div class="col-12">
|
<strong>Bid Step:</strong>
|
||||||
<div class="card-body">
|
@{
|
||||||
<h5 class="card-title">@(string.IsNullOrEmpty(Model.LastProductUrl) ? @T("Plugins.Misc.AuctionPlugin.StartOfList") : @T("Plugins.Misc.AuctionPlugin.BackToLast"))</h5>
|
if (Model.WorkingCurrency.CurrencyCode == "EUR")
|
||||||
<p class="card-text">@(string.IsNullOrEmpty(Model.LastProductName) ? "---" : Model.LastProductName)</p>
|
{
|
||||||
</div>
|
<span id="licitStepText@(Model.ProductToAuctionId)" class="value">@($"{Model.LicitStepInWorkingCurrency.ToString("C", new CultureInfo("de-DE"))}")</span>
|
||||||
</div>
|
|
||||||
</div>
|
}
|
||||||
</div>
|
else
|
||||||
</a>
|
{
|
||||||
|
// <span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
||||||
|
<span id="licitStepText@(Model.ProductToAuctionId)" class="value">@($"{Model.LicitStep.ToString("C", new CultureInfo("hu-HU"))}")</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<a href="@(string.IsNullOrEmpty(Model.NextProductUrl) ? "#" : Model.NextProductUrl)" @(string.IsNullOrEmpty(Model.NextProductUrl) ? "disabled" : string.Empty)>
|
|
||||||
<div class="card mb-3" style="max-width: 540px;">
|
|
||||||
<div class="row g-0">
|
|
||||||
@*<div class="col-md-4">
|
|
||||||
<img src="@(string.IsNullOrEmpty(Model.NextProductImageUrl) ? "https://placehold.co/400" : Model.NextProductImageUrl)" class="img-fluid rounded-start" alt="...">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">*@
|
<div class="m-auto">
|
||||||
<div class="col-12">
|
<button id="signalRBidButton@(Model.ProductToAuctionId)" class="btn btn-success float-end" style="text-transform: uppercase;" type="button" @(!bidButtonActive ? "disabled" : string.Empty)>
|
||||||
<div class="card-body">
|
@{
|
||||||
<h5 class="card-title">@(string.IsNullOrEmpty(Model.NextProductUrl) ? @T("Plugins.Misc.AuctionPlugin.EndOfList") : @T("Plugins.Misc.AuctionPlugin.ComingUp"))</h5>
|
if (Model.WorkingCurrency.CurrencyCode == "EUR")
|
||||||
<p class="card-text">@(string.IsNullOrEmpty(Model.NextProductName) ? "---" : Model.NextProductName)</p>
|
{
|
||||||
</div>
|
@T("Plugins.Misc.AuctionPlugin.BidButtonPrefix") @($"{Model.NextBidPriceInWorkingCurrency.ToString("C", new CultureInfo("de-DE"))}")
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div>
|
}
|
||||||
<div id="publicProductBidBox" class="p-3 @bgClass text-white">
|
else
|
||||||
<div class="row">
|
{
|
||||||
<div class="col-3"><strong>#@Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault()!.SortIndex</strong></div>
|
// <span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
||||||
<div class="col-9"><a target="_blank" class="btn btn-secondary btn-sm float-end" href="https://youtube.com/live/6yfnmyQE7Uw?feature=share"><i class="fa-brands fa-youtube"></i> Youtube live</a></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 id="bidBoxTitle">@title</h4>
|
@T("Plugins.Misc.AuctionPlugin.BidButtonPrefix") @($"{Model.NextBidPrice.ToString("C", new CultureInfo("hu-HU"))}")
|
||||||
<div class="d-flex justify-content-between">
|
}
|
||||||
<div class="m-auto">
|
}
|
||||||
<strong>Base Price:</strong>
|
|
||||||
@{
|
|
||||||
if (Model.WorkingCurrency.CurrencyCode == "EUR")
|
|
||||||
{
|
|
||||||
|
|
||||||
<span class="value">@($"{((decimal)Model.BasePriceInWorkingCurrency).ToString("C", new CultureInfo("de-DE"))}")</span>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<span class="value">@($"{((decimal)Model.BasePrice).ToString("C", new CultureInfo("hu-HU"))}")</span>
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="m-auto">
|
|
||||||
<strong>Bid Step:</strong>
|
|
||||||
@{
|
|
||||||
if (Model.WorkingCurrency.CurrencyCode == "EUR")
|
|
||||||
{
|
|
||||||
<span id="licitStepText" class="value">@($"{Model.LicitStepInWorkingCurrency.ToString("C", new CultureInfo("de-DE"))}")</span>
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// <span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
|
||||||
<span id="licitStepText" class="value">@($"{Model.LicitStep.ToString("C", new CultureInfo("hu-HU"))}")</span>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="m-auto">
|
|
||||||
<button id="signalRBidButton" class="btn btn-success float-end" style="text-transform: uppercase;" type="button" @(!bidButtonActive ? "disabled" : string.Empty)>
|
|
||||||
@{
|
|
||||||
if (Model.WorkingCurrency.CurrencyCode == "EUR")
|
|
||||||
{
|
|
||||||
@T("Plugins.Misc.AuctionPlugin.BidButtonPrefix") @($"{Model.NextBidPriceInWorkingCurrency.ToString("C", new CultureInfo("de-DE"))}")
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// <span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
|
||||||
|
|
||||||
@T("Plugins.Misc.AuctionPlugin.BidButtonPrefix") @($"{Model.NextBidPrice.ToString("C", new CultureInfo("hu-HU"))}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
@* <button id="bidButton" class="btn btn-success">
|
@* <button id="bidButton" class="btn btn-success">
|
||||||
|
|
||||||
Bid @String.Format("{0:c}", Model.NextBidPrice)
|
Bid @String.Format("{0:c}", Model.NextBidPrice)
|
||||||
</button> *@
|
</button> *@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@* <button id="testButton" class="btn btn-success">
|
@* <button id="testButton" class="btn btn-success">
|
||||||
TestButton
|
TestButton
|
||||||
</button> *@
|
</button> *@
|
||||||
|
|
||||||
<div id="bidFeedback" class="mt-3"></div>
|
<div id="bidFeedback" class="mt-3"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
if (Model.IsAdmin)
|
if (Model.IsAdmin)
|
||||||
{
|
{
|
||||||
<div id="publicProductBidBoxAdmin" class="p-3 bg-secondary text-white">
|
<div id="publicProductBidBoxAdmin@(Model.ProductToAuctionId)" class="p-3 bg-secondary text-white">
|
||||||
<h4>Manage auction!</h4>
|
<h4>Manage auction!</h4>
|
||||||
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
<div id="bidBoxAdminButtons@(Model.ProductToAuctionId)" class="d-flex justify-content-between mb-3">
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button id="signalROpenItemButton" class="btn btn-primary" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.None || Model.AuctionStatus == AuctionStatus.Pause ? string.Empty : "disabled hidden")>
|
<button id="signalROpenItemButton@(Model.ProductToAuctionId)" class="btn btn-primary" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.None || Model.AuctionStatus == AuctionStatus.Pause ? string.Empty : "disabled hidden")>
|
||||||
Open item
|
Open item
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRPauseItemButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.Active || Model.AuctionStatus == AuctionStatus.FirstWarning || Model.AuctionStatus == AuctionStatus.SecondWarning ? string.Empty : "disabled hidden")>
|
<button id="signalRPauseItemButton@(Model.ProductToAuctionId)" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.Active || Model.AuctionStatus == AuctionStatus.FirstWarning || Model.AuctionStatus == AuctionStatus.SecondWarning ? string.Empty : "disabled hidden")>
|
||||||
Pause auction
|
Pause auction
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRRevertBidButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled hidden" : string.Empty)>
|
<button id="signalRRevertBidButton@(Model.ProductToAuctionId)" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled hidden" : string.Empty)>
|
||||||
Revert bid
|
Revert bid
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRResetItemButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled hidden" : string.Empty)>
|
<button id="signalRResetItemButton@(Model.ProductToAuctionId)" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled hidden" : string.Empty)>
|
||||||
Reset auction
|
Reset auction
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Active ? "disabled hidden" : string.Empty)>
|
<button id="signalRFirstWarningButton@(Model.ProductToAuctionId)" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Active ? "disabled hidden" : string.Empty)>
|
||||||
First warning
|
First warning
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRSecondWarningButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.FirstWarning ? "disabled hidden" : string.Empty)>
|
<button id="signalRSecondWarningButton@(Model.ProductToAuctionId)" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.FirstWarning ? "disabled hidden" : string.Empty)>
|
||||||
Second warning
|
Second warning
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRCloseItemButton" class="btn btn-success" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.SecondWarning ? "disabled hidden" : string.Empty)>
|
<button id="signalRCloseItemButton@(Model.ProductToAuctionId)" class="btn btn-success" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.SecondWarning ? "disabled hidden" : string.Empty)>
|
||||||
Finished
|
Finished
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// <p>No access to admin level buttons</p>
|
// <p>No access to admin level buttons</p>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div id="publicProductBidBoxGuest" class="p-3 bg-primary text-white">
|
<div id="publicProductBidBoxGuest@(Model.ProductToAuctionId)" class="p-3 bg-primary text-white">
|
||||||
<h4>This item is under auction!</h4>
|
<h4>This item is under auction!</h4>
|
||||||
<div id="bidBoxGuestMessage" class="d-flex justify-content-between mb-3">
|
<div id="bidBoxGuestMessage@(Model.ProductToAuctionId)" class="d-flex justify-content-between mb-3">
|
||||||
|
|
||||||
<p>@T("Plugins.Misc.AuctionPlugin.PleaseLogInOrRegister")</p>
|
<p>@T("Plugins.Misc.AuctionPlugin.PleaseLogInOrRegister")</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var bidBoxPageViewModel;
|
var bidBoxPageViewModel;
|
||||||
|
//var bidPrice;
|
||||||
|
$(window).load(function () {
|
||||||
|
try {
|
||||||
|
|
||||||
$(window).load(function () {
|
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
||||||
try {
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(e); // Logs the error
|
||||||
|
}
|
||||||
|
console.log("bidBoxPageViewModel " + bidBoxPageViewModel);
|
||||||
|
console.log(bidBoxPageViewModel.WidgetZone);
|
||||||
|
//console.log(typeof sendMessageToServer);
|
||||||
|
document.getElementById("bidPriceContainer" + bidBoxPageViewModel.ProductToAuctionId).value = bidBoxPageViewModel.NextBidPrice;
|
||||||
|
setOnClicks(bidBoxPageViewModel.ProductToAuctionId, bidBoxPageViewModel);
|
||||||
|
//var status = bidBoxPageViewModel.productToAuctionDto.auctionStatus;
|
||||||
|
//setButtons(status);
|
||||||
|
});
|
||||||
|
|
||||||
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
function setOnClicks(ptaId, viewModel) {
|
||||||
}
|
console.log("Setting onclick methods");
|
||||||
catch (e) {
|
$("#signalRBidButton" + ptaId).on("click", function () {
|
||||||
console.log(e); // Logs the error
|
var storedBidPrice = document.getElementById("bidPriceContainer" + ptaId).value;
|
||||||
}
|
sendBidMessage(ptaId,
|
||||||
console.log("bidBoxPageViewModel " + bidBoxPageViewModel);
|
viewModel.AuctionId,
|
||||||
console.log(bidBoxPageViewModel.WidgetZone);
|
storedBidPrice,
|
||||||
//console.log(typeof sendMessageToServer);
|
viewModel.ProductId
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$("#signalRBidButton").on("click", function () {
|
$("#signalROpenItemButton" + ptaId).on("click", function () {
|
||||||
|
|
||||||
setBidButtonDisabledById("signalRBidButton", true);
|
this.disabled = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (!bidBoxPageViewModel) {
|
sendAuctionStatusChange(ptaId, AuctionStatus.Active);
|
||||||
console.log("we need viewmodel data");
|
|
||||||
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
|
||||||
}
|
|
||||||
|
|
||||||
var bidMessage = {
|
return false;
|
||||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
});
|
||||||
AuctionId: bidBoxPageViewModel.AuctionId,
|
$("#signalRCloseItemButton" + ptaId).on("click", function () {
|
||||||
BidPrice: bidBoxPageViewModel.NextBidPrice,
|
|
||||||
ProductId: bidBoxPageViewModel.ProductId,
|
|
||||||
CustomerId: bidBoxPageViewModel.CustomerId
|
|
||||||
};
|
|
||||||
|
|
||||||
var content = JSON.stringify(bidMessage);
|
this.disabled = true;
|
||||||
console.log("WTF " + content);
|
/*event.preventDefault();*/
|
||||||
sendMessageToServer("BidRequestMessage", bidBoxPageViewModel.CustomerId, content);
|
|
||||||
|
|
||||||
return false;
|
sendAuctionStatusChange(ptaId, AuctionStatus.Sold);
|
||||||
});
|
|
||||||
|
|
||||||
$("#signalROpenItemButton").on("click", function () {
|
return false;
|
||||||
|
});
|
||||||
|
$("#signalRFirstWarningButton" + ptaId).on("click", function () {
|
||||||
|
|
||||||
document.getElementById("signalROpenItemButton").disabled = true;
|
this.disabled = true;
|
||||||
event.preventDefault();
|
//event.preventDefault();
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.Active);
|
sendAuctionStatusChange(ptaId, AuctionStatus.FirstWarning);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$("#signalRCloseItemButton").on("click", function () {
|
$("#signalRSecondWarningButton" + ptaId).on("click", function () {
|
||||||
|
|
||||||
document.getElementById("signalRCloseItemButton").disabled = true;
|
this.disabled = true;
|
||||||
event.preventDefault();
|
//event.preventDefault();
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.Sold);
|
sendAuctionStatusChange(ptaId, AuctionStatus.SecondWarning);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$("#signalRFirstWarningButton").on("click", function () {
|
$("#signalRPauseItemButton" + ptaId).on("click", function () {
|
||||||
|
|
||||||
document.getElementById("signalRFirstWarningButton").disabled = true;
|
this.disabled = true;
|
||||||
event.preventDefault();
|
//event.preventDefault();
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.FirstWarning);
|
sendAuctionStatusChange(ptaId, AuctionStatus.Pause);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$("#signalRSecondWarningButton").on("click", function () {
|
$("#signalRRevertBidButton" + ptaId).on("click", function () {
|
||||||
|
|
||||||
document.getElementById("signalRSecondWarningButton").disabled = true;
|
this.disabled = true;
|
||||||
event.preventDefault();
|
//event.preventDefault();
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.SecondWarning);
|
if (!bidBoxPageViewModel) {
|
||||||
|
console.log("we need viewmodel data");
|
||||||
|
bidBoxPageViewModel = viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
var revertMessage = {
|
||||||
});
|
ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId
|
||||||
$("#signalRPauseItemButton").on("click", function () {
|
};
|
||||||
|
|
||||||
document.getElementById("signalRPauseItemButton").disabled = true;
|
var content = JSON.stringify(revertMessage);
|
||||||
event.preventDefault();
|
console.log("WTF " + content);
|
||||||
|
sendMessageToServer("RevertAuctionBidRequest", bidBoxPageViewModel.CustomerId, content);
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.Pause);
|
return false;
|
||||||
|
});
|
||||||
|
$("#signalRResetItemButton" + ptaId).on("click", function () {
|
||||||
|
|
||||||
return false;
|
this.disabled = true;
|
||||||
});
|
//event.preventDefault();
|
||||||
$("#signalRRevertBidButton").on("click", function () {
|
|
||||||
|
|
||||||
document.getElementById("signalRRevertBidButton").disabled = true;
|
sendAuctionStatusChange(AuctionStatus.None);
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
if (!bidBoxPageViewModel) {
|
return false;
|
||||||
console.log("we need viewmodel data");
|
});
|
||||||
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var revertMessage = {
|
// function SendRevertAuctionBidRequest() {
|
||||||
ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId
|
|
||||||
};
|
|
||||||
|
|
||||||
var content = JSON.stringify(revertMessage);
|
// var revertButtonElement = document.getElementById("signalRRevertBidButton");
|
||||||
console.log("WTF " + content);
|
// revertButtonElement.disabled = true;
|
||||||
sendMessageToServer("RevertAuctionBidRequest", bidBoxPageViewModel.CustomerId, content);
|
// sendMessageToServer("RevertAuctionBidRequest", bidBoxPageViewModel.ProductToAuctionId);
|
||||||
|
// }
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$("#signalRResetItemButton").on("click", function () {
|
|
||||||
|
|
||||||
document.getElementById("signalRResetItemButton").disabled = true;
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.None);
|
function setBidButtonDisabled(bidButtonElement, disabled, updateDisabledState = true) {
|
||||||
|
if (!updateDisabledState) return;
|
||||||
|
|
||||||
return false;
|
setElementDisabled(bidButtonElement, disabled, updateDisabledState);
|
||||||
});
|
}
|
||||||
//var status = bidBoxPageViewModel.productToAuctionDto.auctionStatus;
|
|
||||||
//setButtons(status);
|
|
||||||
});
|
|
||||||
|
|
||||||
function sendAuctionStatusChange(auctionStatus) {
|
function setElementDisabledById(domElementId, disabled) {
|
||||||
|
setElementDisabled(document.getElementById(domElementId), disabled);
|
||||||
|
}
|
||||||
|
|
||||||
// Create the message object
|
function setElementDisabled(domElement, disabled) {
|
||||||
var auctionMessage = {
|
if (!domElement)
|
||||||
ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId,
|
return;
|
||||||
AuctionStatus: auctionStatus
|
|
||||||
};
|
|
||||||
|
|
||||||
// Convert to JSON and log
|
domElement.disabled = disabled;
|
||||||
var content = JSON.stringify(auctionMessage);
|
}
|
||||||
console.log(content);
|
|
||||||
|
|
||||||
// Send the message via SignalR
|
|
||||||
sendMessageToServer("AuctionProductStatusRequest", bidBoxPageViewModel.CustomerId, content);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function SendRevertAuctionBidRequest() {
|
|
||||||
|
|
||||||
var revertButtonElement = document.getElementById("signalRRevertBidButton");
|
|
||||||
revertButtonElement.disabled = true;
|
|
||||||
sendMessageToServer("RevertAuctionBidRequest", bidBoxPageViewModel.ProductToAuctionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setBidButtonDisabledById(bidButtonElementId, disabled, updateDisabledState = true) {
|
|
||||||
if (!updateDisabledState) return;
|
|
||||||
|
|
||||||
setBidButtonDisabled(document.getElementById(bidButtonElementId), disabled, updateDisabledState);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setBidButtonDisabled(bidButtonElement, disabled, updateDisabledState = true) {
|
|
||||||
if (!updateDisabledState) return;
|
|
||||||
|
|
||||||
setElementDisabled(bidButtonElement, disabled, updateDisabledState);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setElementDisabledById(domElementId, disabled) {
|
|
||||||
setElementDisabled(document.getElementById(domElementId), disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setElementDisabled(domElement, disabled) {
|
|
||||||
if (!domElement)
|
|
||||||
return;
|
|
||||||
|
|
||||||
domElement.disabled = disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshPublicBidBox(bidNotification, updateBidButtonDisabledState) {
|
|
||||||
|
|
||||||
//TODO: is it for me?
|
|
||||||
// if () {
|
|
||||||
// bidNotification.AuctionDto.
|
|
||||||
// }
|
|
||||||
|
|
||||||
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
|
||||||
var currency = bidBoxPageViewModel.WorkingCurrency;
|
|
||||||
console.log(currency);
|
|
||||||
|
|
||||||
var bidButtonElement = document.getElementById("signalRBidButton");
|
|
||||||
var licitStepElement = document.getElementById("licitStepText");
|
|
||||||
var bidBox = document.getElementById("publicProductBidBox");
|
|
||||||
var bidBoxTitle = document.getElementById("bidBoxTitle");
|
|
||||||
console.log(bidNotification);
|
|
||||||
|
|
||||||
let auctionDto = bidNotification.auctionDto;
|
|
||||||
let productToAuction = auctionDto.productToAuctionDtos[0];
|
|
||||||
var productAuctionMappingId = productToAuction.id;
|
|
||||||
var winnerId = productToAuction.winnerCustomerId;
|
|
||||||
var isMyBid;
|
|
||||||
|
|
||||||
if (winnerId == bidBoxPageViewModel.CustomerId) {
|
|
||||||
isMyBid = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("ProductToAuctionId: " + productAuctionMappingId);
|
|
||||||
|
|
||||||
//TODO: TESZT STATUS!!! - JTEST.
|
|
||||||
var status = productToAuction.auctionStatus;
|
|
||||||
//var status = AuctionStatus.TEST;
|
|
||||||
|
|
||||||
//if (status == AuctionStatus.FirstWarning) {
|
|
||||||
if (updateBidButtonDisabledState)
|
|
||||||
setButtons(status);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
|
|
||||||
// console.log("THIS IS FOR US! SORRY FOR SHOUTING");
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (widgetPriceElement) {
|
|
||||||
|
|
||||||
if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
|
|
||||||
console.log("THIS IS FOR US! SORRY FOR SHOUTING");
|
|
||||||
if(bidBoxPageViewModel.WorkingCurrency.CurrencyCode == "EUR") {
|
|
||||||
widgetPriceElement.textContent = EURFormatter.format(bidNotification.currentPrice * bidBoxPageViewModel.WorkingCurrency.Rate); // Update the price
|
|
||||||
licitStepElement.textContent = EURFormatter.format(bidNotification.nextStepAmount * bidBoxPageViewModel.WorkingCurrency.Rate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
widgetPriceElement.textContent = HUFFormatter.format(bidNotification.currentPrice); // Update the price
|
|
||||||
licitStepElement.textContent = HUFFormatter.format(bidNotification.nextStepAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
bidBoxPageViewModel.NextBidPrice = Number(bidNotification.nextBidPrice);
|
|
||||||
setBidButtonDisabled(bidButtonElement, !productToAuction.isActiveItem, updateBidButtonDisabledState);
|
|
||||||
|
|
||||||
var list;
|
|
||||||
if (isMyBid) {
|
|
||||||
console.log("This is my bid");
|
|
||||||
list = bidBox.classList;
|
|
||||||
list.add("bg-success");
|
|
||||||
list.remove("bg-primary");
|
|
||||||
|
|
||||||
bidButtonElement.textContent = "@(T("Plugins.Misc.AuctionPlugin.GoodJob"))";
|
|
||||||
bidBoxTitle.textContent = productToAuction.auctionStatus == AuctionStatus.Sold ? "@(T("Plugins.Misc.AuctionPlugin.YouWin"))" : "@(T("Plugins.Misc.AuctionPlugin.YourBidLeading"))";
|
|
||||||
|
|
||||||
if (bidBoxPageViewModel.IsAdmin) {
|
|
||||||
console.log("I AM WEASEL!!! " + bidBoxPageViewModel.IsAdmin);
|
|
||||||
setBidButtonDisabled(bidButtonElement, !productToAuction.isActiveItem, updateBidButtonDisabledState);
|
|
||||||
} else {
|
|
||||||
console.log("I AM NOT WEASEL!!! " + bidBoxPageViewModel.IsAdmin);
|
|
||||||
setBidButtonDisabled(bidButtonElement, true, updateBidButtonDisabledState);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
list = bidBox.classList;
|
|
||||||
list.add("bg-primary");
|
|
||||||
list.remove("bg-success");
|
|
||||||
bidBoxTitle.textContent = productToAuction.auctionStatus == AuctionStatus.Sold ? "@(T("Plugins.Misc.AuctionPlugin.Sold"))" : "@(T("Plugins.Misc.AuctionPlugin.PlaceABid"))";
|
|
||||||
|
|
||||||
if (bidBoxPageViewModel.WorkingCurrency.CurrencyCode == "EUR") {
|
|
||||||
bidButtonElement.textContent = "@(T("Plugins.Misc.AuctionPlugin.BidButtonPrefix")) " + EURFormatter.format(bidBoxPageViewModel.NextBidPriceInWorkingCurrency);
|
|
||||||
} else {
|
|
||||||
bidButtonElement.textContent = "@(T("Plugins.Misc.AuctionPlugin.BidButtonPrefix")) " + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`WidgetPrice updated to: ${bidNotification.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`);
|
|
||||||
//bidButtonElement.disabled = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("Not for this product");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleAuctionUpdate(auctionStatusNotification) {
|
|
||||||
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
|
||||||
var bidButtonElement = document.getElementById("signalRBidButton");
|
|
||||||
var licitStepElement = document.getElementById("licitStepText");
|
|
||||||
var bidBoxTitle = document.getElementById("bidBoxTitle");
|
|
||||||
|
|
||||||
var auctionDto = auctionStatusNotification.auctionDto;
|
|
||||||
var productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
|
||||||
var productAuctionMappingId = productToAuctionDto.id;
|
|
||||||
let isMyBid = false;
|
|
||||||
|
|
||||||
//TODO: TESZT STATUS!!! - JTEST.
|
|
||||||
let itemStatus = productToAuctionDto.auctionStatus;
|
|
||||||
//var itemStatus = AuctionStatus.TEST;
|
|
||||||
let winnerId = productToAuctionDto.winnerCustomerId;
|
|
||||||
if (winnerId == bidBoxPageViewModel.CustomerId) {
|
|
||||||
isMyBid = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
console.log("handle auction update called" + productAuctionMappingId);
|
|
||||||
console.log("auction status:" + itemStatus);
|
|
||||||
if (widgetPriceElement) {
|
|
||||||
|
|
||||||
if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
|
|
||||||
console.log("THIS IS FOR US! SORRY FOR SHOUTING");
|
|
||||||
switch (itemStatus) {
|
|
||||||
case AuctionStatus.None:
|
|
||||||
location.reload();
|
|
||||||
// bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.AuctionNotStarted"))";
|
|
||||||
|
|
||||||
// bidBoxPageViewModel.NextBidPrice = Number(auctionStatusNotification.nextBidPrice);
|
|
||||||
|
|
||||||
// if(bidBoxPageViewModel.WorkingCurrency.CurrencyCode == "EUR") {
|
|
||||||
// widgetPriceElement.textContent = EURFormatter.format(auctionStatusNotification.currentPrice * bidBoxPageViewModel.WorkingCurrency.Rate); // Update the price
|
|
||||||
// licitStepElement.textContent = EURFormatter.format(auctionStatusNotification.nextStepAmount * bidBoxPageViewModel.WorkingCurrency.Rate);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// widgetPriceElement.textContent = HUFFormatter.format(auctionStatusNotification.currentPrice); // Update the price
|
|
||||||
// licitStepElement.textContent = HUFFormatter.format(auctionStatusNotification.nextStepAmount);
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AuctionStatus.Active:
|
|
||||||
if (isMyBid) {
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.YourBidLeading"))";
|
|
||||||
} else {
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.PlaceABid"))";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AuctionStatus.Pause:
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.AuctionPaused"))";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AuctionStatus.FirstWarning:
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.FirstWarning"))";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AuctionStatus.SecondWarning:
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.SecondWarning"))";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AuctionStatus.Sold:
|
|
||||||
if (isMyBid) {
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.YouWin"))";
|
|
||||||
} else {
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.ItemClosed"))";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case AuctionStatus.NotSold:
|
|
||||||
bidBoxTitle.textContent = "@(T("Plugins.Misc.AuctionPlugin.ItemClosed"))";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
console.warn("Unknown AuctionStatus: ", itemStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setButtons(itemStatus);
|
|
||||||
|
|
||||||
console.log(`WidgetPrice updated to: ${auctionStatusNotification.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
console.log("Not for this product");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function setButtons(auctionStatus) {
|
|
||||||
console.log("SetButtons called: " + auctionStatus);
|
|
||||||
|
|
||||||
// Button IDs and their default states for each AuctionStatus
|
|
||||||
//true = disabled
|
|
||||||
var buttonStates = {
|
|
||||||
[AuctionStatus.None]: {
|
|
||||||
signalRBidButton: true,
|
|
||||||
signalRFirstWarningButton: true,
|
|
||||||
signalRSecondWarningButton: true,
|
|
||||||
signalROpenItemButton: false,
|
|
||||||
signalRCloseItemButton: true,
|
|
||||||
signalRPauseItemButton: true,
|
|
||||||
signalRRevertBidButton: true,
|
|
||||||
signalRResetItemButton: true,
|
|
||||||
},
|
|
||||||
[AuctionStatus.Active]: {
|
|
||||||
signalRBidButton: false,
|
|
||||||
signalRFirstWarningButton: false,
|
|
||||||
signalRSecondWarningButton: true,
|
|
||||||
signalROpenItemButton: true,
|
|
||||||
signalRCloseItemButton: true,
|
|
||||||
signalRPauseItemButton: false,
|
|
||||||
signalRRevertBidButton: true,
|
|
||||||
signalRResetItemButton: true,
|
|
||||||
},
|
|
||||||
[AuctionStatus.FirstWarning]: {
|
|
||||||
signalRBidButton: false,
|
|
||||||
signalRFirstWarningButton: true,
|
|
||||||
signalRSecondWarningButton: false,
|
|
||||||
signalROpenItemButton: true,
|
|
||||||
signalRCloseItemButton: true,
|
|
||||||
signalRPauseItemButton: false,
|
|
||||||
signalRRevertBidButton: true,
|
|
||||||
signalRResetItemButton: true,
|
|
||||||
},
|
|
||||||
[AuctionStatus.SecondWarning]: {
|
|
||||||
signalRBidButton: false,
|
|
||||||
signalRFirstWarningButton: true,
|
|
||||||
signalRSecondWarningButton: true,
|
|
||||||
signalROpenItemButton: true,
|
|
||||||
signalRCloseItemButton: false,
|
|
||||||
signalRPauseItemButton: false,
|
|
||||||
signalRRevertBidButton: true,
|
|
||||||
signalRResetItemButton: true,
|
|
||||||
},
|
|
||||||
[AuctionStatus.Pause]: {
|
|
||||||
signalRBidButton: true,
|
|
||||||
signalRFirstWarningButton: true,
|
|
||||||
signalRSecondWarningButton: true,
|
|
||||||
signalROpenItemButton: false,
|
|
||||||
signalRCloseItemButton: true,
|
|
||||||
signalRPauseItemButton: true,
|
|
||||||
signalRRevertBidButton: false,
|
|
||||||
signalRResetItemButton: false,
|
|
||||||
},
|
|
||||||
[AuctionStatus.Sold]: {
|
|
||||||
signalRBidButton: true,
|
|
||||||
signalRFirstWarningButton: true,
|
|
||||||
signalRSecondWarningButton: true,
|
|
||||||
signalROpenItemButton: true,
|
|
||||||
signalRCloseItemButton: true,
|
|
||||||
signalRPauseItemButton: true,
|
|
||||||
signalRRevertBidButton: true,
|
|
||||||
signalRResetItemButton: true,
|
|
||||||
},
|
|
||||||
[AuctionStatus.NotSold]: {
|
|
||||||
signalRBidButton: true,
|
|
||||||
signalRFirstWarningButton: true,
|
|
||||||
signalRSecondWarningButton: true,
|
|
||||||
signalROpenItemButton: true,
|
|
||||||
signalRCloseItemButton: true,
|
|
||||||
signalRPauseItemButton: true,
|
|
||||||
signalRRevertBidButton: true,
|
|
||||||
signalRResetItemButton: true,
|
|
||||||
},
|
|
||||||
[AuctionStatus.TEST]: {
|
|
||||||
signalRBidButton: false,
|
|
||||||
signalRFirstWarningButton: false,
|
|
||||||
signalRSecondWarningButton: false,
|
|
||||||
signalROpenItemButton: false,
|
|
||||||
signalRCloseItemButton: false,
|
|
||||||
signalRPauseItemButton: false,
|
|
||||||
signalRRevertBidButton: false,
|
|
||||||
signalRResetItemButton: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the states for the given auctionStatus
|
|
||||||
var states = buttonStates[auctionStatus];
|
|
||||||
if (!states) {
|
|
||||||
console.error("Unknown AuctionStatus: ", auctionStatus);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply the states to each button
|
|
||||||
Object.keys(states).forEach((buttonId) => {
|
|
||||||
var button = document.getElementById(buttonId);
|
|
||||||
if (button) {
|
|
||||||
button.disabled = states[buttonId];
|
|
||||||
button.hidden = states[buttonId];
|
|
||||||
} else {
|
|
||||||
console.warn(`Button with ID ${buttonId} not found.`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue