Browse Source

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

Cms kit - Tags Cleaning
pull/6858/head
İlkay İlknur 6 years ago
committed by GitHub
parent
commit
9a296e0410
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1643
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.Designer.cs
  2. 24
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.cs
  3. 4
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml
  5. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/GetRelatedTagsInput.cs
  6. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/TagDto.cs
  7. 28
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs
  8. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Tags/Default.cshtml
  9. 6
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs
  10. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Tags/default.css
  11. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Volo.CmsKit.Common.Web.csproj
  12. 2
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Tags/TagConsts.cs
  13. 3
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagManager.cs
  14. 9
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs
  15. 7
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs
  16. 1
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

1643
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.Designer.cs

File diff suppressed because it is too large

24
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.cs

@ -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);
}
}
}

4
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs

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

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

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

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

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

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

@ -8,7 +8,5 @@ namespace Volo.CmsKit.Tags
public string EntityType { get; set; } public string EntityType { get; set; }
public string Name { get; protected set; } public string Name { get; protected set; }
public string HexColor { get; protected 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( public TagAppService(
ITagManager tagManager, ITagManager tagManager,
ITagRepository tagRepository, IEntityTagRepository entityTagRepository) ITagRepository tagRepository,
IEntityTagRepository entityTagRepository)
{ {
TagManager = tagManager; TagManager = tagManager;
TagRepository = tagRepository; TagRepository = tagRepository;
@ -27,31 +28,6 @@ namespace Volo.CmsKit.Tags
input.EntityId, input.EntityId,
CurrentTenant.Id); 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); return ObjectMapper.Map<List<Tag>, List<TagDto>>(entities);
} }
} }

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

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

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( public virtual async Task<IViewComponentResult> InvokeAsync(
string entityType, string entityType,
string entityId, string entityId)
IEnumerable<string> tags = null)
{ {
var tagDtos = await TagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput var tagDtos = await TagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput
{ {
EntityId = entityId, EntityId = entityId,
EntityType = entityType, EntityType = entityType
Tags = tags?.ToList()
}); });
var viewModel = new TagViewModel var viewModel = new TagViewModel

4
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Tags/default.css

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

4
modules/cms-kit/src/Volo.CmsKit.Common.Web/Volo.CmsKit.Common.Web.csproj

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

2
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Tags/TagConsts.cs

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

3
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagManager.cs

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

9
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs

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

7
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs

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

1
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

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

Loading…
Cancel
Save