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 9a6be48e5f..5e953e82d6 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -46,6 +46,7 @@ using Volo.CmsKit.Comments; using Volo.CmsKit.MediaDescriptors; using Volo.CmsKit.Reactions; using Volo.CmsKit.Ratings; +using Volo.CmsKit.Contents; namespace Volo.CmsKit; @@ -152,6 +153,11 @@ public class CmsKitWebUnifiedModule : AbpModule { options.IsEnabled = MultiTenancyConsts.IsEnabled; }); + + Configure(options => + { + options.AddWidget("ExComment", "CommentDate", "DecisionCommentDate"); + }); } private void ConfigureCmsKit(ServiceConfigurationContext context) 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 new file mode 100644 index 0000000000..7921c0ecbd --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDate.cshtml @@ -0,0 +1,11 @@ +@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/CommentDateViewComponent.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs new file mode 100644 index 0000000000..4122bb1481 --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs @@ -0,0 +1,25 @@ +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 = "CommentDate")] +public class CommentDateViewComponent : AbpViewComponent +{ + public bool IsShow { get; set; } + + public CommentDateViewComponent() + { + } + + public virtual async Task InvokeAsync(string isShow) + { + return View("~/ViewComponents/CommentDate.cshtml", new CommentDateViewComponent() { IsShow = bool.Parse(isShow) }); + } +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml new file mode 100644 index 0000000000..0622000bb7 --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml @@ -0,0 +1,6 @@ +@using Volo.CmsKit.ViewComponents +@model DecisionCommentDateViewModel + +
+ +
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 new file mode 100644 index 0000000000..c4f52d508a --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDateViewComponent.cs @@ -0,0 +1,32 @@ +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/Pages/_ViewImports.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/_ViewImports.cshtml similarity index 100% rename from modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/_ViewImports.cshtml rename to modules/cms-kit/host/Volo.CmsKit.Web.Unified/_ViewImports.cshtml 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 3219538d46..87831e4e1d 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 @@ -1,5 +1,6 @@ @page @using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal @using Volo.CmsKit.Admin.Web.Pages @using Volo.CmsKit.Localization @using Volo.CmsKit.Admin.Web.Pages.CmsKit.Contents; @@ -20,15 +21,17 @@
@if (Model.Widgets.Count() > 1) { + foreach (var item in Model.ViewModel.Details) { - + } -
-
- } else { @@ -36,4 +39,7 @@ }
+ + + diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js index 2c307c8faf..2f625fe2fa 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js @@ -3,6 +3,8 @@ $(function () { abp.modals.addWidgetModal = function () { var initModal = function () { + var activeEditor; + var activeForm; let widgetName, widgetType; $("#ViewModel_Widget").change(function () { @@ -11,41 +13,28 @@ $(function () { $('.widget-detail').attr('hidden', 'true'); - $('#editor-' + widgetName).removeAttr('hidden'); - }); + activeEditor = $('#editor-' + widgetName); + activeEditor.removeAttr('hidden'); - $("#save-changes").click(function () { - var widgetKey = $("#WidgetCode").val(); - if (widgetKey != undefined) { - let html = " " - $("#PropertySideId").append(html); - } + activeForm = $('#editor-' + widgetName + ' form'); + }); - var keys = []; - var values = []; - $(".properties").each(function () { - if (($.trim($(this).val()).length > 0)) { - keys.push(this.id); - values.push($(this).val()); - } - }); + $(".save-changes").click(function () { - let updatedText = ''; - if (widgetType != undefined) { + let properties = activeForm.serializeFormToObject(); - updatedText = "[Widget Type=\"" + widgetType + "\" "; + let widgetText = "[Widget Type=\"" + widgetType + "\" "; - for (var i = 0; i < keys.length; i++) { - updatedText += keys[i] + "=\"" + values[i]; - updatedText += i == (keys.length - 1) ? "\"" : "\" "; + for (var propertyName in properties) { + if (!propertyName.includes(']') && !propertyName.includes('[')) { + widgetText += propertyName + "=\"" + properties[propertyName] + "\" "; } - - updatedText += "]"; } - $('#GeneratedWidgetText').val(updatedText); - $("#GeneratedWidgetText").trigger("change"); + widgetText = widgetText.trim() + "]"; + $('#GeneratedWidgetText').val(widgetText); + $("#GeneratedWidgetText").trigger("change"); $('#addWidgetModal').modal('hide'); }); }; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml index 5a92ae2b04..2aa3c0ce8b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml @@ -40,6 +40,7 @@ { @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) } + }