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.

Migrate CreateOrUpdate.AssociatedProducts.cshtml to AdminShared (ARCH-001 Phase 2)

KrzysztofPajak0cdeafa45350
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml b/src/Web/Grand.Web.AdminShared/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
similarity index 71%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
index e895f68f6..935591ac9 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
@@ -1,22 +1,38 @@
-@model ProductModel
-
+@model ProductModel
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
@if (!string.IsNullOrEmpty(Model.Id))
{
<div class="note note-info">
- <p>@Loc["Admin.Catalog.Products.AssociatedProducts.Note2"]</p>
+ <p>@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.AssociatedProducts.Note2"]</p>
</div>
<div class="panel panel-default">
- <vc:admin-widget widget-zone="product_details_associated_products_top" additional-data="Model"/>
+ @if (Scope.ResourceKeyPrefix == "Vendor")
+ {
+ <vc:vendor-widget widget-zone="vendor_product_details_associated_products_top" additional-data="Model"/>
+ }
+ else
+ {
+ <vc:admin-widget widget-zone="product_details_associated_products_top" additional-data="Model"/>
+ }
<div class="panel-body">
<div id="associatedproducts-grid"></div>
</div>
<div class="panel-footer">
- <a id="btnAddNewAssociatedProduct" href="@(Url.Action("AssociatedProductAddPopup", "Product", new { productId = Model.Id, btnId = "btnRefreshAssociatedProducts", formId = "product-form", area = Constants.AreaAdmin }))" class="k-button">
- @Loc["Admin.Catalog.Products.AssociatedProducts.AddNew"]
+ <a id="btnAddNewAssociatedProduct" href="@(Url.Action("AssociatedProductAddPopup", "Product", new { productId = Model.Id, btnId = "btnRefreshAssociatedProducts", formId = "product-form", area = area }))" class="k-button">
+ @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.AssociatedProducts.AddNew"]
</a>
<input type="submit" id="btnRefreshAssociatedProducts" style="display: none"/>
</div>
- <vc:admin-widget widget-zone="product_details_associated_products_bottom" additional-data="Model"/>
+ @if (Scope.ResourceKeyPrefix == "Vendor")
+ {
+ <vc:vendor-widget widget-zone="vendor_product_details_associated_products_bottom" additional-data="Model"/>
+ }
+ else
+ {
+ <vc:admin-widget widget-zone="product_details_associated_products_bottom" additional-data="Model"/>
+ }
</div>
<script>
$(document).ready(function () {
@@ -37,19 +53,19 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("AssociatedProductList", "Product", new { productId = Model.Id, area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("AssociatedProductList", "Product", new { productId = Model.Id, area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
update: {
- url:"@Html.Raw(Url.Action("AssociatedProductUpdate", "Product", new { area = Constants.AreaAdmin }))",
+ url:"@Html.Raw(Url.Action("AssociatedProductUpdate", "Product", new { area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
destroy: {
- url: "@Html.Raw(Url.Action("AssociatedProductDelete", "Product", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("AssociatedProductDelete", "Product", new { area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -97,11 +113,11 @@
scrollable: false,
columns: [{
field: "ProductName",
- title: "@Loc["Admin.Catalog.Products.AssociatedProducts.Fields.Product"]",
- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { id = "", area = Constants.AreaAdmin })/#=Id#">#=kendo.htmlEncode(ProductName)#</a>'
+ title: "@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.AssociatedProducts.Fields.Product"]",
+ template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { id = "", area = area })/#=Id#">#=kendo.htmlEncode(ProductName)#</a>'
}, {
field: "DisplayOrder",
- title: "@Loc["Admin.Catalog.Products.AssociatedProducts.Fields.DisplayOrder"]",
+ title: "@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.AssociatedProducts.Fields.DisplayOrder"]",
//integer format
format: "{0:0}",
width: 150
@@ -109,13 +125,13 @@
command: [{
name: "edit",
text: {
- edit: "@Loc["Admin.Common.Edit"]",
- update: "@Loc["Admin.Common.Update"]",
- cancel: "@Loc["Admin.Common.Cancel"]"
+ edit: "@Loc[$"{Scope.ResourceKeyPrefix}.Common.Edit"]",
+ update: "@Loc[$"{Scope.ResourceKeyPrefix}.Common.Update"]",
+ cancel: "@Loc[$"{Scope.ResourceKeyPrefix}.Common.Cancel"]"
}
}, {
name: "destroy",
- text: "@Loc["Admin.Common.Delete"]"
+ text: "@Loc[$"{Scope.ResourceKeyPrefix}.Common.Delete"]"
}],
width: 300
}]
@@ -138,5 +154,5 @@
}
else
{
- @Loc["Admin.Catalog.Products.AssociatedProducts.SaveBeforeEdit"]
-}
\ No newline at end of file
+ @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.AssociatedProducts.SaveBeforeEdit"]
+}
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
deleted file mode 100644
index 59ee84ad2..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
+++ /dev/null
@@ -1,142 +0,0 @@
-@model ProductModel
-
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="note note-info">
- <p>@Loc["Admin.Catalog.Products.AssociatedProducts.Note2"]</p>
- </div>
- <div class="panel panel-default">
- <vc:admin-widget widget-zone="product_details_associated_products_top" additional-data="Model"/>
- <div class="panel-body">
- <div id="associatedproducts-grid"></div>
- </div>
- <div class="panel-footer">
- <a id="btnAddNewAssociatedProduct" href="@(Url.Action("AssociatedProductAddPopup", "Product", new { productId = Model.Id, btnId = "btnRefreshAssociatedProducts", formId = "product-form", area = Constants.AreaStore }))" class="k-button">
- @Loc["Admin.Catalog.Products.AssociatedProducts.AddNew"]
- </a>
- <input type="submit" id="btnRefreshAssociatedProducts" style="display: none"/>
- </div>
- <vc:admin-widget widget-zone="product_details_associated_products_bottom" additional-data="Model"/>
- </div>
- <script>
- $(document).ready(function () {
- $('#btnAddNewAssociatedProduct').magnificPopup({
- type: 'ajax',
- settings: { cache: false, async: false },
- midClick: true,
- callbacks: {
- parseAjax: function (mfpResponse) {
- mfpResponse.data = $('<div></div>').html(mfpResponse.data);
- },
- ajaxContentAdded: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- $("#associatedproducts-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("AssociatedProductList", "Product", new { productId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- update: {
- url:"@Html.Raw(Url.Action("AssociatedProductUpdate", "Product", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("AssociatedProductDelete", "Product", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- ProductName: {editable: false, type: "string" },
- DisplayOrder: {editable: true, type: "number" },
- ProductId: { editable: false, type: "string" },
- Id: { editable: false, type: "string" }
- }
- }
- },
- requestEnd: function(e) {
- if(e.type=="update") {
- this.read();
- }
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- autoBind: false,
- pageable: {
- refresh: true,
- numeric: false,
- previousNext: false,
- info: false
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "ProductName",
- title: "@Loc["Admin.Catalog.Products.AssociatedProducts.Fields.Product"]",
- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { id = "", area = Constants.AreaStore })/#=Id#">#=kendo.htmlEncode(ProductName)#</a>'
- }, {
- field: "DisplayOrder",
- title: "@Loc["Admin.Catalog.Products.AssociatedProducts.Fields.DisplayOrder"]",
- //integer format
- format: "{0:0}",
- width: 150
- }, {
- command: [{
- name: "edit",
- text: {
- edit: "@Loc["Admin.Common.Edit"]",
- update: "@Loc["Admin.Common.Update"]",
- cancel: "@Loc["Admin.Common.Cancel"]"
- }
- }, {
- name: "destroy",
- text: "@Loc["Admin.Common.Delete"]"
- }],
- width: 300
- }]
- });
- });
- </script>
-
- <script>
- $(document).ready(function () {
- $('#btnRefreshAssociatedProducts').click(function () {
- //refresh grid
- var grid = $("#associatedproducts-grid").data('kendoGrid');
- grid.dataSource.read();
-
- //return false to don't reload a page
- return false;
- });
- });
- </script>
-}
-else
-{
- @Loc["Admin.Catalog.Products.AssociatedProducts.SaveBeforeEdit"]
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
deleted file mode 100644
index 36176b7d8..000000000
--- a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.AssociatedProducts.cshtml
+++ /dev/null
@@ -1,142 +0,0 @@
-@model ProductModel
-
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="note note-info">
- <p>@Loc["Vendor.Catalog.Products.AssociatedProducts.Note2"]</p>
- </div>
- <div class="panel panel-default">
- <vc:vendor-widget widget-zone="vendor_product_details_associated_products_top" additional-data="Model"/>
- <div class="panel-body">
- <div id="associatedproducts-grid"></div>
- </div>
- <div class="panel-footer">
- <a id="btnAddNewAssociatedProduct" href="@(Url.Action("AssociatedProductAddPopup", "Product", new { productId = Model.Id, btnId = "btnRefreshAssociatedProducts", formId = "product-form", area = Constants.AreaVendor }))" class="k-button">
- @Loc["Vendor.Catalog.Products.AssociatedProducts.AddNew"]
- </a>
- <input type="submit" id="btnRefreshAssociatedProducts" style="display: none"/>
- </div>
- <vc:vendor-widget widget-zone="vendor_product_details_associated_products_bottom" additional-data="Model"/>
- </div>
- <script>
- $(document).ready(function () {
- $('#btnAddNewAssociatedProduct').magnificPopup({
- type: 'ajax',
- settings: { cache: false, async: false },
- midClick: true,
- callbacks: {
- parseAjax: function (mfpResponse) {
- mfpResponse.data = $('<div></div>').html(mfpResponse.data);
- },
- ajaxContentAdded: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- $("#associatedproducts-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("AssociatedProductList", "Product", new { productId = Model.Id, area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- update: {
- url:"@Html.Raw(Url.Action("AssociatedProductUpdate", "Product", new { area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("AssociatedProductDelete", "Product", new { area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- ProductName: {editable: false, type: "string" },
- DisplayOrder: {editable: true, type: "number" },
- ProductId: { editable: false, type: "string" },
- Id: { editable: false, type: "string" }
- }
- }
- },
- requestEnd: function(e) {
- if(e.type=="update") {
- this.read();
- }
- },
- error: function(e) {
- display_kendoui_grid_error(e);
- // Cancel the changes
- this.cancelChanges();
- },
- serverPaging: true,
- serverFiltering: true,
- serverSorting: true
- },
- autoBind: false,
- pageable: {
- refresh: true,
- numeric: false,
- previousNext: false,
- info: false
- },
- editable: {
- confirmation: false,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "ProductName",
- title: "@Loc["Vendor.Catalog.Products.AssociatedProducts.Fields.Product"]",
- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { id = "", area = Constants.AreaVendor })/#=Id#">#=kendo.htmlEncode(ProductName)#</a>'
- }, {
- field: "DisplayOrder",
- title: "@Loc["Vendor.Catalog.Products.AssociatedProducts.Fields.DisplayOrder"]",
- //integer format
- format: "{0:0}",
- width: 150
- }, {
- command: [{
- name: "edit",
- text: {
- edit: "@Loc["Vendor.Common.Edit"]",
- update: "@Loc["Vendor.Common.Update"]",
- cancel: "@Loc["Vendor.Common.Cancel"]"
- }
- }, {
- name: "destroy",
- text: "@Loc["Vendor.Common.Delete"]"
- }],
- width: 300
- }]
- });
- });
- </script>
-
- <script>
- $(document).ready(function () {
- $('#btnRefreshAssociatedProducts').click(function () {
- //refresh grid
- var grid = $("#associatedproducts-grid").data('kendoGrid');
- grid.dataSource.read();
-
- //return false to don't reload a page
- return false;
- });
- });
- </script>
-}
-else
-{
- @Loc["Vendor.Catalog.Products.AssociatedProducts.SaveBeforeEdit"]
-}
\ No newline at end of file