Browse Source

code review was done

pull/19919/head
EmreKendirli 2 years ago
parent
commit
538741954c
  1. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentSettingsDto.cs
  2. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs
  3. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs
  4. 26
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/Volo/CmsKit/Admin/Comments/CommentAdminClientProxy.Generated.cs
  5. 236
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/cms-kit-admin-generate-proxy.json
  6. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs
  7. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs
  8. 8
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/index.js
  9. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/details.js
  10. 78
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js
  11. 1
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingPageContributor.cs
  12. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingScriptBundleContributor.cs
  13. 54
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/Index.cshtml
  14. 69
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/index.js
  15. 23
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/client-proxies/cms-kit-admin-proxy.js
  16. 8356
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/libs/markdown-it/markdown-it.js
  17. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/libs/markdown-it/markdown-it.min.js
  18. 6
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentSettingsDto.cs

@ -3,7 +3,7 @@
namespace Volo.CmsKit.Admin.Comments;
[Serializable]
public class SettingsDto
public class CommentSettingsDto
{
public bool CommentRequireApprovement { get; set; }
}

4
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs

@ -15,9 +15,9 @@ public interface ICommentAdminAppService : IApplicationService
Task UpdateApprovalStatusAsync(Guid id, CommentApprovalDto input);
Task SetSettingsAsync(SettingsDto input);
Task SetSettingsAsync(CommentSettingsDto input);
Task<SettingsDto> GetSettingsAsync();
Task<CommentSettingsDto> GetSettingsAsync();
Task<int> GetWaitingCountAsync();
}

6
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs

@ -93,16 +93,16 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp
}
[Authorize(CmsKitAdminPermissions.Comments.Update)]
public async Task SetSettingsAsync(SettingsDto input)
public async Task SetSettingsAsync(CommentSettingsDto input)
{
await _settingManager.SetGlobalAsync(AppSettings.CommentRequireApprovement, input.CommentRequireApprovement.ToString());
}
public async Task<SettingsDto> GetSettingsAsync()
public async Task<CommentSettingsDto> GetSettingsAsync()
{
var isRequireApprovementEnabled = bool.Parse(await _settingManager.GetOrNullGlobalAsync(AppSettings.CommentRequireApprovement));
return new SettingsDto
return new CommentSettingsDto
{
CommentRequireApprovement = isRequireApprovementEnabled
};

26
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/Volo/CmsKit/Admin/Comments/CommentAdminClientProxy.Generated.cs

@ -50,29 +50,21 @@ public partial class CommentAdminClientProxy : ClientProxyBase<ICommentAdminAppS
});
}
public virtual void SetSettings(SettingsDto settingsDto)
public virtual async Task SetSettingsAsync(CommentSettingsDto input)
{
//Client Proxy does not support the synchronization method, you should always use asynchronous methods as a best practice
throw new System.NotImplementedException();
}
public virtual SettingsDto GetSettings()
{
//Client Proxy does not support the synchronization method, you should always use asynchronous methods as a best practice
throw new System.NotImplementedException();
await RequestAsync(nameof(SetSettingsAsync), new ClientProxyRequestTypeValue
{
{ typeof(CommentSettingsDto), input }
});
}
public virtual int GetWaitingCommentCount()
public virtual async Task<CommentSettingsDto> GetSettingsAsync()
{
//Client Proxy does not support the synchronization method, you should always use asynchronous methods as a best practice
throw new System.NotImplementedException();
return await RequestAsync<CommentSettingsDto>(nameof(GetSettingsAsync));
}
public virtual async Task<PagedResultDto<CommentWithAuthorDto>> GetWaitingWithRepliesAsync(CommentGetListInput input)
public virtual async Task<int> GetWaitingCountAsync()
{
return await RequestAsync<PagedResultDto<CommentWithAuthorDto>>(nameof(GetWaitingWithRepliesAsync), new ClientProxyRequestTypeValue
{
{ typeof(CommentGetListInput), input }
});
return await RequestAsync<int>(nameof(GetWaitingCountAsync));
}
}

236
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/cms-kit-admin-generate-proxy.json

@ -1280,7 +1280,7 @@
"defaultValue": null
},
{
"name": "commentApprovalDto",
"name": "input",
"typeAsString": "Volo.CmsKit.Admin.Comments.CommentApprovalDto, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.CommentApprovalDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentApprovalDto",
@ -1294,13 +1294,13 @@
}
},
{
"name": "SetSettings",
"name": "SetSettingsAsync",
"parametersOnMethod": [
{
"name": "settingsDto",
"typeAsString": "Volo.CmsKit.Admin.Comments.SettingsDto, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.SettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.SettingsDto",
"name": "input",
"typeAsString": "Volo.CmsKit.Admin.Comments.CommentSettingsDto, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"isOptional": false,
"defaultValue": null
}
@ -1311,37 +1311,20 @@
}
},
{
"name": "GetSettings",
"name": "GetSettingsAsync",
"parametersOnMethod": [],
"returnValue": {
"type": "Volo.CmsKit.Admin.Comments.SettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.SettingsDto"
"type": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentSettingsDto"
}
},
{
"name": "GetWaitingCommentCount",
"name": "GetWaitingCountAsync",
"parametersOnMethod": [],
"returnValue": {
"type": "System.Int32",
"typeSimple": "number"
}
},
{
"name": "GetWaitingCommentsWithRepliesAsync",
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "Volo.CmsKit.Admin.Comments.CommentGetListInput, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.CommentGetListInput",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentGetListInput",
"isOptional": false,
"defaultValue": null
}
],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.PagedResultDto<Volo.CmsKit.Admin.Comments.CommentWithAuthorDto>",
"typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto<Volo.CmsKit.Admin.Comments.CommentWithAuthorDto>"
}
}
]
}
@ -1438,7 +1421,7 @@
},
{
"nameOnMethod": "input",
"name": "commentApproveStateType",
"name": "CommentApproveState",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
@ -1566,11 +1549,11 @@
"allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
},
"UpdateApprovalStatusAsyncByIdAndCommentApprovalDto": {
"uniqueName": "UpdateApprovalStatusAsyncByIdAndCommentApprovalDto",
"UpdateApprovalStatusAsyncByIdAndInput": {
"uniqueName": "UpdateApprovalStatusAsyncByIdAndInput",
"name": "UpdateApprovalStatusAsync",
"httpMethod": "POST",
"url": "api/cms-kit-admin/comments/{id}",
"httpMethod": "PUT",
"url": "api/cms-kit-admin/comments/{id}/approval-status",
"supportedVersions": [],
"parametersOnMethod": [
{
@ -1582,7 +1565,7 @@
"defaultValue": null
},
{
"name": "commentApprovalDto",
"name": "input",
"typeAsString": "Volo.CmsKit.Admin.Comments.CommentApprovalDto, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.CommentApprovalDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentApprovalDto",
@ -1604,8 +1587,8 @@
"descriptorName": ""
},
{
"nameOnMethod": "commentApprovalDto",
"name": "commentApprovalDto",
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "Volo.CmsKit.Admin.Comments.CommentApprovalDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentApprovalDto",
@ -1623,29 +1606,29 @@
"allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
},
"SetSettingsBySettingsDto": {
"uniqueName": "SetSettingsBySettingsDto",
"name": "SetSettings",
"SetSettingsAsyncByInput": {
"uniqueName": "SetSettingsAsyncByInput",
"name": "SetSettingsAsync",
"httpMethod": "POST",
"url": "api/cms-kit-admin/comments/settings",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "settingsDto",
"typeAsString": "Volo.CmsKit.Admin.Comments.SettingsDto, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.SettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.SettingsDto",
"name": "input",
"typeAsString": "Volo.CmsKit.Admin.Comments.CommentSettingsDto, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "settingsDto",
"name": "settingsDto",
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "Volo.CmsKit.Admin.Comments.SettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.SettingsDto",
"type": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
@ -1660,24 +1643,24 @@
"allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
},
"GetSettings": {
"uniqueName": "GetSettings",
"name": "GetSettings",
"GetSettingsAsync": {
"uniqueName": "GetSettingsAsync",
"name": "GetSettingsAsync",
"httpMethod": "GET",
"url": "api/cms-kit-admin/comments/settings",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "Volo.CmsKit.Admin.Comments.SettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.SettingsDto"
"type": "Volo.CmsKit.Admin.Comments.CommentSettingsDto",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentSettingsDto"
},
"allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
},
"GetWaitingCommentCount": {
"uniqueName": "GetWaitingCommentCount",
"name": "GetWaitingCommentCount",
"GetWaitingCountAsync": {
"uniqueName": "GetWaitingCountAsync",
"name": "GetWaitingCountAsync",
"httpMethod": "GET",
"url": "api/cms-kit-admin/comments/waiting-count",
"supportedVersions": [],
@ -1689,151 +1672,6 @@
},
"allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
},
"GetWaitingCommentsWithRepliesAsyncByInput": {
"uniqueName": "GetWaitingCommentsWithRepliesAsyncByInput",
"name": "GetWaitingCommentsWithRepliesAsync",
"httpMethod": "GET",
"url": "api/cms-kit-admin/comments/waiting",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "Volo.CmsKit.Admin.Comments.CommentGetListInput, Volo.CmsKit.Admin.Application.Contracts",
"type": "Volo.CmsKit.Admin.Comments.CommentGetListInput",
"typeSimple": "Volo.CmsKit.Admin.Comments.CommentGetListInput",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "EntityType",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "Text",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "RepliedCommentId",
"jsonName": null,
"type": "System.Guid?",
"typeSimple": "string?",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "Author",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "CreationStartDate",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "CreationEndDate",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "commentApproveStateType",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "Sorting",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "SkipCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "MaxResultCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
}
],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.PagedResultDto<Volo.CmsKit.Admin.Comments.CommentWithAuthorDto>",
"typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto<Volo.CmsKit.Admin.Comments.CommentWithAuthorDto>"
},
"allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
}
}
},

4
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs

@ -60,7 +60,7 @@ public class CommentAdminController : CmsKitAdminController, ICommentAdminAppSer
[HttpPost]
[Route("settings")]
[Authorize(CmsKitAdminPermissions.Comments.Update)]
public Task SetSettingsAsync(SettingsDto input)
public Task SetSettingsAsync(CommentSettingsDto input)
{
return CommentAdminAppService.SetSettingsAsync(input);
}
@ -68,7 +68,7 @@ public class CommentAdminController : CmsKitAdminController, ICommentAdminAppSer
[HttpGet]
[Route("settings")]
[Authorize(CmsKitAdminPermissions.Comments.Default)]
public Task<SettingsDto> GetSettingsAsync()
public Task<CommentSettingsDto> GetSettingsAsync()
{
return CommentAdminAppService.GetSettingsAsync();
}

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

@ -66,7 +66,7 @@ public class CmsKitAdminWebModule : AbpModule
.Configure(typeof(Abp.SettingManagement.Web.Pages.SettingManagement.IndexModel).FullName,
configuration =>
{
configuration.AddFiles("/client-proxies/cms-kit-admin-proxy.js");
configuration.AddContributors(typeof(CommentSettingScriptBundleContributor));
})
.Configure(StandardBundles.Scripts.Global,
configuration =>
@ -99,13 +99,13 @@ public class CmsKitAdminWebModule : AbpModule
options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts/Create", CmsKitAdminPermissions.BlogPosts.Create);
options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts/Update", CmsKitAdminPermissions.BlogPosts.Update);
options.Conventions.AuthorizeFolder("/CmsKit/Comments/", CmsKitAdminPermissions.Comments.Default);
options.Conventions.AuthorizeFolder("/CmsKit/Comments/Approve", CmsKitAdminPermissions.Comments.Default);
options.Conventions.AuthorizeFolder("/CmsKit/Comments/Details", CmsKitAdminPermissions.Comments.Default);
options.Conventions.AuthorizeFolder("/CmsKit/Menus", CmsKitAdminPermissions.Menus.Default);
options.Conventions.AuthorizePage("/CmsKit/Menus/MenuItems/CreateModal", CmsKitAdminPermissions.Menus.Create);
options.Conventions.AuthorizePage("/CmsKit/Menus/MenuItems/UpdateModal", CmsKitAdminPermissions.Menus.Update);
options.Conventions.AuthorizeFolder("/CmsKit/Menus/MenuItems", CmsKitAdminPermissions.Menus.Update);
options.Conventions.AuthorizeFolder("/CmsKit/GlobalResources", CmsKitAdminPermissions.GlobalResources.Default);
// TODO: Add /CmsKit/Comments/Approve/Index page
});
Configure<RazorPagesOptions>(options =>

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

@ -42,6 +42,7 @@
filterObj.creationStartDate = getFormattedDate($('#CreationStartDate'));
filterObj.creationEndDate = getFormattedDate($('#CreationEndDate'));
filterObj.commentApproveState = "Waiting";
return filterObj;
};
@ -54,7 +55,7 @@
scrollX: true,
searching: false,
scrollCollapse: true,
ajax: abp.libs.datatables.createAjax(commentsService.getWaitingCommentsWithReplies, getFilter),
ajax: abp.libs.datatables.createAjax(commentsService.getList, getFilter),
columnDefs: [
{
width: "10%",
@ -132,12 +133,7 @@
title: l("Text"),
data: "text",
orderable: false,
render: function (data) {
//var converter = new showdown.Converter();
//var htmlContent = converter.makeHtml(data);
var md = window.markdownit();
var htmlContent = md.render(data);
return (htmlContent);

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

@ -201,7 +201,7 @@ $(function (){
_dataTable.ajax.reloadEx();
});
commentsService.getSettings().then(function (data) {
if (data.requireApprovement) {
if (data.commentRequireApprovement) {
$('#CommentsTable').DataTable().column(4).visible(true);
} else {
$('#CommentsTable').DataTable().column(4).visible(false);

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

@ -1,21 +1,21 @@
$(function (){
$(function () {
var l = abp.localization.getResource("CmsKit");
var commentsService = volo.cmsKit.admin.comments.commentAdmin;
var detailsModal = new abp.ModalManager(abp.appPath + "CmsKit/Comments/DetailsModal");
moment()._locale.preparse = (string) => string;
moment()._locale.postformat = (string) => string;
var getFormattedDate = function ($datePicker) {
if(!$datePicker.val()) {
if (!$datePicker.val()) {
return null;
}
var momentDate = moment($datePicker.val(), $datePicker.data('daterangepicker').locale.format);
return momentDate.isValid() ? momentDate.toISOString() : null;
};
$('.singledatepicker').daterangepicker({
"singleDatePicker": true,
@ -26,27 +26,27 @@ $(function (){
"drops": "auto"
});
$('.singledatepicker').attr('autocomplete', 'off');
$('.singledatepicker').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('l'));
});
var filterForm = $('#CmsKitCommentsFilterForm');
var getFilter = function () {
var filterObj = filterForm.serializeFormToObject();
filterObj.creationStartDate = getFormattedDate($('#CreationStartDate'));
filterObj.creationEndDate = getFormattedDate($('#CreationEndDate'));
return filterObj;
};
var _dataTable = $('#CommentsTable').DataTable(abp.libs.datatables.normalizeConfiguration({
processing: true,
serverSide: true,
@ -80,6 +80,7 @@ $(function (){
.delete(data.record.id)
.then(function () {
_dataTable.ajax.reloadEx();
checkWaitingComments()
abp.notify.success(l('DeletedSuccessfully'));
});
}
@ -95,6 +96,7 @@ $(function (){
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () {
_dataTable.ajax.reloadEx();
checkWaitingComments()
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
@ -116,6 +118,7 @@ $(function (){
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () {
_dataTable.ajax.reloadEx();
checkWaitingComments()
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
@ -156,7 +159,7 @@ $(function (){
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 '<a href="' + data + '#comment-' + row.id + '" target="_blank"><i class="fa fa-location-arrow"></i></a>';
}
return "";
}
@ -215,46 +218,47 @@ $(function (){
}
]
}));
function GetFilterableDatatableContent(filterSelector, data){
return '<span class="datatableCell" data-field="'+ filterSelector +'" data-val="'+ data +'">' + data + '</span>';
function GetFilterableDatatableContent(filterSelector, data) {
return '<span class="datatableCell" data-field="' + filterSelector + '" data-val="' + data + '">' + data + '</span>';
}
$(document).on('click', '.datatableCell', function () {
var inputSelector = $(this).attr('data-field');
var value = $(this).attr('data-val');
$(inputSelector).val(value);
_dataTable.ajax.reloadEx();
});
filterForm.submit(function (e){
filterForm.submit(function (e) {
e.preventDefault();
_dataTable.ajax.reloadEx();
});
// TODO: Replace these methods because ther are replaced in appservice
commentsService.getWaitingCommentCount().then(function (count) {
if (count > 0) {
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/Approve'
});
}
});
function checkWaitingComments() {
commentsService.getWaitingCount().then(function (count) {
if (count > 0) {
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/Approve'
});
} else {
$('#commentsAlert').hide()
}
});
}
checkWaitingComments()
commentsService.getSettings().then(function (data) {
if (data.requireApprovement) {
if (data.commentRequireApprovement) {
$('#CommentsTable').DataTable().column(6).visible(true);
} else {
$('#CommentsTable').DataTable().column(6).visible(false);
$('#isApprovedColumn').hide();
}
})
// TODO: if I change the state of the comment, you should update the alert message
});

1
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingPageContributor.cs

@ -8,6 +8,7 @@ namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Shared.Components.Comments;
public class CommentSettingPageContributor : ISettingPageContributor
{
public Task ConfigureAsync(SettingPageCreationContext context)
{
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<CmsKitResource>>();

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingScriptBundleContributor.cs

@ -7,7 +7,7 @@ public class CommentSettingScriptBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js");
context.Files.AddIfNotContains("/client-proxies/cms-kit-admin-proxy.js");
context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Comments/index.js");
}
}

54
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/Index.cshtml

@ -9,19 +9,18 @@
<abp-script-bundle>
<abp-script src="/client-proxies/cms-kit-admin-proxy.js" />
<abp-script src="/client-proxies/cms-kit-common-proxy.js" />
@* <abp-script src="" /> *@
<abp-script src="/Pages/CmsKit/Shared/Components/Comments/index.js"></abp-script>
</abp-script-bundle>
}
@{
@inject IHtmlLocalizer<CmsKitResource> L
<abp-form #form="ngForm">
<abp-form id="deneme1" form="CmsKitCommentSettingsForm">
<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 />
<input type="checkbox" id="checkbox" class="form-check-input" name="checkbox" />
<label for="checkbox" class="form-check-label">@L["CmsKitCommentOptions:RequireApprovement"].Value</label>
</div>
<small id="checkboxHelp" class="form-text text-muted">@L["CmsKitCommentOptions:RequireApprovementDescription"].Value</small>
@ -33,55 +32,6 @@
</abp-button>
</div>
</abp-form>
}
<script>
var l = abp.localization.getResource("CmsKit");
var app = app || {};
app.commentAdmin = (function () {
var _service = volo.cmsKit.admin.comments.commentAdmin;
var _init = function () {
_getSettings();
_bindEvents();
};
var _getSettings = function () {
_service.getSettings().done(function (response) {
var isChecked = response.requireApprovement;
$('#checkbox').prop('checked', isChecked);
console.log('CheckBox durumu başarıyla güncellendi:', response.requireApprovement);
}).fail(function (error) {
console.error('CheckBox durumu alınırken bir hata oluştu:', error);
});
};
var _bindEvents = function () {
$('#save').click(function () {
var isChecked = $('#checkbox').prop('checked');
_service.setSettings({ requireApprovement: isChecked }).done(function (response) {
console.log('CheckBox durumu başarıyla güncellendi:', response);
abp.notify.success(l("SavedSuccessfully"));
}).fail(function (error) {
console.error('CheckBox durumu güncellenirken bir hata oluştu:', error);
abp.notify.error('CheckBox durumu kaydedilirken bir hata oluştu.');
});
});
};
return {
init: _init
};
})();
$(document).ready(function () {
app.commentAdmin.init();
});
</script>

69
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/index.js

@ -1,47 +1,30 @@

//$(document).ready(function () {
// var service = volo.cmsKit.admin.comments.commentAdmin;
// service.getSettings().done(function (response) {
// var isChecked = response.requireApprovement
// $('#checkbox').prop('checked', isChecked);
// console.log('CheckBox durumu başarıyla güncellendi:', response.requireApprovement);
// }).fail(function (error) {
// console.error('CheckBox durumu alınırken bir hata oluştu:', error);
// });
var l = abp.localization.getResource("CmsKit");
(function () {
abp.widgets.CmsCommentSetting = function ($wrapper) {
// $('#save').click(function () {
// var isChecked = $('#checkbox').prop('checked');
var _service = volo.cmsKit.admin.comments.commentAdmin;
var _init = function () {
_getSettings();
_bindEvents();
};
var _getSettings = function () {
_service.getSettings().then(function (response) {
$('#checkbox').prop('checked', response.commentRequireApprovement);
})
};
// service.setSettings({ RequireApprovement: isChecked }).done(function (response) {
// console.log('CheckBox durumu başarıyla güncellendi:', response);
// alert('CheckBox durumu başarıyla kaydedildi.');
// }).fail(function (error) {
// console.error('CheckBox durumu güncellenirken bir hata oluştu:', error);
// alert('CheckBox durumu kaydedilirken bir hata oluştu.');
// });
// });
//});
console.log("dsf")
var service = volo.cmsKit.admin.comments.commentAdmin;
var _bindEvents = function () {
$('#save').click(function () {
var isChecked = $('#checkbox').prop('checked');
_service.setSettings({ commentRequireApprovement: isChecked }).then(function (response) {
abp.notify.success(l("SavedSuccessfully"));
})
});
};
$(document).ready(function () {
service.getSettings().done(function (response) {
var isChecked = response.requireApprovement
$('#checkbox').prop('checked', isChecked);
console.log('CheckBox durumu başarıyla güncellendi:', response.requireApprovement);
}).fail(function (error) {
console.error('CheckBox durumu alınırken bir hata oluştu:', error);
});
$('#save').click(function () {
var isChecked = $('#checkbox').prop('checked');
service.setSettings({ RequireApprovement: isChecked }).done(function (response) {
console.log('CheckBox durumu başarıyla güncellendi:', response);
alert('CheckBox durumu başarıyla kaydedildi.');
}).fail(function (error) {
console.error('CheckBox durumu güncellenirken bir hata oluştu:', error);
alert('CheckBox durumu kaydedilirken bir hata oluştu.');
});
});
});
return {
init: _init
};
};
})();

23
modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/client-proxies/cms-kit-admin-proxy.js

@ -176,7 +176,7 @@
volo.cmsKit.admin.comments.commentAdmin.getList = function(input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments' + abp.utils.buildQueryString([{ name: 'entityType', value: input.entityType }, { name: 'text', value: input.text }, { name: 'repliedCommentId', value: input.repliedCommentId }, { name: 'author', value: input.author }, { name: 'creationStartDate', value: input.creationStartDate }, { name: 'creationEndDate', value: input.creationEndDate }, { name: 'commentApproveStateType', value: input.commentApproveStateType }, { name: 'sorting', value: input.sorting }, { name: 'skipCount', value: input.skipCount }, { name: 'maxResultCount', value: input.maxResultCount }]) + '',
url: abp.appPath + 'api/cms-kit-admin/comments' + abp.utils.buildQueryString([{ name: 'entityType', value: input.entityType }, { name: 'text', value: input.text }, { name: 'repliedCommentId', value: input.repliedCommentId }, { name: 'author', value: input.author }, { name: 'creationStartDate', value: input.creationStartDate }, { name: 'creationEndDate', value: input.creationEndDate }, { name: 'commentApproveState', value: input.commentApproveState }, { name: 'sorting', value: input.sorting }, { name: 'skipCount', value: input.skipCount }, { name: 'maxResultCount', value: input.maxResultCount }]) + '',
type: 'GET'
}, ajaxParams));
};
@ -196,21 +196,21 @@
}, ajaxParams));
};
volo.cmsKit.admin.comments.commentAdmin.updateApprovalStatus = function(id, commentApprovalDto, ajaxParams) {
volo.cmsKit.admin.comments.commentAdmin.updateApprovalStatus = function(id, input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/' + id + '',
type: 'POST',
url: abp.appPath + 'api/cms-kit-admin/comments/' + id + '/approval-status',
type: 'PUT',
dataType: null,
data: JSON.stringify(commentApprovalDto)
data: JSON.stringify(input)
}, ajaxParams));
};
volo.cmsKit.admin.comments.commentAdmin.setSettings = function(settingsDto, ajaxParams) {
volo.cmsKit.admin.comments.commentAdmin.setSettings = function(input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/settings',
type: 'POST',
dataType: null,
data: JSON.stringify(settingsDto)
data: JSON.stringify(input)
}, ajaxParams));
};
@ -221,20 +221,13 @@
}, ajaxParams));
};
volo.cmsKit.admin.comments.commentAdmin.getWaitingCommentCount = function(ajaxParams) {
volo.cmsKit.admin.comments.commentAdmin.getWaitingCount = function(ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/waiting-count',
type: 'GET'
}, ajaxParams));
};
volo.cmsKit.admin.comments.commentAdmin.getWaitingCommentsWithReplies = function(input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/waiting' + abp.utils.buildQueryString([{ name: 'entityType', value: input.entityType }, { name: 'text', value: input.text }, { name: 'repliedCommentId', value: input.repliedCommentId }, { name: 'author', value: input.author }, { name: 'creationStartDate', value: input.creationStartDate }, { name: 'creationEndDate', value: input.creationEndDate }, { name: 'commentApproveStateType', value: input.commentApproveStateType }, { name: 'sorting', value: input.sorting }, { name: 'skipCount', value: input.skipCount }, { name: 'maxResultCount', value: input.maxResultCount }]) + '',
type: 'GET'
}, ajaxParams));
};
})();
// controller volo.cmsKit.admin.globalResources.globalResourceAdmin

8356
modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/libs/markdown-it/markdown-it.js

File diff suppressed because it is too large

3
modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/libs/markdown-it/markdown-it.min.js

File diff suppressed because one or more lines are too long

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

@ -229,25 +229,19 @@
"ThisPartOfContentCouldntBeLoaded": "This part of content couldn't be loaded.",
"DuplicateCommentAttemptMessage": "Duplicate comment post attempt detected. Your comment has already been submitted.",
"NoBlogPostYet": "No blog post yet!",
"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":"There are {0} comments waiting for approval",
"Menu:CmsKitCommentOptions":"CmsKit Comment Options"
}
}
Loading…
Cancel
Save