Browse Source

Remove static tags logic

pull/6850/head
enisn 6 years ago
parent
commit
49f3b6a8f4
  1. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml
  2. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/GetRelatedTagsInput.cs
  3. 28
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs
  4. 6
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs

6
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml

@ -22,8 +22,7 @@
@await Component.InvokeAsync(typeof(TagViewComponent), new
{
entityType = "quote",
entityId = "1",
tags = new List<string> { "a", "b" }
entityId = "1"
})
</abp-blockquote>
@ -89,8 +88,7 @@
@await Component.InvokeAsync(typeof(TagViewComponent), new
{
entityType = "IndexPage",
entityId = Guid.Empty.ToString(),
tags = new List<string> { "a", "b" }
entityId = Guid.Empty.ToString()
})
</abp-column>
</abp-row>

2
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/GetRelatedTagsInput.cs

@ -10,7 +10,5 @@ namespace Volo.CmsKit.Tags
[Required]
public string EntityId { get; set; }
public List<string> Tags { get; set; }
}
}

28
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs

@ -13,7 +13,8 @@ namespace Volo.CmsKit.Tags
public TagAppService(
ITagManager tagManager,
ITagRepository tagRepository, IEntityTagRepository entityTagRepository)
ITagRepository tagRepository,
IEntityTagRepository entityTagRepository)
{
TagManager = tagManager;
TagRepository = tagRepository;
@ -27,31 +28,6 @@ namespace Volo.CmsKit.Tags
input.EntityId,
CurrentTenant.Id);
if (input.Tags?.Count > 0)
{
var nonExisting = input.Tags
.Where(x =>
!entities.Any(a =>
a.Name.Equals(x.Trim(),
StringComparison.InvariantCultureIgnoreCase)));
foreach (var tag in nonExisting)
{
var insertedTag = await TagManager.GetOrAddAsync(
input.EntityType,
tag,
tenantId: CurrentTenant?.Id);
await EntityTagRepository.InsertAsync(
new EntityTag(
insertedTag.Id,
input.EntityId,
CurrentTenant?.Id));
entities.Add(insertedTag);
}
}
return ObjectMapper.Map<List<Tag>, List<TagDto>>(entities);
}
}

6
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs

@ -21,14 +21,12 @@ namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Tags
public virtual async Task<IViewComponentResult> InvokeAsync(
string entityType,
string entityId,
IEnumerable<string> tags = null)
string entityId)
{
var tagDtos = await TagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput
{
EntityId = entityId,
EntityType = entityType,
Tags = tags?.ToList()
EntityType = entityType
});
var viewModel = new TagViewModel

Loading…
Cancel
Save