mirror of https://github.com/abpframework/abp.git
12 changed files with 153 additions and 4 deletions
@ -1,11 +1,11 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Tags; |
|||
|
|||
public interface ITagAppService : IApplicationService |
|||
{ |
|||
Task<List<TagDto>> GetAllRelatedTagsAsync(string entityType, string entityId); |
|||
} |
|||
Task<List<PopularTagDto>> GetPopularTagsAsync(string entityType, int maxCount); |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Volo.CmsKit.Tags; |
|||
|
|||
public class PopularTagDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
public string Name { get; set; } |
|||
public int Count { get; set; } |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
|
|||
namespace Volo.CmsKit.Tags; |
|||
|
|||
public class PopularTag |
|||
{ |
|||
public Guid Id { get; set; } |
|||
public string Name { get; set; } |
|||
public int Count { get; set; } |
|||
|
|||
public PopularTag(Guid id, string name, int count) |
|||
{ |
|||
Id = id; |
|||
Name = name; |
|||
Count = count; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
@inject IHtmlLocalizer<CmsKitResource> L |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.CmsKit.Localization |
|||
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.PopularTags.PopularTagsViewComponent.PopularTagsViewModel |
|||
|
|||
@if (Model.Tags != null && Model.Tags.Any()) |
|||
{ |
|||
<h4 class="mb-3 fw--6">@L["PopularTags"]</h4> |
|||
|
|||
<div class="cms-tags-area my-3"> |
|||
@foreach (var tag in Model.Tags) |
|||
{ |
|||
if (Model.UrlFactory == null) |
|||
{ |
|||
<span class="br-8 me-2 mb-2 p-2 d-inline-block cmskit-tag fw--5" style="background: #eeedf7; color: #766bc8"> |
|||
@tag.Name |
|||
</span> |
|||
} |
|||
else |
|||
{ |
|||
<a href="@Model.UrlFactory(tag)"> |
|||
<span class="br-8 me-2 mb-2 p-2 d-inline-block cmskit-tag fw--5" style="background: #eeedf7; color: #766bc8"> |
|||
@tag.Name |
|||
</span> |
|||
</a> |
|||
} |
|||
} |
|||
</div> |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Uow; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.PopularTags; |
|||
|
|||
public class PopularTagsViewComponent : AbpViewComponent |
|||
{ |
|||
private readonly ITagAppService _tagAppService; |
|||
|
|||
public PopularTagsViewComponent(ITagAppService tagAppService) |
|||
{ |
|||
_tagAppService = tagAppService; |
|||
} |
|||
|
|||
public async Task<IViewComponentResult> InvokeAsync(string entityType, int maxCount, Func<PopularTagDto, string> urlFactory = null) |
|||
{ |
|||
var model = new PopularTagsViewModel |
|||
{ |
|||
Tags = await _tagAppService.GetPopularTagsAsync(entityType, maxCount), |
|||
UrlFactory = urlFactory |
|||
}; |
|||
return View("~/Pages/CmsKit/Shared/Components/PopularTags/Default.cshtml", model); |
|||
} |
|||
|
|||
public class PopularTagsViewModel |
|||
{ |
|||
public List<PopularTagDto> Tags { get; set; } |
|||
public Func<PopularTagDto, string> UrlFactory { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue