Browse Source

Added some example widgets for doc

pull/13311/head
malik masis 4 years ago
committed by Enis Necipoglu
parent
commit
ebc1170b9e
  1. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs
  2. 11
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDate.cshtml
  3. 25
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs
  4. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml
  5. 23
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDateViewComponent.cs
  6. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js
  7. 1
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml

6
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<CmsKitContentWidgetOptions>(options =>
{
options.AddWidget("ExComment", "CommentDate", "DecisionCommentDate");
});
}
private void ConfigureCmsKit(ServiceConfigurationContext context)

11
modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDate.cshtml

@ -0,0 +1,11 @@
@model Volo.CmsKit.ViewComponents.CommentDateViewComponent
<p>Welcome Comment Date Component</p>
@if (Model.IsShow)
{
<p> @DateTime.Today.ToLongDateString()</p>
}
else
{
<p>Without date</p>
}

25
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<IViewComponentResult> InvokeAsync(string isShow)
{
return View("~/ViewComponents/CommentDate.cshtml", new CommentDateViewComponent() { IsShow = bool.Parse(isShow) });
}
}

6
modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml

@ -0,0 +1,6 @@
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="NewOption" />
<label class="form-check-label text-primary d-block" for="NewOption">
Show date in the component
</label>
</div>

23
modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDateViewComponent.cs

@ -0,0 +1,23 @@
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 = "DecisionCommentDate")]
public class DecisionCommentDateViewComponent : AbpViewComponent
{
public DecisionCommentDateViewComponent()
{
}
public virtual async Task<IViewComponentResult> InvokeAsync()
{
return View("~/ViewComponents/DecisionCommentDate.cshtml");
}
}

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js

@ -20,6 +20,12 @@ $(function () {
let html = " <input hidden class=\"properties form-control\" value=\"" + widgetKey + "\" id=\"Code\" type=\"text\" />"
$("#PropertySideId").append(html);
}
else {
var val = $('#NewOption').is(":checked");
let html = " <input hidden class=\"properties form-control\" value=\"" + val + "\" id=\"IsShow\" type=\"text\" />"
$("#PropertySideId").append(html);
}
var keys = [];
var values = [];

1
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml

@ -40,6 +40,7 @@
{
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject())
}
}
</abp-card-body>
</abp-card>

Loading…
Cancel
Save