Browse Source

code review was done

pull/19919/head
Emre 2 years ago
parent
commit
8fbdfe58d9
  1. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs
  2. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs
  3. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/Volo/CmsKit/Admin/Comments/CommentAdminClientProxy.Generated.cs
  4. 8
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/cms-kit-admin-generate-proxy.json
  5. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs
  6. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/index.js
  7. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml
  8. 8
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml
  9. 14
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/details.js
  10. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.css
  11. 32
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js
  12. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingPageContributor.cs
  13. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingScriptBundleContributor.cs
  14. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingViewComponent.cs
  15. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/default.cshtml
  16. 7
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/default.js
  17. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/client-proxies/cms-kit-admin-proxy.js
  18. 6
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Settings/AppSettings.cs
  19. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs
  20. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettingDefinitionProvider.cs
  21. 1
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs
  22. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs
  23. 4
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs
  24. 8
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs
  25. 1
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/Volo.CmsKit.EntityFrameworkCore.Tests.csproj

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

@ -15,7 +15,7 @@ public interface ICommentAdminAppService : IApplicationService
Task UpdateApprovalStatusAsync(Guid id, CommentApprovalDto input); Task UpdateApprovalStatusAsync(Guid id, CommentApprovalDto input);
Task SetSettingsAsync(CommentSettingsDto input); Task UpdateSettingsAsync(CommentSettingsDto input);
Task<CommentSettingsDto> GetSettingsAsync(); Task<CommentSettingsDto> GetSettingsAsync();

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

@ -95,15 +95,15 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp
} }
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] [Authorize(CmsKitAdminPermissions.Comments.SettingManagement)]
public async Task SetSettingsAsync(CommentSettingsDto input) public async Task UpdateSettingsAsync(CommentSettingsDto input)
{ {
await SettingManager.SetGlobalAsync(AppSettings.CommentRequireApprovement, input.CommentRequireApprovement.ToString()); await SettingManager.SetGlobalAsync(CmsKitSettings.CommentRequireApprovement, input.CommentRequireApprovement.ToString());
} }
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] [Authorize(CmsKitAdminPermissions.Comments.SettingManagement)]
public async Task<CommentSettingsDto> GetSettingsAsync() public async Task<CommentSettingsDto> GetSettingsAsync()
{ {
var isRequireApprovementEnabled = bool.Parse(await SettingManager.GetOrNullGlobalAsync(AppSettings.CommentRequireApprovement)); var isRequireApprovementEnabled = bool.Parse(await SettingManager.GetOrNullGlobalAsync(CmsKitSettings.CommentRequireApprovement));
return new CommentSettingsDto {CommentRequireApprovement = isRequireApprovementEnabled}; return new CommentSettingsDto {CommentRequireApprovement = isRequireApprovementEnabled};
} }

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

@ -50,9 +50,9 @@ public partial class CommentAdminClientProxy : ClientProxyBase<ICommentAdminAppS
}); });
} }
public virtual async Task SetSettingsAsync(CommentSettingsDto input) public virtual async Task UpdateSettingsAsync(CommentSettingsDto input)
{ {
await RequestAsync(nameof(SetSettingsAsync), new ClientProxyRequestTypeValue await RequestAsync(nameof(UpdateSettingsAsync), new ClientProxyRequestTypeValue
{ {
{ typeof(CommentSettingsDto), input } { typeof(CommentSettingsDto), input }
}); });

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

@ -1294,7 +1294,7 @@
} }
}, },
{ {
"name": "SetSettingsAsync", "name": "UpdateSettingsAsync",
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "input", "name": "input",
@ -1606,9 +1606,9 @@
"allowAnonymous": false, "allowAnonymous": false,
"implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService" "implementFrom": "Volo.CmsKit.Admin.Comments.ICommentAdminAppService"
}, },
"SetSettingsAsyncByInput": { "UpdateSettingsAsyncByInput": {
"uniqueName": "SetSettingsAsyncByInput", "uniqueName": "UpdateSettingsAsyncByInput",
"name": "SetSettingsAsync", "name": "UpdateSettingsAsync",
"httpMethod": "POST", "httpMethod": "POST",
"url": "api/cms-kit-admin/comments/settings", "url": "api/cms-kit-admin/comments/settings",
"supportedVersions": [], "supportedVersions": [],

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

@ -59,9 +59,9 @@ public class CommentAdminController : CmsKitAdminController, ICommentAdminAppSer
[HttpPost] [HttpPost]
[Route("settings")] [Route("settings")]
[Authorize(CmsKitAdminPermissions.Comments.SettingManagement)] [Authorize(CmsKitAdminPermissions.Comments.SettingManagement)]
public Task SetSettingsAsync(CommentSettingsDto input) public Task UpdateSettingsAsync(CommentSettingsDto input)
{ {
return CommentAdminAppService.SetSettingsAsync(input); return CommentAdminAppService.UpdateSettingsAsync(input);
} }
[HttpGet] [HttpGet]

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

@ -71,9 +71,6 @@
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { // TODO: Is it necessary in ABP Framework?
abp.notify.error(error.message);
});
} }
}, },
{ {
@ -90,9 +87,6 @@
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { // TODO: Is it necessary in ABP Framework?
abp.notify.error(error.message);
});
} }
} }
] ]

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

@ -95,9 +95,9 @@
<abp-input asp-for="@Model.Author" label="@L["Username"].Value" type="text"/> <abp-input asp-for="@Model.Author" label="@L["Username"].Value" type="text"/>
</abp-column> </abp-column>
<abp-column size-lg="_2" size-md="_12"> <abp-column size-lg="_2" size-md="_12">
<div class="mb-3" id="isApprovedColumn"> // TODO: Use standard id naming convention. For example: IsApprovedSelectInput <div class="mb-3" id="IsApprovedSelectInput">
<label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label> <label class="mb-1" for="IsApprovedSelect">@L["CommentFilter:ApproveState"].Value</label>
<select id="isApprovedSelect" asp-for="@Model.CommentApproveState" class="form-control"> <select id="IsApprovedSelect" asp-for="@Model.CommentApproveState" class="form-control">
<option value="@CommentApproveState.All">@L["CommentFilter:All"].Value</option> <option value="@CommentApproveState.All">@L["CommentFilter:All"].Value</option>
<option value="@CommentApproveState.Approved">@L["CommentFilter:Approved"].Value</option> <option value="@CommentApproveState.Approved">@L["CommentFilter:Approved"].Value</option>
<option value="@CommentApproveState.Disapproved">@L["CommentFilter:Disapproved"].Value</option> <option value="@CommentApproveState.Disapproved">@L["CommentFilter:Disapproved"].Value</option>

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

@ -32,7 +32,7 @@
</abp-script-bundle> </abp-script-bundle>
} }
<abp-alert id="commentsAlert" alert-type="Warning" style="display: none;"> // TODO: Use standard id naming convention. For example: IsApprovedSelectInput <abp-alert id="CommentsWaitingAlert" alert-type="Warning" style="display: none;">
</abp-alert> </abp-alert>
<abp-card class="mb-4"> <abp-card class="mb-4">
@ -60,9 +60,9 @@
</abp-column> </abp-column>
<abp-column size-lg="_2" size-md="_6"> <abp-column size-lg="_2" size-md="_6">
<div class="mb-3" id="isApprovedColumn"> <div class="mb-3" id="IsApprovedSelectInput">
<label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label> <label class="mb-1" for="IsApprovedSelect">@L["CommentFilter:ApproveState"].Value</label>
<select id="isApprovedSelect" asp-for="@Model.CommentApproveState" class="form-control"> <select id="IsApprovedSelect" asp-for="@Model.CommentApproveState" class="form-control">
<option value="@CommentApproveState.All">@L["CommentFilter:All"].Value</option> <option value="@CommentApproveState.All">@L["CommentFilter:All"].Value</option>
<option value="@CommentApproveState.Approved">@L["CommentFilter:Approved"].Value</option> <option value="@CommentApproveState.Approved">@L["CommentFilter:Approved"].Value</option>
<option value="@CommentApproveState.Disapproved">@L["CommentFilter:Disapproved"].Value</option> <option value="@CommentApproveState.Disapproved">@L["CommentFilter:Disapproved"].Value</option>

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

@ -93,9 +93,6 @@ $(function (){
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { // TODO: Is it necessary in ABP Framework?
abp.notify.error(error.message);
});
} }
}, },
{ {
@ -114,9 +111,6 @@ $(function (){
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { // TODO: Is it necessary in ABP Framework?
abp.notify.error(error.message);
});
} }
} }
] ]
@ -173,12 +167,12 @@ $(function (){
var icons = '' var icons = ''
if (data === null) { if (data === null) {
icons = '<i class="fa-solid fa-hourglass-start"></i>'; icons = '<i class="fa-solid fa-hourglass-half text-muted"></i>';
} else if (typeof data === "boolean") { } else if (typeof data === "boolean") {
if (data) { if (data) {
icons = '<i class="fa-solid fa-check" style="color: #63E6BE;"></i>'; icons = '<i class="fa-solid fa-check text-success"></i>';
} else { } else {
icons = '<i class="fa-solid fa-x" style="color: #e0102f;"></i>'; icons = '<i class="fa-solid fa-x text-danger"></i>';
} }
} }
@ -205,7 +199,7 @@ $(function (){
$('#CommentsTable').DataTable().column(4).visible(true); $('#CommentsTable').DataTable().column(4).visible(true);
} else { } else {
$('#CommentsTable').DataTable().column(4).visible(false); $('#CommentsTable').DataTable().column(4).visible(false);
$('#isApprovedColumn').hide(); $('#IsApprovedSelectInput').hide();
} }
}) })
filterForm.submit(function (e){ filterForm.submit(function (e){

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.css

@ -1,3 +1,3 @@
.datatableCell{ .datatableCell{
cursor: pointer; cursor: pointer;
} }

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

@ -74,7 +74,7 @@ $(function () {
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reloadEx(); _dataTable.ajax.reloadEx();
checkWaitingComments() CheckWaitingComments()
abp.notify.success(l('DeletedSuccessfully')); abp.notify.success(l('DeletedSuccessfully'));
}); });
} }
@ -90,13 +90,10 @@ $(function () {
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus }) .updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () { .then(function () {
_dataTable.ajax.reloadEx(); _dataTable.ajax.reloadEx();
checkWaitingComments() CheckWaitingComments()
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { // TODO: Is it necessary in ABP Framework?
abp.notify.error(error.message);
});
} }
}, },
{ {
@ -112,13 +109,10 @@ $(function () {
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus }) .updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus })
.then(function () { .then(function () {
_dataTable.ajax.reloadEx(); _dataTable.ajax.reloadEx();
checkWaitingComments() CheckWaitingComments()
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully');
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { // TODO: Is it necessary in ABP Framework?
abp.notify.error(error.message);
});
} }
} }
] ]
@ -198,12 +192,12 @@ $(function () {
var icons = '' var icons = ''
if (data === null) { if (data === null) {
icons = '<i class="fa-solid fa-hourglass-start"></i>'; icons = '<i class="fa-solid fa-hourglass-half text-muted"></i>';
} else if (typeof data === "boolean") { } else if (typeof data === "boolean") {
if (data) { if (data) {
icons = '<i class="fa-solid fa-check" style="color: #63E6BE;"></i>'; icons = '<i class="fa-solid fa-check text-success"></i>';
} else { } else {
icons = '<i class="fa-solid fa-x" style="color: #e0102f;"></i>'; icons = '<i class="fa-solid fa-x text-danger"></i>';
} }
} }
@ -231,28 +225,28 @@ $(function () {
_dataTable.ajax.reloadEx(); _dataTable.ajax.reloadEx();
}); });
function checkWaitingComments() { // TODO: Rename this function. CheckWaitingComments is not a good name for this function. function CheckWaitingComments() {
commentsService.getWaitingCount().then(function (count) { commentsService.getWaitingCount().then(function (count) {
if (count > 0) { if (count > 0) {
var alertMessage = l("CommentAlertMessage", count); var alertMessage = l("CommentAlertMessage", count);
var alertElement = '<abp-alert alert-type="Warning">' + alertMessage + '</abp-alert>'; var alertElement = '<abp-alert alert-type="Warning">' + alertMessage + '</abp-alert>';
$('#commentsAlert').html(alertElement); $('#CommentsWaitingAlert').html(alertElement);
$('#commentsAlert').show() $('#CommentsWaitingAlert').show()
$('#commentsAlert').click(function () { $('#CommentsWaitingAlert').click(function () {
window.location.href = '/Cms/Comments/Approve' window.location.href = '/Cms/Comments/Approve'
}); });
} else { } else {
$('#commentsAlert').hide() $('#CommentsWaitingAlert').hide()
} }
}); });
} }
checkWaitingComments() CheckWaitingComments()
commentsService.getSettings().then(function (data) { commentsService.getSettings().then(function (data) {
if (data.commentRequireApprovement) { if (data.commentRequireApprovement) {
$('#CommentsTable').DataTable().column(6).visible(true); $('#CommentsTable').DataTable().column(6).visible(true);
} else { } else {
$('#CommentsTable').DataTable().column(6).visible(false); $('#CommentsTable').DataTable().column(6).visible(false);
$('#isApprovedColumn').hide(); $('#IsApprovedSelectInput').hide();
} }
}) })
}); });

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

@ -15,7 +15,7 @@ public class CommentSettingPageContributor : ISettingPageContributor
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<CmsKitResource>>(); var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<CmsKitResource>>();
context.Groups.Add( context.Groups.Add(
new SettingPageGroup( new SettingPageGroup(
"Volo.Abp.MySettingGroup", "Cms.Comments",
l["Menu:CmsKitCommentOptions"], l["Menu:CmsKitCommentOptions"],
typeof(CommentSettingViewComponent), typeof(CommentSettingViewComponent),
order: 1 order: 1

4
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) public override void ConfigureBundle(BundleConfigurationContext context)
{ {
context.Files.AddIfNotContains("/client-proxies/cms-kit-admin-proxy.js"); // TODO: is it necessary? context.Files.AddIfNotContains("/client-proxies/cms-kit-admin-proxy.js");
context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Comments/index.js"); context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Comments/default.js");
} }
} }

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

@ -13,6 +13,6 @@ public class CommentSettingViewComponent : AbpViewComponent
{ {
public virtual IViewComponentResult Invoke() public virtual IViewComponentResult Invoke()
{ {
return View("~/Pages/CmsKit/Shared/Components/Comments/Index.cshtml"); return View("~/Pages/CmsKit/Shared/Components/Comments/default.cshtml");
} }
} }

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

@ -3,9 +3,7 @@
@section scripts { @section scripts {
<abp-script-bundle> <abp-script-bundle>
<abp-script src="/client-proxies/cms-kit-admin-proxy.js" /> // TODO: Remove this line and then check <abp-script src="/Pages/CmsKit/Shared/Components/Comments/default.js"></abp-script>
<abp-script src="/client-proxies/cms-kit-common-proxy.js" /> // TODO: Remove this line and then check
<abp-script src="/Pages/CmsKit/Shared/Components/Comments/index.js"></abp-script>
</abp-script-bundle> </abp-script-bundle>
} }
@{ @{
@ -16,7 +14,7 @@
<hr /> <hr />
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input type="checkbox" id="checkbox" class="form-check-input" name="checkbox" /> <input type="checkbox" id="RequireApprovementCheckbox" class="form-check-input"/>
<label for="checkbox" class="form-check-label">@L["CmsKitCommentOptions:RequireApprovement"].Value</label> <label for="checkbox" class="form-check-label">@L["CmsKitCommentOptions:RequireApprovement"].Value</label>
</div> </div>
<small id="checkboxHelp" class="form-text text-muted">@L["CmsKitCommentOptions:RequireApprovementDescription"].Value</small> <small id="checkboxHelp" class="form-text text-muted">@L["CmsKitCommentOptions:RequireApprovementDescription"].Value</small>

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

@ -9,15 +9,14 @@
}; };
var _getSettings = function () { var _getSettings = function () {
_service.getSettings().then(function (response) { _service.getSettings().then(function (response) {
// TODO: Rename checkbox id to something more meaningful. $wrapper.find('#RequireApprovementCheckbox').prop('checked', response.commentRequireApprovement);
$('#checkbox').prop('checked', response.commentRequireApprovement); // TODO: use $wrapper.find('#checkbox').prop('checked', response.commentRequireApprovement);
}) })
}; };
var _bindEvents = function () { var _bindEvents = function () {
$('#save').click(function () { $('#save').click(function () {
var isChecked = $('#checkbox').prop('checked'); var isChecked = $('#RequireApprovementCheckbox').prop('checked');
_service.setSettings({ commentRequireApprovement: isChecked }).then(function (response) { _service.updateSettings({ commentRequireApprovement: isChecked }).then(function (response) {
abp.notify.success(l("SavedSuccessfully")); abp.notify.success(l("SavedSuccessfully"));
}) })
}); });

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

@ -205,7 +205,7 @@
}, ajaxParams)); }, ajaxParams));
}; };
volo.cmsKit.admin.comments.commentAdmin.setSettings = function(input, ajaxParams) { volo.cmsKit.admin.comments.commentAdmin.updateSettings = function(input, ajaxParams) {
return abp.ajax($.extend(true, { return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/settings', url: abp.appPath + 'api/cms-kit-admin/comments/settings',
type: 'POST', type: 'POST',

6
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Settings/AppSettings.cs

@ -1,6 +0,0 @@
namespace Volo.CmsKit.Settings;
public static class AppSettings
{
public const string CommentRequireApprovement = "Comments.RequireApprovement";
}

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

@ -29,7 +29,7 @@ public class Comment : AggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator,
public virtual bool? IsApproved { get; set; } public virtual bool? IsApproved { get; set; }
protected Comment() protected Comment()
{ {
} }

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettingDefinitionProvider.cs

@ -7,7 +7,7 @@ public class CmsKitSettingDefinitionProvider : SettingDefinitionProvider
public override void Define(ISettingDefinitionContext context) public override void Define(ISettingDefinitionContext context)
{ {
context.Add( context.Add(
new SettingDefinition(AppSettings.CommentRequireApprovement, "true") // TODO: Check the default value new SettingDefinition(CmsKitSettings.CommentRequireApprovement, "false")
); );
} }
} }

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

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

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

@ -57,7 +57,7 @@ public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPubli
public virtual async Task<ListResultDto<CommentWithDetailsDto>> GetListAsync(string entityType, string entityId) public virtual async Task<ListResultDto<CommentWithDetailsDto>> GetListAsync(string entityType, string entityId)
{ {
var isRequireApprovementEnabled = bool.Parse(await SettingManager.GetOrNullGlobalAsync(AppSettings.CommentRequireApprovement)); var isRequireApprovementEnabled = bool.Parse(await SettingManager.GetOrNullGlobalAsync(CmsKitSettings.CommentRequireApprovement));
var commentsWithAuthor = isRequireApprovementEnabled var commentsWithAuthor = isRequireApprovementEnabled
? await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, CommentApproveState.Approved) ? await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, CommentApproveState.Approved)

4
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs

@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Shouldly; using Shouldly;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.SettingManagement;
using Volo.CmsKit.Admin.Comments; using Volo.CmsKit.Admin.Comments;
using Xunit; using Xunit;
@ -11,11 +12,12 @@ public class CommentAdminAppService_Tests : CmsKitApplicationTestBase
{ {
private readonly ICommentAdminAppService _commentAdminAppService; private readonly ICommentAdminAppService _commentAdminAppService;
private readonly CmsKitTestData _cmsKitTestData; private readonly CmsKitTestData _cmsKitTestData;
private readonly ISettingManager _settingManager;
public CommentAdminAppService_Tests() public CommentAdminAppService_Tests()
{ {
_commentAdminAppService = GetRequiredService<ICommentAdminAppService>(); _commentAdminAppService = GetRequiredService<ICommentAdminAppService>();
_cmsKitTestData = GetRequiredService<CmsKitTestData>(); _cmsKitTestData = GetRequiredService<CmsKitTestData>();
_settingManager = GetRequiredService<ISettingManager>();
} }
[Fact] [Fact]

8
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs

@ -5,13 +5,15 @@ using Microsoft.EntityFrameworkCore.Storage;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
namespace Volo.CmsKit.EntityFrameworkCore; namespace Volo.CmsKit.EntityFrameworkCore;
[DependsOn( [DependsOn(
typeof(CmsKitTestBaseModule), typeof(CmsKitTestBaseModule),
typeof(CmsKitEntityFrameworkCoreModule), typeof(CmsKitEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule) typeof(AbpEntityFrameworkCoreSqliteModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule)
)] )]
public class CmsKitEntityFrameworkCoreTestModule : AbpModule public class CmsKitEntityFrameworkCoreTestModule : AbpModule
{ {
@ -37,6 +39,10 @@ public class CmsKitEntityFrameworkCoreTestModule : AbpModule
new DbContextOptionsBuilder<CmsKitDbContext>().UseSqlite(connection).Options new DbContextOptionsBuilder<CmsKitDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables(); ).GetService<IRelationalDatabaseCreator>().CreateTables();
new SettingManagementDbContext(
new DbContextOptionsBuilder<SettingManagementDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();
return connection; return connection;
} }
} }

1
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/Volo.CmsKit.EntityFrameworkCore.Tests.csproj

@ -10,6 +10,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" />
<ProjectReference Include="..\..\src\Volo.CmsKit.EntityFrameworkCore\Volo.CmsKit.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\src\Volo.CmsKit.EntityFrameworkCore\Volo.CmsKit.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\Volo.CmsKit.TestBase\Volo.CmsKit.TestBase.csproj" /> <ProjectReference Include="..\Volo.CmsKit.TestBase\Volo.CmsKit.TestBase.csproj" />
<ProjectReference Include="..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore/Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj" />
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save