Merge pull request #6850 from abpframework/cms-kit/content-management-cleaning

Cms kit - Tags Cleaning
pull/6858/head
İlkay İlknur 5 years ago committed by GitHub
commit 9a296e0410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Updated_Tag_Removed_HexColor : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "HexColor",
table: "CmsTags");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "HexColor",
table: "CmsTags",
type: "nvarchar(6)",
maxLength: 6,
nullable: true);
}
}
}

@ -1374,10 +1374,6 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("HexColor")
.HasMaxLength(6)
.HasColumnType("nvarchar(6)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")

@ -26,8 +26,7 @@
@await Component.InvokeAsync(typeof(TagViewComponent), new
{
entityType = "quote",
entityId = "1",
tags = new List<string> {"a", "b"}
entityId = "1"
})
}
</abp-blockquote>
@ -92,8 +91,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>

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

@ -8,7 +8,5 @@ namespace Volo.CmsKit.Tags
public string EntityType { get; set; }
public string Name { get; protected set; }
public string HexColor { get; protected set; }
}
}

@ -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,7 +6,7 @@
{
foreach (var tag in Model.Tags)
{
<span class="cmskit-tag" data-color="#@tag.HexColor">
<span class="cmskit-tag">
@tag.Name
</span>
}

@ -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

@ -1,4 +0,0 @@
.cmskit-tag {
border-radius: 2px;
border: 1px solid;
}

@ -35,8 +35,4 @@
<Content Remove="Components\**\*.css" />
</ItemGroup>
<ItemGroup>
<None Remove="Pages\CmsKit\Shared\Components\Tags\default.css" />
</ItemGroup>
</Project>

@ -7,7 +7,5 @@ namespace Volo.CmsKit.Tags
public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength;
public static int MaxNameLength { get; set; } = 32;
public static int MaxColorHexLength { get; set; } = 6;
}
}

@ -12,20 +12,17 @@ namespace Volo.CmsKit.Tags
Task<Tag> InsertAsync(
[NotNull] string entityType,
[NotNull] string name,
[CanBeNull] string hexColor,
Guid? tenantId = null,
CancellationToken cancellationToken = default);
Task<Tag> UpdateAsync(
Guid id,
[NotNull] string name,
[CanBeNull] string hexColor,
CancellationToken cancellationToken = default);
Task<Tag> GetOrAddAsync(
[NotNull] string entityType,
[NotNull] string name,
[CanBeNull] string hexColor = null,
Guid? tenantId = null,
CancellationToken cancellationToken = default);
}

@ -12,8 +12,6 @@ namespace Volo.CmsKit.Tags
public string Name { get; protected set; }
public string HexColor { get; protected set; }
public Guid? TenantId { get; }
protected Tag()
@ -23,12 +21,10 @@ namespace Volo.CmsKit.Tags
public Tag(
[NotNull] string entityType,
[NotNull] string name,
[CanBeNull] string hexColor,
Guid? tenantId = null)
{
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength);
SetName(name);
SetHexColor(hexColor);
TenantId = tenantId;
}
@ -36,10 +32,5 @@ namespace Volo.CmsKit.Tags
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TagConsts.MaxNameLength);
}
public void SetHexColor(string hexColor)
{
HexColor = Check.Length(hexColor, nameof(hexColor), TagConsts.MaxColorHexLength);
}
}
}

@ -19,7 +19,6 @@ namespace Volo.CmsKit.Tags
public async Task<Tag> GetOrAddAsync(
[NotNull] string entityType,
[NotNull] string name,
[CanBeNull] string hexColor = null,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
@ -27,7 +26,7 @@ namespace Volo.CmsKit.Tags
if (entity == null)
{
entity = await InsertAsync(entityType, name, hexColor, tenantId, cancellationToken);
entity = await InsertAsync(entityType, name, tenantId, cancellationToken);
}
return entity;
@ -36,7 +35,6 @@ namespace Volo.CmsKit.Tags
public async Task<Tag> InsertAsync(
[NotNull] string entityType,
[NotNull] string name,
[CanBeNull] string hexColor,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
@ -49,7 +47,6 @@ namespace Volo.CmsKit.Tags
new Tag(
entityType,
name,
hexColor,
tenantId),
cancellationToken: cancellationToken);
}
@ -57,13 +54,11 @@ namespace Volo.CmsKit.Tags
public async Task<Tag> UpdateAsync(
Guid id,
[NotNull] string name,
[CanBeNull] string hexColor,
CancellationToken cancellationToken = default)
{
var entity = await _tagRepository.GetAsync(id, cancellationToken: cancellationToken);
entity.SetName(name);
entity.SetHexColor(hexColor);
if (await _tagRepository.AnyAsync(entity.EntityType, name, entity.TenantId, cancellationToken))
{

@ -118,7 +118,6 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength);
b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength);
b.Property(x => x.HexColor).HasMaxLength(TagConsts.MaxColorHexLength);
b.HasIndex(x => new { x.TenantId, x.Name });
});

Loading…
Cancel
Save