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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Pages (Topics) CRUD management in Grand.Web.Store (#693)
Copilot3f030cedee65
diff --git a/Directory.Packages.props b/Directory.Packages.propsindex f22ad1651..510f84898 100644--- a/Directory.Packages.props+++ b/Directory.Packages.props@@ -9,7 +9,7 @@<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.7" /><PackageVersion Include="Microsoft.FeatureManagement.AspNetCore" Version="4.5.0" /><PackageVersion Include="Scalar.AspNetCore" Version="2.14.5" />- <PackageVersion Include="Scryber.Core" Version="9.3.1" />+ <PackageVersion Include="Scryber.Core" Version="9.5.0" /><PackageVersion Include="Scryber.Core.OpenType" Version="9.2.0" /><PackageVersion Include="MailKit" Version="4.16.0" /><PackageVersion Include="AWSSDK.Core" Version="4.0.4" />diff --git a/src/Business/Grand.Business.Common/Services/Seo/SeNameService.cs b/src/Business/Grand.Business.Common/Services/Seo/SeNameService.csindex b549f3678..ee249f850 100644--- a/src/Business/Grand.Business.Common/Services/Seo/SeNameService.cs+++ b/src/Business/Grand.Business.Common/Services/Seo/SeNameService.cs@@ -43,7 +43,7 @@ public class SeNameService(ISlugService slugService, ILanguageService languageSeentityUrl.EntityName.Equals(entityName,StringComparison.OrdinalIgnoreCase));- var reserved2 = seoSettings.ReservedEntityUrlSlugs.Contains(tempSeName, StringComparer.OrdinalIgnoreCase);+ var reserved2 = seoSettings.ReservedEntityUrlSlugs?.Contains(tempSeName, StringComparer.OrdinalIgnoreCase) ?? false;var reserved3 = (await languageService.GetAllLanguages(true)).Any(language =>language.UniqueSeoCode.Equals(tempSeName, StringComparison.OrdinalIgnoreCase));diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.csindex d386a0f40..2f22c469d 100644--- a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.cs+++ b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.cs@@ -35,6 +35,28 @@ namespace Grand.Business.Common.Tests.Services.Seo_seNameService = new SeNameService(_mockSlugService.Object, _mockLanguageService.Object, _seoSettings);}+ [Test]+ public async Task ValidateSeName_NullReservedSlugs_DoesNotThrow()+ {+ // Arrange - simulate a MongoDB installation where ReservedEntityUrlSlugs was stored as null+ var settingsWithNullSlugs = new SeoSettings {+ ReservedEntityUrlSlugs = null,+ ConvertNonWesternChars = false,+ AllowUnicodeCharsInUrls = false,+ AllowSlashChar = false,+ SeoCharConversion = null+ };+ var serviceWithNullSettings = new SeNameService(+ _mockSlugService.Object, _mockLanguageService.Object, settingsWithNullSlugs);++ var entity = new TestEntity { Id = "123" };+ _mockSlugService.Setup(s => s.GetBySlug(It.IsAny<string>())).ReturnsAsync((EntityUrl)null);++ // Act & Assert – should not throw ArgumentNullException+ var result = await serviceWithNullSettings.ValidateSeName(entity, "my-page", "My Page", false);+ ClassicAssert.AreEqual("my-page", result);+ }+[Test]public async Task ValidateSeName_ShouldReturnName_WhenSeNameIsEmpty(){diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Page/List.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Page/List.cshtmlindex 76dfa92c5..060c3bedb 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Page/List.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Page/List.cshtml@@ -1,4 +1,5 @@-@model PageListModel+@inject AdminAreaSettings adminAreaSettings+@model PageListModel@{//page titleViewBag.Title = Loc["Admin.Content.Pages"];@@ -77,15 +78,14 @@// Cancel the changesthis.cancelChanges();},+ pageSize: @(adminAreaSettings.DefaultGridPageSize),serverPaging: true,serverFiltering: true,serverSorting: true},pageable: {refresh: true,- numeric: false,- previousNext: false,- info: false+ pageSizes: [@(adminAreaSettings.GridPageSizes)]},editable: {confirmation: false,@@ -97,12 +97,9 @@title: "@Loc["Admin.Content.Pages.Fields.SystemName"]",template: '<a class="k-link" href="Edit/#=Id#">#=SystemName#</a>',}, {- field: "IsPasswordProtected",- title: "@Loc["Admin.Content.Pages.Fields.IsPasswordProtected"]",- width: 100,- headerAttributes: { style: "text-align:center" },- attributes: { style: "text-align:center" },- template: '# if(IsPasswordProtected) {# <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: "Title",+ title: "@Loc["Admin.Content.Pages.Fields.Title"]",+ template: '#=kendo.htmlEncode(Title == null ? "" : Title)#',}, {field: "IncludeInMenu",title: "@Loc["Admin.Content.Pages.Fields.IncludeInMenu"]",@@ -110,6 +107,13 @@headerAttributes: { style: "text-align:center" },attributes: { style: "text-align:center" },template: '# if(IncludeInMenu) {# <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: "Published",+ title: "@Loc["Admin.Content.Pages.Fields.Published"]",+ width: 100,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(Published) {# <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.Content.Pages.Fields.DisplayOrder"]",diff --git a/src/Web/Grand.Web.Admin/Controllers/PageController.cs b/src/Web/Grand.Web.Admin/Controllers/PageController.csindex 01ae93cf3..e5e91301e 100644--- a/src/Web/Grand.Web.Admin/Controllers/PageController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/PageController.cs@@ -75,9 +75,11 @@ public class PageController : BaseAdminController(x.Title != null && x.Title.ToLowerInvariant().Contains(model.Name.ToLowerInvariant()))).ToList();//"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "foreach (var page in pageModels) page.Body = "";+ var total = pageModels.Count;+ var pagedData = pageModels.Skip((command.Page - 1) * command.PageSize).Take(command.PageSize).ToList();var gridModel = new DataSourceResult {- Data = pageModels,- Total = pageModels.Count+ Data = pagedData,+ Total = total};return Json(gridModel);diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Create.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Create.cshtmlnew file mode 100644index 000000000..26b02c71f--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Create.cshtml@@ -0,0 +1,37 @@+@model PageModel+@{+ //page title+ ViewBag.Title = Loc["Admin.Content.Pages.AddNew"];+ Layout = Constants.LayoutStore;+}+<form asp-area="@Constants.AreaStore" asp-controller="Page" asp-action="Create" method="post">++ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-fw fa-file-o"></i>+ @Loc["Admin.Content.Pages.AddNew"]+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.Pages.BackToList"], "List")+ </small>+ </div>+ <div class="actions">+ <div class="btn-group btn-group-devided">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button>+ </div>+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Edit.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Edit.cshtmlnew file mode 100644index 000000000..4262faa6d--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Edit.cshtml@@ -0,0 +1,60 @@+@model PageModel+@{+ //page title+ ViewBag.Title = Loc["Admin.Content.Pages.EditPageDetails"];+ Layout = Constants.LayoutStore;+}+<form asp-area="@Constants.AreaStore" asp-controller="Page" asp-action="Edit" method="post">++ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-fw fa-file-o"></i>+ @Loc["Admin.Content.Pages.EditPageDetails"] - @Model.SystemName+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.Pages.BackToList"], "List")+ </small>+ </div>+ <div class="actions">+ <div class="btn-group btn-group-devided">+ @if (!string.IsNullOrEmpty(Model.SeName))+ {+ <button type="button" onclick="window.open('@Url.RouteUrl("Page", new { Model.SeName })','_blank');" class="btn purple">+ <i class="fa fa-eye"></i>+ @Loc["Admin.Common.Preview"]+ </button>+ }+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button>+ @if (ViewBag.ShowCopyButton == true)+ {+ <button type="submit" form="page-copy-form" class="btn blue">+ <i class="fa fa-copy"></i> @Loc["Admin.Common.Copy"]+ </button>+ }+ <span id="page-delete" class="btn red">+ <i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]+ </span>+ </div>+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>+<admin-delete-confirmation button-id="page-delete"/>+@if (ViewBag.ShowCopyButton == true)+{+ <form id="page-copy-form" asp-area="@Constants.AreaStore" asp-controller="Page" asp-action="Copy" method="post">+ <input type="hidden" name="id" value="@Model.Id"/>+ </form>+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Page/List.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/List.cshtmlnew file mode 100644index 000000000..1e9f4124c--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/List.cshtml@@ -0,0 +1,166 @@+@model PageListModel+@inject AdminAreaSettings adminAreaSettings+@{+ //page title+ ViewBag.Title = Loc["Admin.Content.Pages"];+ Layout = Constants.LayoutStore;+}++<div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-fw fa-file-o"></i>+ @Loc["Admin.Content.Pages"]+ </div>+ <div class="actions btn-group btn-group-devided">+ <a href="@Url.Action("Create", new { area = Constants.AreaStore })" class="btn green">+ <i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>+ </a>+ </div>+ </div>+ <div class="x_content">+ <div class="form-horizontal">+ <div class="form-body">+ <div class="row align-items-end mb-1">+ <div class="col-md-9 col-sm-12 col-12">+ <div class="form-group mb-0">+ <admin-label asp-for="Name" class="d-flex flex-column align-items-start mw-100 px-0 text-left"/>+ <admin-input asp-for="Name"/>+ </div>+ </div>+ <div class="col-md-3 col-sm-12 col-12 mt-md-0 mt-3">+ <div class="form-actions">+ <button class="btn btn-success filter-submit" id="search-pages">+ <i class="fa fa-search"></i> @Loc["Admin.Common.Search"]+ </button>+ </div>+ </div>+ </div>+ </div>+ <div class="x_content">+ <admin-tabstrip name="pages-list-tabs" BindGrid="true">+ <items>+ <tabstrip-item text="@Loc["Admin.Content.Pages.List.StorePages"]" tab-index="0">+ <content>+ <div id="store-pages-grid"></div>+ </content>+ </tabstrip-item>+ <tabstrip-item text="@Loc["Admin.Content.Pages.List.GlobalPages"]" tab-index="1">+ <content>+ <div id="global-pages-grid"></div>+ </content>+ </tabstrip-item>+ </items>+ </admin-tabstrip>+ </div>+ </div>+ </div>+ </div>+ </div>+</div>++<script>+ $(document).ready(function () {+ var gridColumns = [{+ field: "SystemName",+ title: "@Loc["Admin.Content.Pages.Fields.SystemName"]",+ template: '<a class="k-link" href="Edit/#=Id#">#=SystemName#</a>',+ }, {+ field: "Title",+ title: "@Loc["Admin.Content.Pages.Fields.Title"]",+ template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Title == null ? "" : Title)#</a>',+ }, {+ field: "IncludeInMenu",+ title: "@Loc["Admin.Content.Pages.Fields.IncludeInMenu"]",+ width: 100,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IncludeInMenu) {# <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: "Published",+ title: "@Loc["Admin.Content.Pages.Fields.Published"]",+ width: 100,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(Published) {# <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.Content.Pages.Fields.DisplayOrder"]",+ width: 100+ }];++ function makeDataSource(url) {+ return {+ transport: {+ read: {+ url: url,+ type: "POST",+ dataType: "json",+ data: additionalData+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors"+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ pageSize: @(adminAreaSettings.DefaultGridPageSize),+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ };+ }++ function makeGrid(selector, url) {+ $(selector).kendoGrid({+ dataSource: makeDataSource(url),+ pageable: {+ refresh: true,+ pageSizes: [@(adminAreaSettings.GridPageSizes)]+ },+ editable: {+ confirmation: false,+ mode: "inline"+ },+ scrollable: false,+ columns: gridColumns+ });+ }++ makeGrid("#store-pages-grid", "@Html.Raw(Url.Action("StorePagesList", "Page", new { area = Constants.AreaStore }))");+ makeGrid("#global-pages-grid", "@Html.Raw(Url.Action("GlobalPagesList", "Page", new { area = Constants.AreaStore }))");+ });+</script>++<script>+ $(document).ready(function () {+ $('#search-pages').click(function () {+ var sg = $('#store-pages-grid').data('kendoGrid');+ if (sg) sg.dataSource.read();+ var gg = $('#global-pages-grid').data('kendoGrid');+ if (gg) gg.dataSource.read();+ return false;+ });++ $("#@Html.IdFor(model => model.Name)").keydown(function (event) {+ if (event.keyCode == 13) {+ $("#search-pages").click();+ return false;+ }+ });+ });++ function additionalData() {+ var data = {+ Name: $('#@Html.IdFor(model => model.Name)').val()+ };+ addAntiForgeryToken(data);+ return data;+ }+</script>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.TabInfo.cshtmlnew file mode 100644index 000000000..a090bfe7d--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.TabInfo.cshtml@@ -0,0 +1,193 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model PageModel++<script>+$(document).ready(function() {+ $("#@Html.IdFor(model => model.IsPasswordProtected)").click(togglePassword);+ togglePassword();+});++function togglePassword() {+ if ($('#@Html.IdFor(model => model.IsPasswordProtected)').is(':checked')) {+ $('#pnlPasswordEnabled').show();+ } else {+ $('#pnlPasswordEnabled').hide();+ }+}+</script>++@{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Title"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Title"/>+ <span asp-validation-for="@Model.Locales[item].Title"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Body"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Body" asp-template="Editor"/>+ <span asp-validation-for="@Model.Locales[item].Body"></span>+ </div>+ </div>+ <input asp-for="@Model.Locales[item].LanguageId" type="hidden"/>+ </div>;+}++<div class="form-horizontal">+ <localized-editor localized-template="@template" name="page-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="Title"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Title"/>+ <span asp-validation-for="Title"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="Body"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Body" asp-template="Editor"/>+ <span asp-validation-for="Body"></span>+ </div>+ </div>+ </div>+ </localized-editor>++ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="SystemName"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="SystemName"/>+ <span asp-validation-for="SystemName"></span>+ </div>+ </div>+ @if (!string.IsNullOrEmpty(Model.Id))+ {+ <div class="form-group">+ <admin-label asp-for="Url"/>+ <div class="col-md-9 col-sm-9">+ <label class="control-label">+ <a href="@Model.Url">@Model.Url</a>+ </label>+ </div>+ </div>+ }+ <div class="form-group">+ <admin-label asp-for="IsPasswordProtected"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IsPasswordProtected"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IsPasswordProtected"></span>+ </div>+ </div>+ <div class="form-group" id="pnlPasswordEnabled">+ <admin-label asp-for="Password"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Password" autocomplete="off"/>+ <span asp-validation-for="Password"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="IncludeInSitemap"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IncludeInSitemap"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IncludeInSitemap"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="IncludeInMenu"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IncludeInMenu"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IncludeInMenu"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="IncludeInFooterRow1"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IncludeInFooterRow1"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IncludeInFooterRow1"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="IncludeInFooterRow2"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IncludeInFooterRow2"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IncludeInFooterRow2"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="IncludeInFooterRow3"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IncludeInFooterRow3"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IncludeInFooterRow3"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="DisplayOrder"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="DisplayOrder"/>+ <span asp-validation-for="DisplayOrder"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="AccessibleWhenStoreClosed"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="AccessibleWhenStoreClosed"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="AccessibleWhenStoreClosed"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="PageLayoutId"/>+ <div class="col-md-9 col-sm-9">+ <admin-select asp-for="PageLayoutId" asp-items="Model.AvailablePageLayouts"/>+ <span asp-validation-for="PageLayoutId"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="Published"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="Published"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="Published"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="StartDateUtc"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="StartDateUtc"/>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="EndDateUtc"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="EndDateUtc"/>+ </div>+ </div>+ </div>+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.TabSeo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.TabSeo.cshtmlnew file mode 100644index 000000000..0c7e64b27--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.TabSeo.cshtml@@ -0,0 +1,72 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model PageModel++@{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].MetaKeywords"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].MetaKeywords"/>+ <span asp-validation-for="@Model.Locales[item].MetaKeywords"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].MetaDescription"/>+ <div class="col-md-9 col-sm-9">+ <admin-textarea asp-for="@Model.Locales[item].MetaDescription"></admin-textarea>+ <span asp-validation-for="@Model.Locales[item].MetaDescription"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].MetaTitle"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].MetaTitle"/>+ <span asp-validation-for="@Model.Locales[item].MetaTitle"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].SeName"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].SeName"/>+ <span asp-validation-for="@Model.Locales[item].SeName"></span>+ </div>+ </div>+ <input asp-for="@Model.Locales[item].LanguageId" type="hidden"/>+ </div>;+}++<div class="form-horizontal">+ <localized-editor localized-template="@template" name="page-seo-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="MetaKeywords"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="MetaKeywords"/>+ <span asp-validation-for="MetaKeywords"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="MetaDescription"/>+ <div class="col-md-9 col-sm-9">+ <admin-textarea asp-for="MetaDescription"></admin-textarea>+ <span asp-validation-for="MetaDescription"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="MetaTitle"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="MetaTitle"/>+ <span asp-validation-for="MetaTitle"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="SeName"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="SeName"/>+ <span asp-validation-for="SeName"></span>+ </div>+ </div>+ </div>+ </localized-editor>+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.cshtmlnew file mode 100644index 000000000..8ceb8a57e--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Page/Partials/CreateOrUpdate.cshtml@@ -0,0 +1,22 @@+@model PageModel++<div asp-validation-summary="All"></div>+<input asp-for="Id" type="hidden"/>+<admin-tabstrip name="page-edit">+ <items>+ <tabstrip-item text="@Loc["Admin.Content.Pages.Info"]" tab-index="0">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabInfo" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ <tabstrip-item text="@Loc["Admin.Common.SEO"]" tab-index="1">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabSeo" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ </items>+</admin-tabstrip>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtmlindex bb0768c2b..af197fbf1 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml@@ -32,6 +32,7 @@@using Grand.Web.AdminShared.Models.News@using Grand.Web.AdminShared.Models.Blogs@using Grand.Web.AdminShared.Models.Messages+@using Grand.Web.AdminShared.Models.Pages@inject LocService Loc@inject IEnumTranslationService EnumTranslationService\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Controllers/PageController.cs b/src/Web/Grand.Web.Store/Controllers/PageController.csnew file mode 100644index 000000000..1af17dfb3--- /dev/null+++ b/src/Web/Grand.Web.Store/Controllers/PageController.cs@@ -0,0 +1,283 @@+using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Cms;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Domain.Permissions;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Extensions;+using Grand.Web.AdminShared.Extensions.Mapping;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Pages;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Filters;+using Grand.Web.Common.Security.Authorization;+using Microsoft.AspNetCore.Mvc;++namespace Grand.Web.Store.Controllers;++[PermissionAuthorize(PermissionSystemName.Pages)]+public class PageController : BaseStoreController+{+ #region Constructors++ public PageController(+ IPageViewModelService pageViewModelService,+ IPageService pageService,+ ILanguageService languageService,+ ITranslationService translationService,+ IContextAccessor contextAccessor,+ IDateTimeService dateTimeService)+ {+ _pageViewModelService = pageViewModelService;+ _pageService = pageService;+ _languageService = languageService;+ _translationService = translationService;+ _contextAccessor = contextAccessor;+ _dateTimeService = dateTimeService;+ }++ #endregion++ #region Fields++ private readonly IPageViewModelService _pageViewModelService;+ private readonly IPageService _pageService;+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;+ private readonly IContextAccessor _contextAccessor;+ private readonly IDateTimeService _dateTimeService;++ #endregion++ #region List++ public IActionResult Index()+ {+ return RedirectToAction("List");+ }++ public IActionResult List()+ {+ return View();+ }++ [PermissionAuthorizeAction(PermissionActionName.List)]+ [HttpPost]+ public async Task<IActionResult> StorePagesList(DataSourceRequest command, PageListModel model)+ {+ var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;+ var pages = await _pageService.GetAllPages(storeId, true);++ // Store-specific: exclusively assigned to this one store+ var pageModels = pages+ .Where(x => x.LimitedToStores && x.Stores.Count == 1)+ .Select(x => x.ToModel(_dateTimeService))+ .ToList();++ if (!string.IsNullOrEmpty(model.Name))+ pageModels = pageModels.Where(x =>+ x.SystemName.ToLowerInvariant().Contains(model.Name.ToLowerInvariant()) ||+ (x.Title != null && x.Title.ToLowerInvariant().Contains(model.Name.ToLowerInvariant()))).ToList();++ foreach (var page in pageModels) page.Body = "";++ var total = pageModels.Count;+ var pagedData = pageModels.Skip((command.Page - 1) * command.PageSize).Take(command.PageSize).ToList();+ return Json(new DataSourceResult { Data = pagedData, Total = total });+ }++ [PermissionAuthorizeAction(PermissionActionName.List)]+ [HttpPost]+ public async Task<IActionResult> GlobalPagesList(DataSourceRequest command, PageListModel model)+ {+ var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;+ var pages = await _pageService.GetAllPages(storeId, true);++ // Global: no store restriction, or shared across multiple stores+ var pageModels = pages+ .Where(x => !x.LimitedToStores || x.Stores.Count > 1)+ .Select(x => x.ToModel(_dateTimeService))+ .ToList();++ if (!string.IsNullOrEmpty(model.Name))+ pageModels = pageModels.Where(x =>+ x.SystemName.ToLowerInvariant().Contains(model.Name.ToLowerInvariant()) ||+ (x.Title != null && x.Title.ToLowerInvariant().Contains(model.Name.ToLowerInvariant()))).ToList();++ foreach (var page in pageModels) page.Body = "";++ var total = pageModels.Count;+ var pagedData = pageModels.Skip((command.Page - 1) * command.PageSize).Take(command.PageSize).ToList();+ return Json(new DataSourceResult { Data = pagedData, Total = total });+ }++ #endregion++ #region Create / Edit / Delete++ [PermissionAuthorizeAction(PermissionActionName.Create)]+ public async Task<IActionResult> Create()+ {+ ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);+ var model = new PageModel {+ DisplayOrder = 1,+ Published = true+ };+ await _pageViewModelService.PrepareLayoutsModel(model);+ await AddLocales(_languageService, model.Locales);+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ public async Task<IActionResult> Create(PageModel model, bool continueEditing)+ {+ if (ModelState.IsValid)+ {+ model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];+ var page = await _pageViewModelService.InsertPageModel(model);+ Success(_translationService.GetResource("Admin.Content.Pages.Added"));+ return continueEditing ? RedirectToAction("Edit", new { id = page.Id }) : RedirectToAction("List");+ }++ //If we got this far, something failed, redisplay form+ ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);+ await _pageViewModelService.PrepareLayoutsModel(model);+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> Edit(string id)+ {+ var page = await _pageService.GetPageById(id);+ if (page == null)+ return RedirectToAction("List");++ if (!page.LimitedToStores || (page.Stores.Contains(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId) &&+ page.Stores.Count > 1))+ {+ Warning(_translationService.GetResource("Admin.Content.Pages.Permissions"));+ }+ else+ {+ if (!page.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("List");+ }++ ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);+ ViewBag.ShowCopyButton = !page.LimitedToStores || page.Stores.Count > 1;+ var model = page.ToModel(_dateTimeService);+ model.Url = Url.RouteUrl("Page", new { SeName = page.GetSeName(_contextAccessor.WorkContext.WorkingLanguage.Id) }, Request.Scheme);+ await _pageViewModelService.PrepareLayoutsModel(model);+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Title = page.GetTranslation(x => x.Title, languageId, false);+ locale.Body = page.GetTranslation(x => x.Body, languageId, false);+ locale.MetaKeywords = page.GetTranslation(x => x.MetaKeywords, languageId, false);+ locale.MetaDescription = page.GetTranslation(x => x.MetaDescription, languageId, false);+ locale.MetaTitle = page.GetTranslation(x => x.MetaTitle, languageId, false);+ locale.SeName = page.GetSeName(languageId, false);+ });+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ public async Task<IActionResult> Edit(PageModel model, bool continueEditing)+ {+ var page = await _pageService.GetPageById(model.Id);+ if (page == null)+ return RedirectToAction("List");++ if (!page.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("Edit", new { id = page.Id });++ if (ModelState.IsValid)+ {+ model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];+ model.CustomerGroups = page.CustomerGroups.ToArray();+ page = await _pageViewModelService.UpdatePageModel(page, model);+ Success(_translationService.GetResource("Admin.Content.Pages.Updated"));++ if (continueEditing)+ {+ await SaveSelectedTabIndex();+ return RedirectToAction("Edit", new { id = page.Id });+ }++ return RedirectToAction("List");+ }++ //If we got this far, something failed, redisplay form+ ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);+ model.Url = Url.RouteUrl("Page", new { SeName = page.GetSeName(_contextAccessor.WorkContext.WorkingLanguage.Id) }, "http");+ await _pageViewModelService.PrepareLayoutsModel(model);+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Delete)]+ [HttpPost]+ public async Task<IActionResult> Delete(string id)+ {+ var page = await _pageService.GetPageById(id);+ if (page == null)+ return RedirectToAction("List");++ if (!page.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("List");++ await _pageViewModelService.DeletePage(page);+ Success(_translationService.GetResource("Admin.Content.Pages.Deleted"));+ return RedirectToAction("List");+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ [HttpPost]+ public async Task<IActionResult> Copy(string id)+ {+ var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;+ var page = await _pageService.GetPageById(id);+ if (page == null)+ return RedirectToAction("List");++ if (!page.AccessToEntityByStore(storeId))+ return RedirectToAction("List");++ // Only allow copy for multistore or store-unrestricted topics+ if (page.LimitedToStores && page.Stores.Count <= 1)+ return RedirectToAction("Edit", new { id });++ // Check if a page with the same SystemName already exists for the current store+ var storePages = await _pageService.GetAllPages(storeId, true);+ if (storePages.Any(p => p.Id != page.Id &&+ p.SystemName.Equals(page.SystemName, StringComparison.OrdinalIgnoreCase)))+ {+ Error(_translationService.GetResource("Admin.Content.Pages.Copy.DuplicateSystemName"));+ return RedirectToAction("Edit", new { id });+ }++ // Build copy model from original page+ var model = page.ToModel(_dateTimeService);+ model.Id = "";+ model.Stores = [storeId];++ // Preserve localized content+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Title = page.GetTranslation(x => x.Title, languageId, false);+ locale.Body = page.GetTranslation(x => x.Body, languageId, false);+ locale.MetaKeywords = page.GetTranslation(x => x.MetaKeywords, languageId, false);+ locale.MetaDescription = page.GetTranslation(x => x.MetaDescription, languageId, false);+ locale.MetaTitle = page.GetTranslation(x => x.MetaTitle, languageId, false);+ locale.SeName = page.GetSeName(languageId, false);+ });++ var newPage = await _pageViewModelService.InsertPageModel(model);+ Success(_translationService.GetResource("Admin.Content.Pages.Added"));+ return RedirectToAction("Edit", new { id = newPage.Id });+ }++ #endregion+}diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xmlindex 743f71b17..4ed1399d6 100644Binary files a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml and b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml differ