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.Collections.cshtml to AdminShared (ARCH-001 Phase 2)

KrzysztofPajak3c0d1d63ba6b
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Collections.cshtml b/src/Web/Grand.Web.AdminShared/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
similarity index 68%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
index 87a9e42f4..312728347 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
@@ -1,15 +1,32 @@
-@model ProductModel
+@model ProductModel
+@{
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
+}
@if (!string.IsNullOrEmpty(Model.Id))
{
<div class="panel panel-default">
- <vc:admin-widget widget-zone="product_details_collections_top" additional-data="Model"/>
+ @if (Scope.ResourceKeyPrefix == "Vendor")
+ {
+ <vc:vendor-widget widget-zone="vendor_product_details_collections_top" additional-data="Model"/>
+ }
+ else
+ {
+ <vc:admin-widget widget-zone="product_details_collections_top" additional-data="Model"/>
+ }
<div class="panel-heading">
- @Loc["Admin.Catalog.Products.Collections.Fields.Collection"]
+ @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.Collections.Fields.Collection"]
</div>
<div class="panel-body">
<div id="productcollections-grid"></div>
</div>
- <vc:admin-widget widget-zone="product_details_collections_bottom" additional-data="Model"/>
+ @if (Scope.ResourceKeyPrefix == "Vendor")
+ {
+ <vc:vendor-widget widget-zone="vendor_product_details_collections_bottom" additional-data="Model"/>
+ }
+ else
+ {
+ <vc:admin-widget widget-zone="product_details_collections_bottom" additional-data="Model"/>
+ }
</div>
@@ -19,25 +36,25 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("ProductCollectionList", "Product", new { productId = Model.Id, area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("ProductCollectionList", "Product", new { productId = Model.Id, area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
create: {
- url: "@Html.Raw(Url.Action("ProductCollectionInsert", "Product", new { productId = Model.Id, area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("ProductCollectionInsert", "Product", new { productId = Model.Id, area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
update: {
- url:"@Html.Raw(Url.Action("ProductCollectionUpdate", "Product", new { area = Constants.AreaAdmin }))",
+ url:"@Html.Raw(Url.Action("ProductCollectionUpdate", "Product", new { area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
destroy: {
- url: "@Html.Raw(Url.Action("ProductCollectionDelete", "Product", new { area = Constants.AreaAdmin }))",
+ url: "@Html.Raw(Url.Action("ProductCollectionDelete", "Product", new { area = area }))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
@@ -79,7 +96,7 @@
previousNext: false,
info: false
},
- toolbar: [{ name: "create", text: "@Loc["Admin.Common.AddNewRecord"]" }],
+ toolbar: [{ name: "create", text: "@Loc[$"{Scope.ResourceKeyPrefix}.Common.AddNewRecord"]" }],
edit: function(e) {
if (e.model.isNew()) {
e.model.CollectionId = "";
@@ -92,22 +109,34 @@
scrollable: false,
columns: [{
field: "CollectionId",
- title: "@Loc["Admin.Catalog.Products.Collections.Fields.Collection"]",
+ title: "@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.Collections.Fields.Collection"]",
width: 200,
editor: collectionDropDownEditor,
- template: '<a class="k-link" href="@Url.Action("Edit", "Collection", new { area = Constants.AreaAdmin })/#=CollectionId#">#:Collection#</a>'
+ @if (Scope.ResourceKeyPrefix == "Vendor")
+ {
+ <text>template: '#:Collection#'</text>
+ }
+ else
+ {
+ <text>template: '<a class="k-link" href="@Url.Action("Edit", "Collection", new { area = area })/#=CollectionId#">#:Collection#</a>'</text>
+ }
},
+ @if (Scope.ResourceKeyPrefix != "Vendor")
{
- field: "IsFeaturedProduct",
- title: "@Loc["Admin.Catalog.Products.Collections.Fields.IsFeaturedProduct"]",
- width: 100,
- headerAttributes: { style: "text-align:center" },
- attributes: { style: "text-align:center" },
- template: '# if(IsFeaturedProduct) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
- },
+ <text>
+ {
+ field: "IsFeaturedProduct",
+ title: "@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.Collections.Fields.IsFeaturedProduct"]",
+ width: 100,
+ headerAttributes: { style: "text-align:center" },
+ attributes: { style: "text-align:center" },
+ template: '# if(IsFeaturedProduct) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
+ },
+ </text>
+ }
{
field: "DisplayOrder",
- title: "@Loc["Admin.Catalog.Products.Collections.Fields.DisplayOrder"]",
+ title: "@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.Collections.Fields.DisplayOrder"]",
width: 100,
minScreenWidth: 500,
headerAttributes: { style: "text-align:center" },
@@ -118,13 +147,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: 200
}]
@@ -148,7 +177,7 @@
dataSource: {
transport: {
read: {
- url: "@Html.Raw(Url.Action("Collection", "Search", new { area = Constants.AreaAdmin }))"
+ url: "@Html.Raw(Url.Action("Collection", "Search", new { area = area }))"
}
},
schema: {
@@ -165,6 +194,6 @@
else
{
<div class="note note-info">
- @Loc["Admin.Catalog.Products.Collections.SaveBeforeEdit"]
+ @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.Collections.SaveBeforeEdit"]
</div>
-}
\ No newline at end of file
+}
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Product/Partials/CreateOrUpdate.Collections.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
deleted file mode 100644
index 932bdf443..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
+++ /dev/null
@@ -1,170 +0,0 @@
-@model ProductModel
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="panel panel-default">
- <vc:admin-widget widget-zone="product_details_collections_top" additional-data="Model"/>
- <div class="panel-heading">
- @Loc["Admin.Catalog.Products.Collections.Fields.Collection"]
- </div>
- <div class="panel-body">
- <div id="productcollections-grid"></div>
- </div>
- <vc:admin-widget widget-zone="product_details_collections_bottom" additional-data="Model"/>
- </div>
-
-
- <script>
- $(document).ready(function () {
- $("#productcollections-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("ProductCollectionList", "Product", new { productId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- create: {
- url: "@Html.Raw(Url.Action("ProductCollectionInsert", "Product", new { productId = Model.Id, area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- update: {
- url:"@Html.Raw(Url.Action("ProductCollectionUpdate", "Product", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("ProductCollectionDelete", "Product", new { area = Constants.AreaStore }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- Collection: { editable: true, type: "string" },
- CollectionId: { editable: true, type: "string" },
- IsFeaturedProduct: { editable: true, type: "boolean" },
- DisplayOrder: { editable: true, type: "number" },
- Id: { editable: false, type: "string" }
- }
- }
- },
- requestEnd: function (e) {
- if (e.type == "create" || 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
- },
- toolbar: [{ name: "create", text: "@Loc["Admin.Common.AddNewRecord"]" }],
- edit: function(e) {
- if (e.model.isNew()) {
- e.model.CollectionId = "";
- }
- },
- editable: {
- confirmation: true,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "CollectionId",
- title: "@Loc["Admin.Catalog.Products.Collections.Fields.Collection"]",
- width: 200,
- editor: collectionDropDownEditor,
- template: '<a class="k-link" href="@Url.Action("Edit", "Collection", new { area = Constants.AreaStore })/#=CollectionId#">#:Collection#</a>'
- },
- {
- field: "IsFeaturedProduct",
- title: "@Loc["Admin.Catalog.Products.Collections.Fields.IsFeaturedProduct"]",
- width: 100,
- headerAttributes: { style: "text-align:center" },
- attributes: { style: "text-align:center" },
- template: '# if(IsFeaturedProduct) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
- },
- {
- field: "DisplayOrder",
- title: "@Loc["Admin.Catalog.Products.Collections.Fields.DisplayOrder"]",
- width: 100,
- minScreenWidth: 500,
- headerAttributes: { style: "text-align:center" },
- attributes: { style: "text-align:center" },
- //integer format
- format: "{0:0}"
- }, {
- 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: 200
- }]
- });
- });
-
- function collectionDropDownEditor(container, options) {
- $('<input required data-text-field="Name" data-value-field="Id" data-bind="value:CollectionId"/>')
- .appendTo(container)
- .kendoDropDownList({
- autobind: false,
- optionLabel: "Select collection...",
- filter: "startswith",
- filtering: function (e) {
- var filter = e.filter;
- if (!filter.value) {
- //prevent filtering if the filter does not value
- e.preventDefault();
- }
- },
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("Collection", "Search", new { area = Constants.AreaStore }))"
- }
- },
- schema: {
- data: "Data"
- },
- serverFiltering: true
- },
- dataTextField: "Name",
- dataValueField: "Id",
- });
- }
- </script>
-}
-else
-{
- <div class="note note-info">
- @Loc["Admin.Catalog.Products.Collections.SaveBeforeEdit"]
- </div>
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.Collections.cshtml b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
deleted file mode 100644
index a11b521a6..000000000
--- a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.Collections.cshtml
+++ /dev/null
@@ -1,162 +0,0 @@
-@model ProductModel
-@if (!string.IsNullOrEmpty(Model.Id))
-{
- <div class="panel panel-default">
- <vc:vendor-widget widget-zone="vendor_product_details_collections_top" additional-data="Model"/>
- <div class="panel-heading">
- @Loc["Vendor.Catalog.Products.Collections.Fields.Collection"]
- </div>
- <div class="panel-body">
- <div id="productcollections-grid"></div>
- </div>
- <vc:vendor-widget widget-zone="vendor_product_details_collections_bottom" additional-data="Model"/>
- </div>
-
-
- <script>
- $(document).ready(function () {
- $("#productcollections-grid").kendoGrid({
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("ProductCollectionList", "Product", new { productId = Model.Id, area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- create: {
- url: "@Html.Raw(Url.Action("ProductCollectionInsert", "Product", new { productId = Model.Id, area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- update: {
- url:"@Html.Raw(Url.Action("ProductCollectionUpdate", "Product", new { area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- },
- destroy: {
- url: "@Html.Raw(Url.Action("ProductCollectionDelete", "Product", new { area = Constants.AreaVendor }))",
- type: "POST",
- dataType: "json",
- data: addAntiForgeryToken
- }
- },
- schema: {
- data: "Data",
- total: "Total",
- errors: "Errors",
- model: {
- id: "Id",
- fields: {
- Collection: { editable: true, type: "string" },
- CollectionId: { editable: true, type: "string" },
- IsFeaturedProduct: { editable: true, type: "boolean" },
- DisplayOrder: { editable: true, type: "number" },
- Id: { editable: false, type: "string" }
- }
- }
- },
- requestEnd: function (e) {
- if (e.type == "create" || 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
- },
- toolbar: [{ name: "create", text: "@Loc["Vendor.Common.AddNewRecord"]" }],
- edit: function(e) {
- if (e.model.isNew()) {
- e.model.CollectionId = "";
- }
- },
- editable: {
- confirmation: true,
- mode: "inline"
- },
- scrollable: false,
- columns: [{
- field: "CollectionId",
- title: "@Loc["Vendor.Catalog.Products.Collections.Fields.Collection"]",
- width: 200,
- editor: collectionDropDownEditor,
- template: '#:Collection#'
- },
- {
- field: "DisplayOrder",
- title: "@Loc["Vendor.Catalog.Products.Collections.Fields.DisplayOrder"]",
- width: 100,
- minScreenWidth: 500,
- headerAttributes: { style: "text-align:center" },
- attributes: { style: "text-align:center" },
- //integer format
- format: "{0:0}"
- }, {
- 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: 200
- }]
- });
- });
-
- function collectionDropDownEditor(container, options) {
- $('<input required data-text-field="Name" data-value-field="Id" data-bind="value:CollectionId"/>')
- .appendTo(container)
- .kendoDropDownList({
- autobind: false,
- optionLabel: "Select collection...",
- filter: "startswith",
- filtering: function (e) {
- var filter = e.filter;
- if (!filter.value) {
- //prevent filtering if the filter does not value
- e.preventDefault();
- }
- },
- dataSource: {
- transport: {
- read: {
- url: "@Html.Raw(Url.Action("Collection", "Search", new { area = Constants.AreaVendor }))"
- }
- },
- schema: {
- data: "Data"
- },
- serverFiltering: true
- },
- dataTextField: "Name",
- dataValueField: "Id",
- });
- }
- </script>
-}
-else
-{
- <div class="note note-info">
- @Loc["Vendor.Catalog.Products.Collections.SaveBeforeEdit"]
- </div>
-}
\ No newline at end of file