Browse Source

approve page was made

pull/19919/head
EmreKendirli 2 years ago
parent
commit
9b0d16fefb
  1. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs
  2. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Components/CommentsSetting/Index.cshtml
  3. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/Index.cshtml
  4. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/Index.cshtml.cs
  5. 52
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/index.js
  6. 12
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml
  7. 1
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml.cs
  8. 17
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml
  9. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml.cs
  10. 24
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/details.js
  11. 32
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js
  12. 9
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Settings/CommentSettingPageContributor.cs
  13. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Volo.CmsKit.Admin.Web.csproj
  14. 22
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json
  15. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs
  16. 21
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs
  17. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

4
modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs

@ -110,7 +110,7 @@ public class CmsKitAdminWebModule : AbpModule
options.Conventions.AddPageRoute("/CmsKit/Comments/Details", "/Cms/Comments/{Id}");
options.Conventions.AddPageRoute("/CmsKit/Menus/MenuItems/Index", "/Cms/Menus/Items");
options.Conventions.AddPageRoute("/CmsKit/GlobalResources/Index", "/Cms/GlobalResources");
options.Conventions.AddPageRoute("/CmsKit/Comments/Waiting/Index", "/Cms/Comments/Waiting");
options.Conventions.AddPageRoute("/CmsKit/Comments/Approve/Index", "/Cms/Comments/Approve");
});
@ -189,7 +189,7 @@ public class CmsKitAdminWebModule : AbpModule
Configure<SettingManagementPageOptions>(options =>
{
options.Contributors.Add(new BookStoreSettingPageContributor());
options.Contributors.Add(new CommentSettingPageContributor());
});
}

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Components/CommentsSetting/Index.cshtml

@ -17,14 +17,14 @@
@inject IHtmlLocalizer<CmsKitResource> L
<abp-form #form="ngForm">
<h4>@L["CommentSettings:Title"].Value</h4>
<h4>@L["CmsKitCommentOptions:Title"].Value</h4>
<hr />
<div class="form-group">
<div class="form-check">
<input type="checkbox" id="checkbox" class="form-check-input" name="checkbox" ngModel />
<label for="checkbox" class="form-check-label">@L["CommentSettings:RequireApprovement"].Value</label>
<label for="checkbox" class="form-check-label">@L["CmsKitCommentOptions:RequireApprovement"].Value</label>
</div>
<small id="checkboxHelp" class="form-text text-muted">@L["CommentSettings:RequireApprovementDescription"].Value</small>
<small id="checkboxHelp" class="form-text text-muted">@L["CmsKitCommentOptions:RequireApprovementDescription"].Value</small>
</div>
<div style="float:right" class="text-right mt-3">

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/Index.cshtml → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/Index.cshtml

@ -27,7 +27,7 @@
<abp-script-bundle>
<abp-script src="/client-proxies/cms-kit-common-proxy.js" />
<abp-script src="/client-proxies/cms-kit-admin-proxy.js" />
<abp-script src="/Pages/CmsKit/Comments/Waiting/index.js" />
<abp-script src="/Pages/CmsKit/Comments/Approve/index.js" />
</abp-script-bundle>
}

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/Index.cshtml.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/Index.cshtml.cs

@ -2,7 +2,7 @@ using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Comments.Waiting;
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Comments.Approve;
public class IndexModel : CmsKitAdminPageModel
{

52
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/index.js → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/index.js

@ -17,8 +17,8 @@
};
var defaultStartDate = moment().add(-7, 'days');
$("#CreationStartDate").val(defaultStartDate.format('L'));
//var defaultStartDate = moment().add(-7, 'days');
//$("#CreationStartDate").val(defaultStartDate.format('L'));
$('.singledatepicker').daterangepicker({
"singleDatePicker": true,
@ -67,32 +67,31 @@
rowAction: {
items: [
{
text: l('Details'),
action: function (data) {
location.href = 'Comments/' + data.record.id;
}
},
{
text: l('Delete'),
visible: abp.auth.isGranted('CmsKit.Comments.Delete'),
confirmMessage: function (data) {
return l("CommentDeletionConfirmationMessage")
text: function (data) {
return l('Approve');
},
action: function (data) {
var newApprovalStatus = true;
commentsService
.delete(data.record.id)
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () {
_dataTable.ajax.reloadEx();
abp.notify.success(l('DeletedSuccessfully'));
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
.catch(function (error) {
console.log("error", error)
abp.notify.error(error.message);
});
}
},
{
text: function (data) {
return data.isApproved ? l('Revoke Approval') : l('Approve');
return l('Revoke Approval') ;
},
action: function (data) {
var newApprovalStatus = !data.record?.isApproved;
var newApprovalStatus = false;
commentsService
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
@ -134,16 +133,6 @@
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",
@ -151,20 +140,13 @@
render: function (data) {
data = $.fn.dataTable.render.text().display(data || "");
var maxChars = 64;
if (data.length > maxChars) {
return (
'<span data-toggle="tooltip" title="' +
data +
'">' +
data.substring(0, maxChars) +
"..." +
'" style="white-space: normal; word-break: break-all;">' +
data +
"</span>"
);
} else {
return data;
}
}
},
{

12
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml

@ -93,6 +93,18 @@
<abp-column size-lg="_4" size-md="_12">
<abp-input asp-for="@Model.Author" label="@L["Username"].Value" type="text"/>
</abp-column>
<abp-column size-lg="_2" size-md="_12">
<div class="mb-3">
<label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label>
<select id="isApprovedSelect" asp-for="@Model.IsApproved" class="form-control">
<option value="">@L["CommentFilter:All"].Value</option>
<option value="true">@L["CommentFilter:Approved"].Value</option>
<option value="false">@L["CommentFilter:Disapproved"].Value</option>
<option value="null">@L["CommentFilter:Waiting"].Value</option>
</select>
</div>
</abp-column>
<abp-column size-lg="_2" size-md="_12">
<div class="d-grid gap-2">
<abp-button class="mt-md-4" button-type="Primary" type="submit">

1
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml.cs

@ -15,6 +15,7 @@ public class DetailsModel : CmsKitAdminPageModel
public DateTime? CreationStartDate { get; set; }
public DateTime? CreationEndDate { get; set; }
public string IsApproved { get; set; }
public CommentWithAuthorDto CommentWithAuthorDto { get; protected set; }

17
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml

@ -42,7 +42,7 @@
<abp-column size-lg="_4" size-md="_12">
<abp-row>
<abp-column size-lg="_6" size-md="_6">
<abp-input asp-for="@Model.CreationStartDate" class="singledatepicker" label="@L["StartDate"].Value" type="text" />
<abp-input asp-for="@Model.CreationStartDate" class="singledatepicker" label="@L["StartDate"].Value" type="text" value="" />
</abp-column>
<abp-column size-lg="_6" size-md="_6">
<abp-input asp-for="@Model.CreationEndDate" class="singledatepicker" label="@L["EndDate"].Value" type="text" />
@ -59,12 +59,15 @@
</abp-column>
<abp-column size-lg="_2" size-md="_6">
<select asp-for="@Model.IsApproved" label="@L["IsApproved"].Value">
<option value="">@L["All"].Value</option>
<option value="true">@L["Approved"].Value</option>
<option value="false">@L["Rejected"].Value</option>
<option value="null">@L["Pending"].Value</option>
</select>
<div class="mb-3">
<label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label>
<select id="isApprovedSelect" asp-for="@Model.IsApproved" class="form-control">
<option value="">@L["CommentFilter:All"].Value</option>
<option value="true">@L["CommentFilter:Approved"].Value</option>
<option value="false">@L["CommentFilter:Disapproved"].Value</option>
<option value="null">@L["CommentFilter:Waiting"].Value</option>
</select>
</div>
</abp-column>
<abp-column size-lg="_2" size-md="_6">

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml.cs

@ -8,7 +8,7 @@ public class IndexModel : CmsKitAdminPageModel
public string Author { get; set; }
public DateTime? CreationStartDate { get; set; }
public DateTime? CreationStartDate { get; set; } = null;
public DateTime? CreationEndDate { get; set; }
public string IsApproved { get; set; }

24
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/details.js

@ -81,7 +81,7 @@ $(function (){
},
{
text: function (data) {
return data.isApproved ? l('Revoke Approval') : l('Approve');
return data.isApproved ? l('Disapproved') : l('Approve');
},
action: function (data) {
var newApprovalStatus = !data.record?.isApproved;
@ -94,7 +94,27 @@ $(function (){
abp.notify.success(message);
})
.catch(function (error) {
console.log("error", error)
abp.notify.error(error.message);
});
}
},
{
text: function (data) {
if (data.isApproved == null) {
return l('Disapproved')
}
},
action: function (data) {
var newApprovalStatus = false;
commentsService
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () {
_dataTable.ajax.reloadEx();
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
.catch(function (error) {
abp.notify.error(error.message);
});
}

32
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js

@ -17,8 +17,8 @@ $(function (){
};
var defaultStartDate = moment().add(-7, 'days');
$("#CreationStartDate").val(defaultStartDate.format('L'));
//var defaultStartDate = moment().add(-7, 'days');
//$("#CreationStartDate").val(defaultStartDate.format('L'));
$('.singledatepicker').daterangepicker({
"singleDatePicker": true,
@ -89,7 +89,7 @@ $(function (){
},
{
text: function (data) {
return data.isApproved ? l('Revoke Approval') : l('Approve');
return data.isApproved ? l('Disapproved') : l('Approve');
},
action: function (data) {
var newApprovalStatus = !data.record?.isApproved;
@ -102,7 +102,27 @@ $(function (){
abp.notify.success(message);
})
.catch(function (error) {
console.log("error", error)
abp.notify.error(error.message);
});
}
},
{
text: function (data) {
if (data.isApproved == null) {
return l('Disapproved')
}
},
action: function (data) {
var newApprovalStatus = false;
commentsService
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () {
_dataTable.ajax.reloadEx();
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
.catch(function (error) {
abp.notify.error(error.message);
});
}
@ -220,12 +240,12 @@ $(function (){
commentsService.getPendingCommentCount().then(function (count) {
console.log(count)
if (count > 0) {
var alertMessage = 'You have pending comments: ' + count;
var alertMessage = l("CommentAlertMessage") + count + "";
var alertElement = '<abp-alert alert-type="Warning">' + alertMessage + '</abp-alert>';
$('#commentsAlert').html(alertElement);
$('#commentsAlert').show()
$('#commentsAlert').click(function () {
window.location.href = '/Cms/Comments/Waiting'
window.location.href = '/Cms/Comments/Approve'
});
}
});

9
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Settings/BookStoreSettingPageContributor.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Settings/CommentSettingPageContributor.cs

@ -1,17 +1,22 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
using Volo.CmsKit.Admin.Web.Components.MySettingGroup;
using Volo.CmsKit.Localization;
namespace Volo.CmsKit.Admin.Web.Settings;
public class BookStoreSettingPageContributor : ISettingPageContributor
public class CommentSettingPageContributor : ISettingPageContributor
{
public Task ConfigureAsync(SettingPageCreationContext context)
{
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<CmsKitResource>>();
context.Groups.Add(
new SettingPageGroup(
"Volo.Abp.MySettingGroup",
"MySettingGroup",
l["Menu:CmsKitCommentOptions"],
typeof(CommentSettingViewComponent),
order: 1
)

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Volo.CmsKit.Admin.Web.csproj

@ -36,7 +36,7 @@
<ItemGroup>
<None Remove="Components\CommentsSetting\Index.js" />
<None Remove="Pages\CmsKit\Comments\Waiting\index.js" />
<None Remove="Pages\CmsKit\Comments\Approve\index.js" />
</ItemGroup>
<ItemGroup>

22
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json

@ -230,8 +230,24 @@
"DuplicateCommentAttemptMessage": "Duplicate comment post attempt detected. Your comment has already been submitted.",
"NoBlogPostYet": "No blog post yet!",
"CommentSettings:Title": "Comment Settings.",
"CommentSettings:RequireApprovement": "Require approval for comments",
"CommentSettings:RequireApprovementDescription": "When enabled, comments will require approval before being published."
"CmsKitCommentOptions:Title": "Comment Settings.",
"CmsKitCommentOptions:RequireApprovement": "Require approval for comments",
"CmsKitCommentOptions:RequireApprovementDescription": "When enabled, comments will require approval before being published.",
"CommentFilter:ApproveState":"Approve State",
"CommentFilter:All":"All",
"CommentFilter:Approved":"Approved",
"CommentFilter:Disapproved":"Disapproved",
"CommentFilter:Waiting":"Waiting",
"ApprovedSuccessfully":"Approved Successfully",
"ApprovalRevokedSuccessfully":"Approval Revoked Successfully",
"Approve":"Approve",
"Disapproved":"Disapproved",
"CommentAlertMessage":"You have waiting comments: ",
"Menu:CmsKitCommentOptions":"CmsKit Comment Options"
}
}

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs

@ -39,7 +39,7 @@ public interface ICommentRepository : IBasicRepository<Comment, Guid>
Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
[NotNull] string entityType,
[NotNull] string entityId,
bool? isApproved = null,
bool? isApproved,
CancellationToken cancellationToken = default
);

21
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs

@ -117,7 +117,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
public virtual async Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
string entityType,
string entityId,
bool? isApproved = null,
bool? isApproved,
CancellationToken cancellationToken = default)
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
@ -134,20 +134,16 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
var commentsQuery = (await GetMongoQueryableAsync(cancellationToken))
.Where(c => c.EntityId == entityId && c.EntityType == entityType);
if (isApproved.HasValue)
{
commentsQuery = commentsQuery.Where(c => c.IsApproved == isApproved.Value);
}
commentsQuery = isApproved.Value ?
commentsQuery.Where(c => c.IsApproved == true) :
commentsQuery.Where(c => c.IsApproved == true || c.IsApproved == null);
var comments = await commentsQuery
.OrderBy(c => c.CreationTime)
.ToListAsync(GetCancellationToken(cancellationToken));
// var comments = await (await GetMongoQueryableAsync(cancellationToken))
//.Where(c => c.EntityId == entityId && c.EntityType == entityType )
// .OrderBy(c => c.CreationTime)
//.ToListAsync(GetCancellationToken(cancellationToken));
return comments
.Select(
comment =>
@ -213,8 +209,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
.WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId)
.WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate)
.WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate);
//.WhereIf(isApproved.HasValue, c => c.IsApproved == isApproved.Value)
//.WhereIf(isApproved == null, c => c.IsApproved == null);
if (!string.IsNullOrWhiteSpace(isApproved))
{
bool? isApprovedValue = ParseIsApproved(isApproved);
@ -229,10 +224,8 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
}
return queryable;
}
public static bool? ParseIsApproved(string isApproved)
{

6
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

@ -57,11 +57,9 @@ public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPubli
public virtual async Task<ListResultDto<CommentWithDetailsDto>> GetListAsync(string entityType, string entityId)
{
string checkboxState = await SettingManager.GetOrNullGlobalAsync(AppSettings.RequireApprovement);
string state = await SettingManager.GetOrNullGlobalAsync(AppSettings.RequireApprovement);
var commentsWithAuthor = bool.Parse(checkboxState) ?
await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, true) :
await CommentRepository.GetListWithAuthorsAsync(entityType, entityId);
var commentsWithAuthor = await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, bool.Parse(state));
return new ListResultDto<CommentWithDetailsDto>(
ConvertCommentsToNestedStructure(commentsWithAuthor)

Loading…
Cancel
Save