widgets basic setup
This commit is contained in:
parent
cf33930077
commit
ae6f4bc7e8
|
|
@ -92,7 +92,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
model.Body = singleAnnouncement.Body;
|
model.Body = singleAnnouncement.Body;
|
||||||
model.IsActive = singleAnnouncement.IsActive;
|
model.IsActive = singleAnnouncement.IsActive;
|
||||||
|
|
||||||
return View("~/Plugins/Widget.LiveAnnouncement/Views/LiveAnnouncementView/Announcement.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Announcement.cshtml", model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
public IActionResult AnnouncementList()
|
public IActionResult AnnouncementList()
|
||||||
{
|
{
|
||||||
var model = new AnnouncementViewModel();
|
var model = new AnnouncementViewModel();
|
||||||
return View("~/Plugins/Misc.Auction/Areas/Admin/Views/AnnouncementList.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/AnnouncementList.cshtml", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[HttpPost]
|
//[HttpPost]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public static class AuctionDefaults
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the system name
|
/// Gets the system name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string SystemName => "Misc.AuctionPlugin";
|
public static string SystemName => "AuctionPlugin";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the user agent used to request third-party services
|
/// Gets the user agent used to request third-party services
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(widgetZone);
|
ArgumentNullException.ThrowIfNull(widgetZone);
|
||||||
|
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
if (widgetZone.Equals(PublicWidgetZones.ProductPriceTop))
|
||||||
{
|
{
|
||||||
return typeof(AuctionPublicViewComponent);
|
return typeof(AuctionPublicViewComponent);
|
||||||
}
|
}
|
||||||
|
|
@ -116,11 +116,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
return Task.FromResult<IList<string>>(new List<string>
|
return Task.FromResult<IList<string>>(new List<string>
|
||||||
{
|
{
|
||||||
PublicWidgetZones.ProductDetailsOverviewTop,
|
PublicWidgetZones.ProductPriceTop,
|
||||||
PublicWidgetZones.OrderSummaryBillingAddress,
|
PublicWidgetZones.ProductDetailsBottom,
|
||||||
|
|
||||||
AdminWidgetZones.OrderBillingAddressDetailsBottom,
|
//AdminWidgetZones.OrderBillingAddressDetailsBottom,
|
||||||
AdminWidgetZones.OrderShippingAddressDetailsBottom
|
//AdminWidgetZones.OrderShippingAddressDetailsBottom
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin;
|
using Nop.Plugin.Misc.AuctionPlugin;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
|
using Nop.Services.Logging;
|
||||||
using Nop.Web.Framework.Components;
|
using Nop.Web.Framework.Components;
|
||||||
using Nop.Web.Framework.Infrastructure;
|
using Nop.Web.Framework.Infrastructure;
|
||||||
using Nop.Web.Models.Catalog;
|
using Nop.Web.Models.Catalog;
|
||||||
|
|
@ -20,6 +21,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
protected readonly IWidgetPluginManager _widgetPluginManager;
|
protected readonly IWidgetPluginManager _widgetPluginManager;
|
||||||
protected readonly IWorkContext _workContext;
|
protected readonly IWorkContext _workContext;
|
||||||
protected readonly AuctionSettings _auctionSettings;
|
protected readonly AuctionSettings _auctionSettings;
|
||||||
|
protected readonly ILogger _logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -29,13 +31,15 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
IGenericAttributeService genericAttributeService,
|
IGenericAttributeService genericAttributeService,
|
||||||
IWidgetPluginManager widgetPluginManager,
|
IWidgetPluginManager widgetPluginManager,
|
||||||
IWorkContext workContext,
|
IWorkContext workContext,
|
||||||
AuctionSettings auctionSettings)
|
AuctionSettings auctionSettings,
|
||||||
|
ILogger logger)
|
||||||
{
|
{
|
||||||
_addressService = addressService;
|
_addressService = addressService;
|
||||||
_genericAttributeService = genericAttributeService;
|
_genericAttributeService = genericAttributeService;
|
||||||
_widgetPluginManager = widgetPluginManager;
|
_widgetPluginManager = widgetPluginManager;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
_auctionSettings = auctionSettings;
|
_auctionSettings = auctionSettings;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -53,25 +57,41 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
|
await _logger.InformationAsync("WidgetViewComponent called");
|
||||||
|
|
||||||
//ensure that what3words widget is active and enabled
|
//ensure that what3words widget is active and enabled
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||||
|
await _logger.InformationAsync($"WidgetViewComponent customer: {customer.Email}");
|
||||||
|
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
||||||
if (!_auctionSettings.Enabled)
|
await _logger.InformationAsync("WidgetViewComponent widget active");
|
||||||
return Content(string.Empty);
|
|
||||||
|
//if (!_auctionSettings.Enabled)
|
||||||
|
// return Content(string.Empty);
|
||||||
|
|
||||||
var productDetailsModel = additionalData as ProductDetailsModel;
|
var productDetailsModel = additionalData as ProductDetailsModel;
|
||||||
|
|
||||||
if (productDetailsModel is null)
|
|
||||||
return Content(string.Empty);
|
|
||||||
|
|
||||||
var productId = 0;
|
await _logger.InformationAsync($"WidgetViewComponent product: {productDetailsModel.Name}");
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsTop))
|
|
||||||
productId = productDetailsModel.Id;
|
|
||||||
|
|
||||||
|
|
||||||
return View("~/Plugins/Widgets.What3words/Views/PublicProductBidBox.cshtml", productId.ToString());
|
//if (productDetailsModel is null)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// await _logger.InformationAsync("WidgetViewComponent productdetailsmodel is null");
|
||||||
|
// return Content(string.Empty);
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (!widgetZone.Equals(PublicWidgetZones.ProductPriceTop))
|
||||||
|
{
|
||||||
|
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
||||||
|
return Content(string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _logger.InformationAsync("WidgetViewComponent called II");
|
||||||
|
|
||||||
|
|
||||||
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml", productDetailsModel.Id.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,16 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
|
await _logger.InformationAsync("Auction widget called");
|
||||||
|
|
||||||
//ensure that a widget is active and enabled
|
//ensure that a widget is active and enabled
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||||
|
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
//if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
||||||
return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
|
|
||||||
if (!_auctionSettings.Enabled)
|
//if (!_auctionSettings.Enabled)
|
||||||
return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_auctionSettings.SomeText))
|
if (string.IsNullOrEmpty(_auctionSettings.SomeText))
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +74,7 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
//}
|
//}
|
||||||
var model = new AuctionPublicInfoModel();
|
var model = new AuctionPublicInfoModel();
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsTop))
|
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsBottom))
|
||||||
{
|
{
|
||||||
|
|
||||||
model.Message = $"Auction plugin is active, setting = {_auctionSettings.SomeText}, productId = {((ProductDetailsModel)additionalData).Name}";
|
model.Message = $"Auction plugin is active, setting = {_auctionSettings.SomeText}, productId = {((ProductDetailsModel)additionalData).Name}";
|
||||||
|
|
@ -87,7 +87,7 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return View("~/Plugins/Widgets.AuctionPlugin/Views/PublicInfo.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicInfo.cshtml", model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
@model AuctionPublicInfoModel
|
@model AuctionPublicInfoModel
|
||||||
|
|
||||||
<div>
|
<div class="bg-dark">
|
||||||
<label for="w3w">@T("Plugins.Widgets.AuctionPLugin.Label"):</label>
|
<h3>Auction viewcomponent</h3>
|
||||||
|
<label for="w3w">@T("Plugins.Misc.AuctionPLugin.Label"):</label>
|
||||||
<div class="">
|
<div class="">
|
||||||
<p>@Model.Message</p>
|
<p>General widget info: @Model.Message</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
@model string
|
@model string
|
||||||
|
|
||||||
<li class="custom-value">
|
<div class="bg-dark">
|
||||||
|
<h3>Auction Public Viewcomponent</h3>
|
||||||
<span class="label">
|
<span class="label">
|
||||||
@T("Plugins.Misc.AuctionPlugin.BidBox.Field.Label"):
|
@T("Plugins.Misc.AuctionPlugin.BidBox.Field.Label"):
|
||||||
</span>
|
</span>
|
||||||
<span class="value">
|
<span class="value">
|
||||||
@(Model)
|
@(Model)
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue