diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs index e3094a7da8..801cc2dd41 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -153,7 +153,7 @@ public class CmsKitWebUnifiedModule : AbpModule Configure(options => { - options.AddWidget("ExComment", "CommentDate", "DecisionCommentDate"); + options.AddWidget("Today", "CmsToday", "Format"); }); } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDate.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDate.cshtml deleted file mode 100644 index 7921c0ecbd..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDate.cshtml +++ /dev/null @@ -1,11 +0,0 @@ -@model Volo.CmsKit.ViewComponents.CommentDateViewComponent - -

Welcome Comment Date Component

-@if (Model.IsShow) -{ -

@DateTime.Today.ToLongDateString()

-} -else -{ -

Without date

-} \ No newline at end of file diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDateViewComponent.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDateViewComponent.cs deleted file mode 100644 index c4f52d508a..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDateViewComponent.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -using Volo.Abp.Localization; - -namespace Volo.CmsKit.ViewComponents; - -[Widget( - AutoInitialize = true -)] - -[ViewComponent(Name = "DecisionCommentDate")] -public class DecisionCommentDateViewComponent : AbpViewComponent -{ - public DecisionCommentDateViewComponent() - { - } - - public virtual async Task InvokeAsync() - { - return View("~/ViewComponents/DecisionCommentDate.cshtml", new DecisionCommentDateViewModel()); - } -} - -public class DecisionCommentDateViewModel -{ - [DisplayName("Show date in the component")] - public bool IsShow { get; set; } = true; -} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/Format.cshtml similarity index 76% rename from modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml rename to modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/Format.cshtml index 0622000bb7..89d24ec933 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/Format.cshtml @@ -2,5 +2,5 @@ @model DecisionCommentDateViewModel
- +
diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/FormatViewComponent.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/FormatViewComponent.cs new file mode 100644 index 0000000000..cd99aabb6d --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/FormatViewComponent.cs @@ -0,0 +1,30 @@ +using System.ComponentModel; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.UI.Widgets; + +namespace Volo.CmsKit.ViewComponents; + +[Widget( + AutoInitialize = true +)] + +[ViewComponent(Name = "Format")] +public class FormatViewComponent : AbpViewComponent +{ + public FormatViewComponent() + { + } + + public virtual async Task InvokeAsync() + { + return View("~/ViewComponents/Format.cshtml", new DecisionCommentDateViewModel()); + } +} + +public class DecisionCommentDateViewModel +{ + [DisplayName("Format your date in the component")] + public string Format { get; set; } +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/Today.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/Today.cshtml new file mode 100644 index 0000000000..9cc7d5717a --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/Today.cshtml @@ -0,0 +1,5 @@ +@model Volo.CmsKit.ViewComponents.TodayViewComponent + +

Welcome Today Component

+ +

@DateTime.Now.ToString(Model.Format)

diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/TodayViewComponent.cs similarity index 50% rename from modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs rename to modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/TodayViewComponent.cs index 4122bb1481..f0be3ad33c 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/TodayViewComponent.cs @@ -9,17 +9,17 @@ namespace Volo.CmsKit.ViewComponents; AutoInitialize = true )] -[ViewComponent(Name = "CommentDate")] -public class CommentDateViewComponent : AbpViewComponent +[ViewComponent(Name = "CmsToday")] +public class TodayViewComponent : AbpViewComponent { - public bool IsShow { get; set; } + public string Format { get; set; } - public CommentDateViewComponent() + public TodayViewComponent() { } - public virtual async Task InvokeAsync(string isShow) + public virtual async Task InvokeAsync(string format) { - return View("~/ViewComponents/CommentDate.cshtml", new CommentDateViewComponent() { IsShow = bool.Parse(isShow) }); + return View("~/ViewComponents/Today.cshtml", new TodayViewComponent() { Format = format }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/AddWidgetModal.cshtml b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/AddWidgetModal.cshtml index 87831e4e1d..be33dc698e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/AddWidgetModal.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/AddWidgetModal.cshtml @@ -20,23 +20,25 @@
@if (Model.Widgets.Count() > 1) - { - - + { + - foreach (var item in Model.ViewModel.Details) + foreach (var item in Model.ViewModel.Details) + { + if (item.EditorComponentName is not null) + { + + } + } + } + else { - +

@L["PleaseConfigureWidgets"].Value

} - } - else - { -

@L["PleaseConfigureWidgets"].Value

- }
diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs index b87f286b5c..1ff76acf79 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs @@ -11,7 +11,7 @@ public class CmsKitContentWidgetOptions WidgetConfigs = new(); } - public void AddWidget(string widgetKey, string widgetName, string editorWidgetName) + public void AddWidget(string widgetKey, string widgetName, string editorWidgetName = null) { var config = new ContentWidgetConfig(widgetName, editorWidgetName); WidgetConfigs.Add(widgetKey, config);