Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Admin panel - remove Affiliate Component

support446319232a81
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabCustomers.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabCustomers.cshtml
index 53164d470..b0dbd56cd 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabCustomers.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabCustomers.cshtml
@@ -30,6 +30,7 @@
serverFiltering: true,
serverSorting: true
},
+ autoBind: false,
pageable: {
refresh: true,
pageSizes: [@(adminAreaSettings.GridPageSizes)]
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/Components/Affiliate/Default.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabOrders.cshtml
similarity index 99%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/Components/Affiliate/Default.cshtml
rename to src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabOrders.cshtml
index 3636fbbf4..002b8b982 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/Components/Affiliate/Default.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.TabOrders.cshtml
@@ -72,6 +72,7 @@
serverFiltering: true,
serverSorting: true
},
+ autoBind: false,
pageable: {
refresh: true,
pageSizes: [@(adminAreaSettings.GridPageSizes)]
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.cshtml
index f8cc846ce..e26fc9e84 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Affiliate/Partials/CreateOrUpdate.cshtml
@@ -1,8 +1,19 @@
-@model AffiliateModel
+@using Grand.Business.Core.Interfaces.Checkout.Orders
+@using Grand.Business.Core.Interfaces.Common.Localization
+@using Grand.Domain.Payments
+@using Grand.Domain.Shipping
+@using Grand.Web.Admin.Components
+@using Microsoft.AspNetCore.Mvc.TagHelpers
+@using Grand.Web.Common.TagHelpers.Admin
+
+@model AffiliateModel
+
+@inject IOrderStatusService orderStatusService;
+@inject ITranslationService translationService;
<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />
-<admin-tabstrip name="affiliate-edit">
+<admin-tabstrip name="affiliate-edit" BindGrid="true">
<items>
<tabstrip-item text="@Loc["Admin.Affiliates.Info"]" tab-index="0">
<content>
@@ -13,6 +24,23 @@
</tabstrip-item>
@if (!string.IsNullOrEmpty(Model.Id))
{
+ var model = new AffiliatedOrderListModel {
+ AffliateId = Model.Id
+ };
+ var status = await orderStatusService.GetAll();
+
+ //order statuses
+ model.AvailableOrderStatuses = status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList();
+ model.AvailableOrderStatuses.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "" });
+
+ //payment statuses
+ model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(Context, false).ToList();
+ model.AvailablePaymentStatuses.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "" });
+
+ //shipping statuses
+ model.AvailableShippingStatuses = ShippingStatus.Pending.ToSelectList(Context, false).ToList();
+ model.AvailableShippingStatuses.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "" });
+
<tabstrip-item text="@Loc["Admin.Affiliates.Customers"]" tab-index="1">
<content>
<div>
@@ -23,7 +51,7 @@
<tabstrip-item text="@Loc["Admin.Affiliates.Orders"]" tab-index="2">
<content>
<div>
- @await Component.InvokeAsync("Affiliate", new { affiliateId = Model.Id })
+ <partial name="Partials/CreateOrUpdate.TabOrders" model="model" />
</div>
</content>
</tabstrip-item>
diff --git a/src/Web/Grand.Web.Admin/Components/Affiliate.cs b/src/Web/Grand.Web.Admin/Components/Affiliate.cs
deleted file mode 100644
index 30504bf92..000000000
--- a/src/Web/Grand.Web.Admin/Components/Affiliate.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using Grand.Domain.Payments;
-using Grand.Domain.Shipping;
-using Grand.Web.Common.Components;
-using Grand.Web.Common.Extensions;
-using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Utilities.Common.Security;
-using Grand.Web.Admin.Models.Affiliates;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Rendering;
-using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Interfaces.Checkout.Orders;
-
-namespace Grand.Web.Admin.Components
-{
- public class AffiliateViewComponent : BaseAdminViewComponent
- {
- private readonly ITranslationService _translationService;
- private readonly IPermissionService _permissionService;
- private readonly IOrderStatusService _orderStatusService;
-
- public AffiliateViewComponent(
- ITranslationService translationService,
- IPermissionService permissionService,
- IOrderStatusService orderStatusService)
- {
- _translationService = translationService;
- _permissionService = permissionService;
- _orderStatusService = orderStatusService;
- }
-
- public async Task<IViewComponentResult> InvokeAsync(string affiliateId)
- {
- if (!await _permissionService.Authorize(StandardPermission.ManageAffiliates))
- return Content("");
-
- if (string.IsNullOrEmpty(affiliateId))
- throw new Exception("Affliate ID cannot be empty");
-
- var model = new AffiliatedOrderListModel {
- AffliateId = affiliateId
- };
- var status = await _orderStatusService.GetAll();
-
- //order statuses
- model.AvailableOrderStatuses = status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList();
- model.AvailableOrderStatuses.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });
-
- //payment statuses
- model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(HttpContext, false).ToList();
- model.AvailablePaymentStatuses.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });
-
- //shipping statuses
- model.AvailableShippingStatuses = ShippingStatus.Pending.ToSelectList(HttpContext, false).ToList();
- model.AvailableShippingStatuses.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });
-
- return View(model);
- }
- }
-}
\ No newline at end of file