Browse Source

Refactor

pull/17110/head
Salih 3 years ago
parent
commit
9f420db9a2
  1. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/PopularTags/Default.cshtml
  2. 7
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/PopularTags/PopularTagsViewComponent.cs
  3. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/Default.cshtml

4
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/PopularTags/Default.cshtml

@ -10,7 +10,7 @@
<div class="cms-tags-area my-3"> <div class="cms-tags-area my-3">
@foreach (var tag in Model.Tags) @foreach (var tag in Model.Tags)
{ {
if (Model.UrlFactory == null) if (Model.UrlFormat.IsNullOrWhiteSpace())
{ {
<span class="br-8 me-2 mb-2 p-2 d-inline-block cmskit-tag fw--5" style="background: #eeedf7; color: #766bc8"> <span class="br-8 me-2 mb-2 p-2 d-inline-block cmskit-tag fw--5" style="background: #eeedf7; color: #766bc8">
@tag.Name @tag.Name
@ -18,7 +18,7 @@
} }
else else
{ {
<a href="@Model.UrlFactory(tag)"> <a href="@Model.UrlFormat.Replace("{TagId}", tag.Id.ToString()).Replace("{TagName}",tag.Name)">
<span class="br-8 me-2 mb-2 p-2 d-inline-block cmskit-tag fw--5" style="background: #eeedf7; color: #766bc8"> <span class="br-8 me-2 mb-2 p-2 d-inline-block cmskit-tag fw--5" style="background: #eeedf7; color: #766bc8">
@tag.Name @tag.Name
</span> </span>

7
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/PopularTags/PopularTagsViewComponent.cs

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Uow;
using Volo.CmsKit.Tags; using Volo.CmsKit.Tags;
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.PopularTags; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.PopularTags;
@ -17,12 +16,12 @@ public class PopularTagsViewComponent : AbpViewComponent
_tagAppService = tagAppService; _tagAppService = tagAppService;
} }
public async Task<IViewComponentResult> InvokeAsync(string entityType, int maxCount, Func<PopularTagDto, string> urlFactory = null) public async Task<IViewComponentResult> InvokeAsync(string entityType, int maxCount, string urlFormat)
{ {
var model = new PopularTagsViewModel var model = new PopularTagsViewModel
{ {
Tags = await _tagAppService.GetPopularTagsAsync(entityType, maxCount), Tags = await _tagAppService.GetPopularTagsAsync(entityType, maxCount),
UrlFactory = urlFactory UrlFormat = urlFormat
}; };
return View("~/Pages/CmsKit/Shared/Components/PopularTags/Default.cshtml", model); return View("~/Pages/CmsKit/Shared/Components/PopularTags/Default.cshtml", model);
} }
@ -30,6 +29,6 @@ public class PopularTagsViewComponent : AbpViewComponent
public class PopularTagsViewModel public class PopularTagsViewModel
{ {
public List<PopularTagDto> Tags { get; set; } public List<PopularTagDto> Tags { get; set; }
public Func<PopularTagDto, string> UrlFactory { get; set; } public string UrlFormat { get; set; }
} }
} }

2
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/Default.cshtml

@ -16,7 +16,7 @@
} }
else else
{ {
var formattedUrl = Model.UrlFormat.Replace("{TagId}", tag.Id.ToString()); var formattedUrl = Model.UrlFormat.Replace("{TagId}", tag.Id.ToString()).Replace("{TagName}", tag.Name);
<a href="@formattedUrl"><span class="badge rounded-pill bg-light text-dark px-3 py-2 cmskit-tag font-weight-normal">@tag.Name</span></a> <a href="@formattedUrl"><span class="badge rounded-pill bg-light text-dark px-3 py-2 cmskit-tag font-weight-normal">@tag.Name</span></a>
} }
} }

Loading…
Cancel
Save