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
Extend news management from Admin to Store with full CRUD operations and configurable per-store limits (#617)
Copilot88acb8b01d21
diff --git a/src/Modules/Grand.Module.Installer/Extensions/PermissionExtensions.cs b/src/Modules/Grand.Module.Installer/Extensions/PermissionExtensions.csindex 729f88c5b..0638e318d 100644--- a/src/Modules/Grand.Module.Installer/Extensions/PermissionExtensions.cs+++ b/src/Modules/Grand.Module.Installer/Extensions/PermissionExtensions.cs@@ -212,7 +212,8 @@ public static class PermissionExtensionsStandardPermission.ManageShipments,StandardPermission.ManageMerchandiseReturns,StandardPermission.ManageCheckoutAttribute,- StandardPermission.ManageReports+ StandardPermission.ManageReports,+ StandardPermission.ManageNews]},diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/Content.TabNewsSettings.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/Content.TabNewsSettings.cshtmlindex 580e0d861..1defad5c8 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/Content.TabNewsSettings.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/Content.TabNewsSettings.cshtml@@ -67,6 +67,6 @@<admin-input asp-for="NewsSettings.NewsArchivePageSize"/><span asp-validation-for="NewsSettings.NewsArchivePageSize"></span></div>- </div>+ </div></div></div>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Controllers/NewsController.cs b/src/Web/Grand.Web.Admin/Controllers/NewsController.csindex 4c4e9b8d3..e84b124b7 100644--- a/src/Web/Grand.Web.Admin/Controllers/NewsController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/NewsController.cs@@ -203,8 +203,7 @@ public class NewsController : BaseAdminController[HttpPost]public async Task<IActionResult> Comments(string filterByNewsItemId, DataSourceRequest command){- var comments =- await _newsViewModelService.PrepareNewsCommentModel(filterByNewsItemId, command.Page, command.PageSize);+ var comments = await _newsViewModelService.PrepareNewsCommentModel(filterByNewsItemId, command.Page, command.PageSize);var gridModel = new DataSourceResult {Data = comments.newsCommentModels.ToList(),diff --git a/src/Web/Grand.Web.AdminShared/Models/News/NewsItemListModel.cs b/src/Web/Grand.Web.AdminShared/Models/News/NewsItemListModel.csindex 14e25b1c6..97f8f8856 100644--- a/src/Web/Grand.Web.AdminShared/Models/News/NewsItemListModel.cs+++ b/src/Web/Grand.Web.AdminShared/Models/News/NewsItemListModel.cs@@ -9,5 +9,8 @@ public class NewsItemListModel : BaseModel[GrandResourceDisplayName("Admin.Content.News.NewsItems.List.SearchStore")]public string SearchStoreId { get; set; }+ [GrandResourceDisplayName("Admin.Content.News.NewsItems.List.SearchTitle")]+ public string SearchNewsTitle { get; set; }+public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();}\ No newline at end of filediff --git a/src/Web/Grand.Web.AdminShared/Services/NewsViewModelService.cs b/src/Web/Grand.Web.AdminShared/Services/NewsViewModelService.csindex a58b1d3df..e4c6eede6 100644--- a/src/Web/Grand.Web.AdminShared/Services/NewsViewModelService.cs+++ b/src/Web/Grand.Web.AdminShared/Services/NewsViewModelService.cs@@ -49,7 +49,7 @@ public class NewsViewModelService : INewsViewModelServicepublic virtual async Task<(IEnumerable<NewsItemModel> newsItemModels, int totalCount)> PrepareNewsItemModel(NewsItemListModel model, int pageIndex, int pageSize){- var news = await _newsService.GetAllNews(model.SearchStoreId, pageIndex - 1, pageSize, true, true);+ var news = await _newsService.GetAllNews(model.SearchStoreId, pageIndex - 1, pageSize, true, true, model.SearchNewsTitle);return (news.Select(x =>{var m = x.ToModel(_dateTimeService);diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/Create.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Create.cshtmlnew file mode 100644index 000000000..53e393735--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Create.cshtml@@ -0,0 +1,38 @@+@model NewsItemModel+@{+ //page title+ ViewBag.Title = Loc["Admin.Content.News.NewsItems.AddNew"];+ Layout = Constants.LayoutStore;+}+<form asp-area="@Constants.AreaStore" asp-controller="News" 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-hacker-news"></i>+ @Loc["Admin.Content.News.NewsItems.AddNew"]+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.News.NewsItems.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>+ <vc:admin-widget widget-zone="news_details_buttons" additional-data="null"/>+ </div>+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/Edit.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Edit.cshtmlnew file mode 100644index 000000000..2e2ea0f40--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Edit.cshtml@@ -0,0 +1,46 @@+@model NewsItemModel+@{+ //page title+ ViewBag.Title = Loc["Admin.Content.News.NewsItems.EditNewsItemDetails"];+ Layout = Constants.LayoutStore;+}+<form asp-area="@Constants.AreaStore" asp-controller="News" 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-hacker-news"></i>+ @Loc["Admin.Content.News.NewsItems.EditNewsItemDetails"] - @Model.Title+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Content.News.NewsItems.BackToList"], "List")+ </small>+ </div>+ <div class="actions">+ <div class="btn-group btn-group-devided">+ <button type="button" onclick="window.open('@Url.RouteUrl("NewsItem", 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>+ <span id="newsitem-delete" class="btn red">+ <i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]+ </span>+ <vc:admin-widget widget-zone="news_details_buttons" additional-data="Model"/>+ </div>+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>+<admin-delete-confirmation button-id="newsitem-delete"/>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/List.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/List.cshtmlnew file mode 100644index 000000000..c2eb9c2c0--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/List.cshtml@@ -0,0 +1,131 @@+@model NewsItemListModel+@inject AdminAreaSettings adminAreaSettings+@{+ //page title+ ViewBag.Title = Loc["Admin.Content.News.NewsItems"];+ 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-hacker-news"></i>+ @Loc["Admin.Content.News.NewsItems"]+ </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>+ <vc:admin-widget widget-zone="news_list_buttons" additional-data="null" />+ </div>+ </div>+ <div class="x_content">+ <div class="form-horizontal">+ <div class="form-body">+ <div class="x_content">+ <div id="newsitem-grid"></div>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+</div>+<script>+ $(document).ready(function () {+ $("#newsitem-grid").kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("List", "News", new { area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: additionalData+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors"+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ // Cancel the changes+ this.cancelChanges();+ },+ pageSize: @(adminAreaSettings.DefaultGridPageSize),+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: {+ refresh: true,+ pageSizes: [@(adminAreaSettings.GridPageSizes)]+ },+ editable: {+ confirmation: false,+ mode: "inline"+ },+ scrollable: false,+ columns: [{+ field: "Title",+ width: 300,+ title: "@Loc["Admin.Content.News.NewsItems.Fields.Title"]",+ template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Title)#</a>',+ }, {+ field: "Comments",+ title: "@Loc["Admin.Content.News.NewsItems.Fields.Comments"]",+ width: 200,+ template: '<a class="k-link" href="Edit/#=Id#">@Loc["Admin.Content.News.NewsItems.Fields.Comments"] - #=Comments# </a>'+ }, {+ field: "StartDate",+ title: "@Loc["Admin.Content.News.NewsItems.Fields.StartDate"]",+ width: 150,+ type: "date",+ format: "{0:G}"+ }, {+ field: "EndDate",+ title: "@Loc["Admin.Content.News.NewsItems.Fields.EndDate"]",+ width: 150,+ type: "date",+ format: "{0:G}"+ }, {+ field: "Published",+ title: "@Loc["Admin.Content.News.NewsItems.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: "CreatedOn",+ title: "@Loc["Admin.Content.News.NewsItems.Fields.CreatedOn"]",+ width: 200,+ type: "date",+ format: "{0:G}"+ }]+ });+ });+</script>+<script>++ $(document).ready(function () {+ //search button+ $('#search-newsitem').click(function () {+ //search+ var grid = $('#newsitem-grid').data('kendoGrid');+ grid.dataSource.page(1); //new search. Set page size to 1+ //grid.dataSource.read(); we already loaded the grid above using "page" function+ return false;+ });+ });++ function additionalData() {+ var data = {+ SearchNewsTitle: ''+ };+ addAntiForgeryToken(data);+ return data;+ }+</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabComments.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabComments.cshtmlnew file mode 100644index 000000000..266dc45ae--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabComments.cshtml@@ -0,0 +1,96 @@+@model NewsItemModel+@inject AdminAreaSettings adminAreaSettings+<vc:admin-widget widget-zone="news_details_comments_list" additional-data="Model"/>+@if (!string.IsNullOrEmpty(Model.Id))+{+ <div class="panel panel-default">+ <vc:admin-widget widget-zone="news_details_comments_top" additional-data="Model"/>+ <div class="panel-body">+ <div id="comments-grid"></div>+ </div>+ <vc:admin-widget widget-zone="news_details_comments_bottom" additional-data="Model"/>+ </div>+ <script>+ $(document).ready(function () {+ $("#comments-grid").kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Url.Action("Comments", "News", new { filterByNewsItemId = Model.Id, area = Constants.AreaStore })",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ },+ destroy: {+ url: "@Html.Raw(Url.Action("CommentDelete", "News", new { area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors",+ model: {+ id: "Id",+ fields: {+ //do not implicitly specify all fields+ //we do it only for fields which implicitly require it+ //otherwise, they'll be formatted wrong way+ CreatedOn: {type: "date" }+ }+ }+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ // Cancel the changes+ this.cancelChanges();+ },+ pageSize: @(adminAreaSettings.DefaultGridPageSize),+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: {+ refresh: true,+ pageSizes: [@(adminAreaSettings.GridPageSizes)]+ },+ editable: {+ confirmation: true,+ mode: "inline"+ },+ scrollable: false,+ columns: [{+ field: "CustomerId",+ title: "@Loc["Admin.Content.News.Comments.Fields.Customer"]",+ width: 200,+ template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaStore })/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'+ }, {+ field: "CommentTitle",+ title: "@Loc["Admin.Content.News.Comments.Fields.CommentTitle"]"+ }, {+ field: "CommentText",+ title: "@Loc["Admin.Content.News.Comments.Fields.CommentText"]",+ encoded: false+ }, {+ field: "CreatedOn",+ title: "@Loc["Admin.Content.News.Comments.Fields.CreatedOn"]",+ width: 200,+ type: "date",+ format: "{0:G}"+ }, {+ command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },+ title: "@Loc["Admin.Common.Delete"]",+ width: 100+ }]+ });+ });+ </script>+}+else+{+ <div class="note note-info">+ @Loc["Admin.Content.News.NewsItems.SaveBeforeEdit"]+ </div>+}\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabInfo.cshtmlnew file mode 100644index 000000000..c0a489daa--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabInfo.cshtml@@ -0,0 +1,101 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model NewsItemModel++@{+ 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].Short"/>+ <div class="col-md-9 col-sm-9">+ <admin-textarea asp-for="@Model.Locales[item].Short"></admin-textarea>+ <span asp-validation-for="@Model.Locales[item].Short"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Full"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Full" asp-template="Editor"/>+ <span asp-validation-for="@Model.Locales[item].Full"></span>+ </div>+ </div>+ <input asp-for="Locales[item].LanguageId" type="hidden"/>+ </div>;+}++<div class="form-horizontal">+ <vc:admin-widget widget-zone="news_details_info_top" additional-data="Model"/>+ <div class="form-body">+ <localized-editor localized-template="@template" name="newsitem-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <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="Short"/>+ <div class="col-md-9 col-sm-9">+ <admin-textarea asp-for="Short"></admin-textarea>+ <span asp-validation-for="Short"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="Full"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Full" asp-template="Editor"/>+ <span asp-validation-for="Full"></span>+ </div>+ </div>+ </localized-editor>+ <div class="form-group">+ <admin-label asp-for="PictureId"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="PictureId"/>+ <span asp-validation-for="PictureId"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="AllowComments"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="AllowComments"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="AllowComments"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="StartDate"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="StartDate"/>+ <span asp-validation-for="StartDate"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="EndDate"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="EndDate"/>+ <span asp-validation-for="EndDate"></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>+ <vc:admin-widget widget-zone="news_details_info_bottom" additional-data="Model"/>+</div>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabSeo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabSeo.cshtmlnew file mode 100644index 000000000..2f504cbfe--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.TabSeo.cshtml@@ -0,0 +1,75 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model NewsItemModel++<vc:admin-widget widget-zone="news_details_seo_top" additional-data="Model"/>+@{+ 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="newsitem-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>+<vc:admin-widget widget-zone="news_details_seo_bottom" additional-data="Model"/>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.cshtmlnew file mode 100644index 000000000..9e3c8074e--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/News/Partials/CreateOrUpdate.cshtml@@ -0,0 +1,30 @@+@model NewsItemModel++<div asp-validation-summary="All"></div>+<input asp-for="Id" type="hidden"/>+<admin-tabstrip name="news-edit">+ <items>+ <tabstrip-item text="@Loc["Admin.Content.News.NewsItems.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>+ <tabstrip-item text="@Loc["Admin.Content.News.NewsItems.Comments"]" tab-index="2">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabComments" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ <vc:admin-widget widget-zone="news_details_tabs" additional-data="Model"/>+ </items>+</admin-tabstrip>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtmlindex baff7dc33..d9c332025 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml@@ -29,6 +29,7 @@@using Grand.Web.AdminShared.Models.Common@using Grand.Web.AdminShared.Models.Customers@using Grand.Web.AdminShared.Models.Cms+@using Grand.Web.AdminShared.Models.News@inject LocService Loc@inject IEnumTranslationService EnumTranslationService\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Controllers/NewsController.cs b/src/Web/Grand.Web.Store/Controllers/NewsController.csnew file mode 100644index 000000000..4f16e8a2c--- /dev/null+++ b/src/Web/Grand.Web.Store/Controllers/NewsController.cs@@ -0,0 +1,239 @@+using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Cms;+using Grand.Business.Core.Interfaces.Common.Configuration;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Domain.News;+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.News;+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.News)]+public class NewsController : BaseStoreController+{+ #region Constructors++ public NewsController(+ INewsViewModelService newsViewModelService,+ INewsService newsService,+ ILanguageService languageService,+ ITranslationService translationService,+ ISettingService settingService,+ IDateTimeService dateTimeService,+ IContextAccessor contextAccessor)+ {+ _newsViewModelService = newsViewModelService;+ _newsService = newsService;+ _languageService = languageService;+ _translationService = translationService;+ _settingService = settingService;+ _dateTimeService = dateTimeService;+ _contextAccessor = contextAccessor;+ }++ #endregion++ #region Fields++ private readonly INewsViewModelService _newsViewModelService;+ private readonly INewsService _newsService;+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;+ private readonly ISettingService _settingService;+ private readonly IDateTimeService _dateTimeService;+ private readonly IContextAccessor _contextAccessor;++ #endregion++ #region News items++ public IActionResult Index()+ {+ return RedirectToAction("List");+ }++ public IActionResult List()+ {+ var model = new NewsItemListModel();+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.List)]+ [HttpPost]+ public async Task<IActionResult> List(DataSourceRequest command, NewsItemListModel model)+ {+ var storeId = _contextAccessor.StoreContext.CurrentStore.Id;+ var newsSettings = await _settingService.LoadSetting<NewsSettings>(storeId);++ var news = await _newsService.GetAllNews(storeId, command.Page - 1, command.PageSize, newsTitle: model.SearchNewsTitle);++ var gridModel = new DataSourceResult {+ Data = news.Select(x =>+ {+ var m = x.ToModel(_dateTimeService);+ m.Full = "";+ m.CreatedOn = _dateTimeService.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc);+ m.Comments = x.CommentCount;+ return m;+ }).ToList(),+ Total = news.TotalCount+ };+ return Json(gridModel);+ }++ [PermissionAuthorizeAction(PermissionActionName.Create)]+ public async Task<IActionResult> Create()+ {+ ViewBag.AllLanguages = _languageService.GetAllLanguages(true);+ var model = new NewsItemModel {+ //default values+ Published = true,+ AllowComments = true+ };++ //locales+ await AddLocales(_languageService, model.Locales);+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ public async Task<IActionResult> Create(NewsItemModel model, bool continueEditing)+ {+ if (ModelState.IsValid)+ {+ model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];+ var newsItem = await _newsViewModelService.InsertNewsItemModel(model);+ await _newsService.UpdateNews(newsItem);++ Success(_translationService.GetResource("Admin.Content.News.NewsItems.Added"));+ return continueEditing ? RedirectToAction("Edit", new { id = newsItem.Id }) : RedirectToAction("List");+ }++ //If we got this far, something failed, redisplay form+ ViewBag.AllLanguages = _languageService.GetAllLanguages(true);+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> Edit(string id)+ {+ var newsItem = await _newsService.GetNewsById(id);+ if (newsItem == null)+ //No news item found with the specified id+ return RedirectToAction("List");++ if (!newsItem.LimitedToStores || (newsItem.LimitedToStores &&+ newsItem.Stores.Contains(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId) &&+ newsItem.Stores.Count > 1))+ {+ Warning(_translationService.GetResource("Admin.Content.News.Permissions"));+ }+ else+ {+ if (!newsItem.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("List");+ }++ ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);+ var model = newsItem.ToModel(_dateTimeService);+ //locales+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Title = newsItem.GetTranslation(x => x.Title, languageId, false);+ locale.Short = newsItem.GetTranslation(x => x.Short, languageId, false);+ locale.Full = newsItem.GetTranslation(x => x.Full, languageId, false);+ locale.MetaKeywords = newsItem.GetTranslation(x => x.MetaKeywords, languageId, false);+ locale.MetaDescription = newsItem.GetTranslation(x => x.MetaDescription, languageId, false);+ locale.MetaTitle = newsItem.GetTranslation(x => x.MetaTitle, languageId, false);+ locale.SeName = newsItem.GetSeName(languageId, false);+ });+ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ public async Task<IActionResult> Edit(NewsItemModel model, bool continueEditing)+ {+ var newsItem = await _newsService.GetNewsById(model.Id);+ if (newsItem == null)+ //No news item found with the specified id+ return RedirectToAction("List");++ if (!newsItem.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("Edit", new { id = newsItem.Id });++ if (ModelState.IsValid)+ {+ model.Stores = [_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId];+ newsItem = await _newsViewModelService.UpdateNewsItemModel(newsItem, model);+ Success(_translationService.GetResource("Admin.Content.News.NewsItems.Updated"));++ if (continueEditing)+ {+ //selected tab+ await SaveSelectedTabIndex();++ return RedirectToAction("Edit", new { id = newsItem.Id });+ }++ return RedirectToAction("List");+ }++ //If we got this far, something failed, redisplay form+ ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);++ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Delete)]+ [HttpPost]+ public async Task<IActionResult> Delete(string id)+ {+ var newsItem = await _newsService.GetNewsById(id);+ if (newsItem == null)+ //No news item found with the specified id+ return RedirectToAction("List");++ if (!newsItem.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ await _newsService.DeleteNews(newsItem);++ Success(_translationService.GetResource("Admin.Content.News.NewsItems.Deleted"));+ return RedirectToAction("List");+ }++ Error(ModelState);+ return RedirectToAction("Edit", new { id = newsItem.Id });+ }++ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> Preview(string id)+ {+ var newsItem = await _newsService.GetNewsById(id);+ if (newsItem == null)+ return RedirectToAction("List");++ if (!newsItem.AccessToEntityByStore(_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId))+ return RedirectToAction("List");++ var model = newsItem.ToModel(_dateTimeService);+ return View(model);+ }++ #endregion+}\ No newline at end of filediff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xmlindex 8b59be237..3b37fcbdf 100644Binary files a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml and b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml differ