Browse Source

code review was done

pull/19919/head
Emre 2 years ago
parent
commit
98fd8b26a0
  1. 6
      docs/en/Modules/Cms-Kit/Comments.md
  2. 1
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs
  3. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml
  4. 20
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js
  5. 23
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingPageContributor.cs
  6. 38
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/default.js
  7. 1
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs

6
docs/en/Modules/Cms-Kit/Comments.md

@ -80,6 +80,12 @@ You can also view and manage replies on this page.
![comments-detail](../../images/cmskit-module-comments-detail.png)
## Settings
You can configure the approval status of comments using the CmsKit Comment Options tab on the Settings page.
![comments-settings](../../images/cmskit-module-comments-settings.png)
## Internals
### Domain Layer

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

@ -50,7 +50,6 @@ public class CommentAdminController : CmsKitAdminController, ICommentAdminAppSer
[HttpPut]
[Route("{id}/approval-status")]
[Authorize(CmsKitAdminPermissions.Comments.Update)]
public Task UpdateApprovalStatusAsync(Guid id, CommentApprovalDto input)
{
return CommentAdminAppService.UpdateApprovalStatusAsync(id, input);

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

@ -32,7 +32,7 @@
</abp-script-bundle>
}
<abp-alert id="CommentsWaitingAlert" alert-type="Warning" style="display: none;">
<abp-alert id="CommentsWaitingAlert" alert-type="Warning">
</abp-alert>
<abp-card class="mb-4">

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

@ -94,7 +94,8 @@ $(function () {
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
}
},
visible: abp.setting.getBoolean("Cms.Comments.RequireApprovement")
},
{
text: function (data) {
@ -113,7 +114,9 @@ $(function () {
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message);
})
}
},
visible: abp.setting.getBoolean("Cms.Comments.RequireApprovement")
}
]
}
@ -231,7 +234,6 @@ $(function () {
var alertMessage = l("CommentAlertMessage", count);
var alertElement = '<abp-alert alert-type="Warning">' + alertMessage + '</abp-alert>';
$('#CommentsWaitingAlert').html(alertElement);
$('#CommentsWaitingAlert').show()
$('#CommentsWaitingAlert').click(function () {
window.location.href = '/Cms/Comments/Approve'
});
@ -245,8 +247,20 @@ $(function () {
if (data.commentRequireApprovement) {
$('#CommentsTable').DataTable().column(6).visible(true);
} else {
$('#CommentsWaitingAlert').hide()
$('#CommentsTable').DataTable().column(6).visible(false);
$('#IsApprovedSelectInput').hide();
}
})
async function GetSettings() {
var result = false;
await commentsService.getSettings().then(function (data) {
result = data.commentRequireApprovement;
});
return result;
}
(async () => {
var commentRequireApprovement = await GetSettings();
console.log(commentRequireApprovement);
})();
});

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

@ -8,27 +8,24 @@ using Volo.CmsKit.Permissions;
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Shared.Components.Comments;
public class CommentSettingPageContributor : ISettingPageContributor
public class CommentSettingPageContributor : SettingPageContributorBase
{
public Task ConfigureAsync(SettingPageCreationContext context)
public CommentSettingPageContributor()
{
RequiredPermissions(CmsKitAdminPermissions.Comments.SettingManagement);
}
public override Task ConfigureAsync(SettingPageCreationContext context)
{
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<CmsKitResource>>();
context.Groups.Add(
new SettingPageGroup(
"Cms.Comments",
l["Menu:CmsKitCommentOptions"],
typeof(CommentSettingViewComponent),
order: 1
"Volo.Abp.CmsKitPro",
l["Settings:Menu:CmsKit"],
typeof(CommentSettingViewComponent)
)
);
return Task.CompletedTask;
}
public async Task<bool> CheckPermissionsAsync(SettingPageCreationContext context)
{
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
return await authorizationService.IsGrantedAsync(CmsKitAdminPermissions.Comments.SettingManagement);
}
}

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

@ -1,26 +1,26 @@
var l = abp.localization.getResource("CmsKit");
(function () {
abp.widgets.CmsCommentSetting = function ($wrapper) {
var _service = volo.cmsKit.admin.comments.commentAdmin
;
var _init = function () {
_getSettings();
_bindEvents();
};
var _getSettings = function () {
_service.getSettings().then(function (response) {
$wrapper.find('#RequireApprovementCheckbox').prop('checked', response.commentRequireApprovement);
})
};
var _service = volo.cmsKit.admin.comments.commentAdmin;
var _init = function () {
_getSettings();
_bindEvents();
};
var _getSettings = function () {
_service.getSettings().then(function (response) {
$wrapper.find('#RequireApprovementCheckbox').prop('checked', response.commentRequireApprovement);
})
};
var _bindEvents = function () {
$('#save').click(function () {
var isChecked = $('#RequireApprovementCheckbox').prop('checked');
_service.updateSettings({ commentRequireApprovement: isChecked }).then(function (response) {
abp.notify.success(l("SavedSuccessfully"));
})
});
};
var _bindEvents = function () {
$('#save').click(function () {
var isChecked = $('#RequireApprovementCheckbox').prop('checked');
_service.updateSettings({ commentRequireApprovement: isChecked }).then(function (response) {
abp.notify.success(l("SavedSuccessfully"));
})
});
};
return {
init: _init

1
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs

@ -4,6 +4,7 @@ public static class CmsKitSettings
{
public const string GroupName = "CmsKit";
public const string CommentRequireApprovement = "Cms.Comments.RequireApprovement";
// TODO : Refactor
/* Add constants for setting names. Example:
* public const string MySettingName = GroupName + ".MySettingName";

Loading…
Cancel
Save