Merge pull request #16476 from abpframework/Onur/cmskit-comment

Cms-Kit - comment enhancement on admin side
pull/16520/head^2
Gizem Mutu Kurt 3 years ago committed by GitHub
commit c1e141a44b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,62 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Volo.CmsKit.Migrations
{
/// <inheritdoc />
public partial class AddedEntityVersion : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "EntityVersion",
table: "AbpUsers",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "EntityVersion",
table: "AbpTenants",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "EntityVersion",
table: "AbpRoles",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "EntityVersion",
table: "AbpOrganizationUnits",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EntityVersion",
table: "AbpUsers");
migrationBuilder.DropColumn(
name: "EntityVersion",
table: "AbpTenants");
migrationBuilder.DropColumn(
name: "EntityVersion",
table: "AbpRoles");
migrationBuilder.DropColumn(
name: "EntityVersion",
table: "AbpOrganizationUnits");
}
}
}

@ -13,8 +13,8 @@ using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Migrations
{
[DbContext(typeof(UnifiedDbContext))]
[Migration("20221223083811_Added_EntityVersion")]
partial class AddedEntityVersion
[Migration("20230504122708_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -790,6 +790,9 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<DateTimeOffset?>("LastPasswordChangeTime")
.HasColumnType("datetimeoffset");
b.Property<bool>("LockoutEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
@ -838,6 +841,9 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("nvarchar(256)")
.HasColumnName("SecurityStamp");
b.Property<bool>("ShouldChangePasswordOnNextLogin")
.HasColumnType("bit");
b.Property<string>("Surname")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)")
@ -900,6 +906,33 @@ namespace Volo.CmsKit.Migrations
b.ToTable("AbpUserClaims", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserDelegation", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("EndTime")
.HasColumnType("datetime2");
b.Property<Guid>("SourceUserId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("StartTime")
.HasColumnType("datetime2");
b.Property<Guid>("TargetUserId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.HasKey("Id");
b.ToTable("AbpUserDelegations", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.Property<Guid>("UserId")
@ -1597,6 +1630,10 @@ namespace Volo.CmsKit.Migrations
.HasMaxLength(512)
.HasColumnType("nvarchar(512)");
b.Property<string>("Url")
.HasMaxLength(512)
.HasColumnType("nvarchar(512)");
b.HasKey("Id");
b.HasIndex("TenantId", "RepliedCommentId");

@ -155,6 +155,7 @@ namespace Volo.CmsKit.Migrations
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Code = table.Column<string>(type: "nvarchar(95)", maxLength: 95, nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
@ -235,6 +236,7 @@ namespace Volo.CmsKit.Migrations
IsDefault = table.Column<bool>(type: "bit", nullable: false),
IsStatic = table.Column<bool>(type: "bit", nullable: false),
IsPublic = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
@ -289,6 +291,7 @@ namespace Volo.CmsKit.Migrations
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
@ -304,6 +307,22 @@ namespace Volo.CmsKit.Migrations
table.PrimaryKey("PK_AbpTenants", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpUserDelegations",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
SourceUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TargetUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
StartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
EndTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserDelegations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpUsers",
columns: table => new
@ -327,6 +346,9 @@ namespace Volo.CmsKit.Migrations
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
@ -400,6 +422,7 @@ namespace Volo.CmsKit.Migrations
RepliedCommentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
Url = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
@ -1232,6 +1255,9 @@ namespace Volo.CmsKit.Migrations
migrationBuilder.DropTable(
name: "AbpUserClaims");
migrationBuilder.DropTable(
name: "AbpUserDelegations");
migrationBuilder.DropTable(
name: "AbpUserLogins");

@ -787,6 +787,9 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<DateTimeOffset?>("LastPasswordChangeTime")
.HasColumnType("datetimeoffset");
b.Property<bool>("LockoutEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
@ -835,6 +838,9 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("nvarchar(256)")
.HasColumnName("SecurityStamp");
b.Property<bool>("ShouldChangePasswordOnNextLogin")
.HasColumnType("bit");
b.Property<string>("Surname")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)")
@ -897,6 +903,33 @@ namespace Volo.CmsKit.Migrations
b.ToTable("AbpUserClaims", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserDelegation", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("EndTime")
.HasColumnType("datetime2");
b.Property<Guid>("SourceUserId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("StartTime")
.HasColumnType("datetime2");
b.Property<Guid>("TargetUserId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.HasKey("Id");
b.ToTable("AbpUserDelegations", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.Property<Guid>("UserId")
@ -1594,6 +1627,10 @@ namespace Volo.CmsKit.Migrations
.HasMaxLength(512)
.HasColumnType("nvarchar(512)");
b.Property<string>("Url")
.HasMaxLength(512)
.HasColumnType("nvarchar(512)");
b.HasKey("Id");
b.HasIndex("TenantId", "RepliedCommentId");

@ -20,4 +20,6 @@ public class CommentWithAuthorDto
public DateTime CreationTime { get; set; }
public CmsUserDto Author { get; set; }
public string Url { get; set; }
}

@ -114,6 +114,16 @@ $(function (){
return "";
}
},
{
title: l("URL"),
data: "url",
render: function (data, type, row) {
if (data !== null) {
return '<a href="' + data + '#comment-'+ row.id + '" target="_blank"><i class="fa fa-location-arrow"></i></a>';
}
return "";
}
},
{
title: l("Text"),
data: "text",

@ -10,4 +10,6 @@ public static class CommentConsts
public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength;
public static int MaxTextLength { get; set; } = 512;
public static int MaxUrlLength { get; set; } = 512;
}

@ -217,6 +217,7 @@
"CommentTextRequired": "Comment is required",
"CaptchaCodeErrorMessage" : "The answer you entered for the CAPTCHA was not correct. Please try again",
"CaptchaCodeMissingMessage": "The captcha code is missing!",
"UnAllowedExternalUrlMessage": "You included an unallowed external URL. Please try again without the external URL."
"UnAllowedExternalUrlMessage": "You included an unallowed external URL. Please try again without the external URL.",
"URL": "URL"
}
}

@ -23,6 +23,8 @@ public class Comment : AggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator,
public virtual DateTime CreationTime { get; set; }
public virtual string Url { get; set; }
protected Comment()
{
@ -35,6 +37,7 @@ public class Comment : AggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator,
[NotNull] string text,
Guid? repliedCommentId,
Guid creatorId,
[CanBeNull] string url = null,
Guid? tenantId = null)
: base(id)
{
@ -42,6 +45,7 @@ public class Comment : AggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator,
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength);
RepliedCommentId = repliedCommentId;
CreatorId = creatorId;
Url = url;
TenantId = tenantId;
SetTextInternal(text);

@ -21,6 +21,7 @@ public class CommentManager : DomainService
[NotNull] string entityType,
[NotNull] string entityId,
[NotNull] string text,
[CanBeNull] string url = null,
[CanBeNull] Guid? repliedCommentId = null)
{
Check.NotNull(creator, nameof(creator));
@ -40,6 +41,7 @@ public class CommentManager : DomainService
text,
repliedCommentId,
creator.Id,
url,
CurrentTenant.Id);
}
}

@ -79,6 +79,7 @@ public static class CmsKitDbContextModelCreatingExtensions
b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength);
b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength);
b.Property(x => x.RepliedCommentId);
b.Property(x => x.Url).HasMaxLength(CommentConsts.MaxUrlLength);
b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId });
b.HasIndex(x => new { x.TenantId, x.RepliedCommentId });

@ -23,4 +23,6 @@ public class CommentDto : IHasConcurrencyStamp
public CmsUserDto Author { get; set; } //TODO: Should only have AuthorId for the basic dto. see https://docs.abp.io/en/abp/latest/Best-Practices/Application-Services
public string ConcurrencyStamp { get; set; }
public string Url { get; set; }
}

@ -17,4 +17,6 @@ public class CreateCommentInput
public Guid? CaptchaToken { get; set; }
public int CaptchaAnswer { get; set; }
public string Url { get; set; }
}

@ -23,4 +23,6 @@ public class CreateCommentWithParametersInput
public Guid? CaptchaToken { get; set; }
public int CaptchaAnswer { get; set; }
public string Url { get; set; }
}

@ -77,6 +77,7 @@ public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPubli
entityType,
entityId,
input.Text,
input.Url,
input.RepliedCommentId
)
);

@ -20,8 +20,8 @@
@<span>
<i class="far fa-comment-alt me-2"></i>
@((string.IsNullOrWhiteSpace(author.Name)
? author.UserName
: author.Name + " " + author.Surname).Trim())
? author.UserName
: author.Name + " " + author.Surname).Trim())
<small class="text-muted float-end" style="opacity: .5; font-size: 14px">@creationTime.ToString()</small>
</span>;
}
@ -157,7 +157,7 @@
}
@foreach (var comment in Model.Input.Comments)
{
<div class="comment">
<div class="comment" id="comment-@comment.Id.ToString()">
<div class="card p-3 mx-0 my-3">
<h5>
@GetCommentTitle(comment.Author, comment.CreationTime).Invoke(null)

@ -150,6 +150,7 @@
entityType: $commentArea.attr('data-entity-type'),
repliedCommentId: formAsObject.repliedCommentId,
text: formAsObject.commentText,
url: window.location.href,
captchaToken: formAsObject.captchaId,
captchaAnswer: formAsObject.input?.captcha
}),
@ -178,7 +179,7 @@
$(location.hash).find('textarea').focus();
}
}
function init() {
registerReplyLinks($widget);
registerEditLinks($widget);

Loading…
Cancel
Save