Browse Source
Implements send to admin approval to publish
pull/12087/head
Musa Demir
4 years ago
No known key found for this signature in database
GPG Key ID: 117DF92322553DC8
13 changed files with
137 additions and
8 deletions
-
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs
-
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs
-
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogPostAdminClientProxy.Generated.cs
-
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs
-
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml
-
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs
-
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js
-
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/index.js
-
modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/client-proxies/cms-kit-admin-proxy.js
-
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostStatus.cs
-
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json
-
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json
-
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs
|
|
|
@ -14,8 +14,12 @@ public interface IBlogPostAdminAppService |
|
|
|
UpdateBlogPostDto> |
|
|
|
{ |
|
|
|
Task PublishAsync(Guid id); |
|
|
|
|
|
|
|
|
|
|
|
Task DraftAsync(Guid id); |
|
|
|
|
|
|
|
|
|
|
|
Task<BlogPostDto> CreateAndPublishAsync(CreateBlogPostDto input); |
|
|
|
|
|
|
|
Task SendToReviewAsync(Guid id); |
|
|
|
|
|
|
|
Task<BlogPostDto> CreateAndSendToReviewAsync(CreateBlogPostDto input); |
|
|
|
} |
|
|
|
|
|
|
|
@ -139,4 +139,22 @@ public class BlogPostAdminAppService : CmsKitAppServiceBase, IBlogPostAdminAppSe |
|
|
|
blogPost.Status = BlogPostStatus.Published; |
|
|
|
return blogPost; |
|
|
|
} |
|
|
|
|
|
|
|
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)] |
|
|
|
public virtual async Task SendToReviewAsync(Guid id) |
|
|
|
{ |
|
|
|
var blogPost = await BlogPostRepository.GetAsync(id); |
|
|
|
blogPost.SetWaitingForReview(); |
|
|
|
} |
|
|
|
|
|
|
|
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)] |
|
|
|
public virtual async Task<BlogPostDto> CreateAndSendToReviewAsync(CreateBlogPostDto input) |
|
|
|
{ |
|
|
|
var blogPost = await CreateAsync(input); |
|
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
|
|
|
|
|
await SendToReviewAsync(blogPost.Id); |
|
|
|
blogPost.Status = BlogPostStatus.WaitingForReview; |
|
|
|
return blogPost; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -79,4 +79,20 @@ public partial class BlogPostAdminClientProxy : ClientProxyBase<IBlogPostAdminAp |
|
|
|
{ typeof(CreateBlogPostDto), input } |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task SendToReviewAsync(Guid id) |
|
|
|
{ |
|
|
|
await RequestAsync(nameof(SendToReviewAsync), new ClientProxyRequestTypeValue |
|
|
|
{ |
|
|
|
{ typeof(Guid), id }, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<BlogPostDto> CreateAndSendToReviewAsync(CreateBlogPostDto input) |
|
|
|
{ |
|
|
|
return await RequestAsync<BlogPostDto>(nameof(CreateAndSendToReviewAsync), new ClientProxyRequestTypeValue |
|
|
|
{ |
|
|
|
{ typeof(CreateBlogPostDto), input } |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -86,4 +86,20 @@ public class BlogPostAdminController : CmsKitAdminController, IBlogPostAdminAppS |
|
|
|
{ |
|
|
|
return BlogPostAdminAppService.CreateAndPublishAsync(input); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
[Route("sendtoreview/{id}")] |
|
|
|
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)] |
|
|
|
public virtual Task SendToReviewAsync(Guid id) |
|
|
|
{ |
|
|
|
return BlogPostAdminAppService.SendToReviewAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
[Route("createandsendtoreview")] |
|
|
|
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)] |
|
|
|
public virtual Task<BlogPostDto> CreateAndSendToReviewAsync(CreateBlogPostDto input) |
|
|
|
{ |
|
|
|
return BlogPostAdminAppService.CreateAndSendToReviewAsync(input); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -87,10 +87,13 @@ |
|
|
|
|
|
|
|
</abp-card-body> |
|
|
|
<abp-card-footer> |
|
|
|
<abp-button button-type="Primary" type="button" text="@L["Draft"].Value" id="button-blog-post-create" /> |
|
|
|
<abp-button button-type="Primary" type="button" text="@L["SaveAsDraft"].Value" id="button-blog-post-create" /> |
|
|
|
@if ((await AuthorizationService.AuthorizeAsync(CmsKitAdminPermissions.BlogPosts.Publish)).Succeeded) |
|
|
|
{ |
|
|
|
<abp-button button-type="Primary" type="button" text="@L["Publish"].Value" id="button-blog-post-publish"/> |
|
|
|
}else |
|
|
|
{ |
|
|
|
<abp-button button-type="Primary" type="button" text="@L["SendToReviewToPublish"].Value" id="button-blog-post-send-to-review"/> |
|
|
|
} |
|
|
|
</abp-card-footer> |
|
|
|
</abp-card> |
|
|
|
|
|
|
|
@ -36,6 +36,10 @@ public class CreateModel : CmsKitAdminPageModel |
|
|
|
{ |
|
|
|
createResult = await BlogPostAdminAppService.CreateAndPublishAsync(dto); |
|
|
|
} |
|
|
|
else if (ViewModel.Status == BlogPostStatus.WaitingForReview) |
|
|
|
{ |
|
|
|
createResult = await BlogPostAdminAppService.CreateAndSendToReviewAsync(dto); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
createResult = await BlogPostAdminAppService.CreateAsync(dto); |
|
|
|
|
|
|
|
@ -4,7 +4,8 @@ $(function () { |
|
|
|
|
|
|
|
var blogPostStatus = { |
|
|
|
Draft: 0, |
|
|
|
Published: 1 |
|
|
|
Published: 1, |
|
|
|
SendToReview: 2 |
|
|
|
}; |
|
|
|
|
|
|
|
var $selectBlog = $('#BlogSelectionSelect'); |
|
|
|
@ -16,6 +17,7 @@ $(function () { |
|
|
|
var $status = $('#ViewModel_Status'); |
|
|
|
var $buttonSubmit = $('#button-blog-post-create'); |
|
|
|
var $buttonPublish = $('#button-blog-post-publish'); |
|
|
|
var $buttonSendToReview = $('#button-blog-post-send-to-review'); |
|
|
|
var $pageContentInput = $('#ViewModel_Content'); |
|
|
|
var $tagsInput = $('.tag-editor-form input[name=tags]'); |
|
|
|
var $fileInput = $('#BlogPostCoverImage'); |
|
|
|
@ -83,6 +85,19 @@ $(function () { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
$buttonSendToReview.click(function (e) { |
|
|
|
abp.message.confirm( |
|
|
|
l('BlogPostSendToReviewConfirmationMessage', $title.val()), |
|
|
|
function (isConfirmed) { |
|
|
|
if (isConfirmed) { |
|
|
|
e.preventDefault(); |
|
|
|
$status.val(blogPostStatus.SendToReview); |
|
|
|
submitCoverImage(); |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
function submitEntityTags(blogPostId) { |
|
|
|
|
|
|
|
var tags = $tagsInput.val().split(',').map(x => x.trim()).filter(x => x); |
|
|
|
|
|
|
|
@ -3,7 +3,8 @@ $(function () { |
|
|
|
var l = abp.localization.getResource("CmsKit"); |
|
|
|
var blogPostStatus = { |
|
|
|
Draft: 0, |
|
|
|
Published: 1 |
|
|
|
Published: 1, |
|
|
|
SendToReview: 2 |
|
|
|
}; |
|
|
|
|
|
|
|
var blogsService = volo.cmsKit.admin.blogs.blogPostAdmin; |
|
|
|
@ -54,6 +55,24 @@ $(function () { |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: l('SendToReview'), |
|
|
|
visible: function(data) { |
|
|
|
return data?.status === blogPostStatus.Draft && |
|
|
|
!abp.auth.isGranted('CmsKit.BlogPosts.Publish'); |
|
|
|
}, |
|
|
|
confirmMessage: function (data) { |
|
|
|
return l("BlogPostPublishConfirmationMessage", data.record.title) |
|
|
|
}, |
|
|
|
action: function (data) { |
|
|
|
blogsService |
|
|
|
.sendToReview(data.record.id) |
|
|
|
.then(function () { |
|
|
|
dataTable.ajax.reload(); |
|
|
|
abp.notify.success(l('BlogPostSendToReviewSuccessMessage', data.record.title)); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: l('Draft'), |
|
|
|
visible: function(data) { |
|
|
|
|
|
|
|
@ -415,6 +415,22 @@ |
|
|
|
}, ajaxParams)); |
|
|
|
}; |
|
|
|
|
|
|
|
volo.cmsKit.admin.blogs.blogPostAdmin.sendToReview = function(id, ajaxParams) { |
|
|
|
return abp.ajax($.extend(true, { |
|
|
|
url: abp.appPath + 'api/cms-kit-admin/blogs/blog-posts/sendtoreview/' + id + '', |
|
|
|
type: 'POST', |
|
|
|
dataType: null |
|
|
|
}, ajaxParams)); |
|
|
|
}; |
|
|
|
|
|
|
|
volo.cmsKit.admin.blogs.blogPostAdmin.createAndSendToReview = function(input, ajaxParams) { |
|
|
|
return abp.ajax($.extend(true, { |
|
|
|
url: abp.appPath + 'api/cms-kit-admin/blogs/blog-posts/createandsendtoreview', |
|
|
|
type: 'POST', |
|
|
|
data: JSON.stringify(input) |
|
|
|
}, ajaxParams)); |
|
|
|
}; |
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
@ -3,5 +3,6 @@ |
|
|
|
public enum BlogPostStatus |
|
|
|
{ |
|
|
|
Draft, |
|
|
|
Published |
|
|
|
Published, |
|
|
|
WaitingForReview |
|
|
|
} |
|
|
|
@ -168,10 +168,16 @@ |
|
|
|
"SavedSuccessfully": "Saved successfully", |
|
|
|
"CmsKit.BlogPost.Status.0": "Draft", |
|
|
|
"CmsKit.BlogPost.Status.1": "Published", |
|
|
|
"CmsKit.BlogPost.Status.2": "Waiting for review", |
|
|
|
"BlogPostPublishConfirmationMessage": "Are you sure to publish the blog post \"{0}\"?", |
|
|
|
"SuccessfullyPublished": "Successfully published!", |
|
|
|
"Draft": "Draft", |
|
|
|
"Publish": "Publish", |
|
|
|
"BlogPostDraftConfirmationMessage": "Are you sure to set the blog post \"{0}\" as draft?" |
|
|
|
"BlogPostDraftConfirmationMessage": "Are you sure to set the blog post \"{0}\" as draft?", |
|
|
|
"BlogPostSendToReviewConfirmationMessage": "Are you sure to send the blog post \"{0}\" to admin review for publishing?", |
|
|
|
"SaveAsDraft": "Save as draft", |
|
|
|
"SendToReview": "Send to review", |
|
|
|
"SendToReviewToPublish": "Send to review to publish", |
|
|
|
"BlogPostSendToReviewSuccessMessage": "The blog post \"{0}\" has been sent to admin review for publishing." |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -167,10 +167,16 @@ |
|
|
|
"SavedSuccessfully": "Başarıyla kaydedildi", |
|
|
|
"CmsKit.BlogPost.Status.0": "Taslak", |
|
|
|
"CmsKit.BlogPost.Status.1": "Yayınlandı", |
|
|
|
"CmsKit.BlogPost.Status.2": "İnceleme Bekliyor", |
|
|
|
"BlogPostPublishConfirmationMessage": "\"{0}\" başlıklı gönderiyi yayınlamak istediğinize emin misiniz?", |
|
|
|
"SuccessfullyPublished": "Başarıyla yayınlandı", |
|
|
|
"Draft": "Taslak olarak kaydet", |
|
|
|
"Publish": "Yayınla", |
|
|
|
"BlogPostDraftConfirmationMessage": "\"{0}\" başlıklı gönderiyi taslak haline getirmek istediğinize emin misiniz?" |
|
|
|
"BlogPostDraftConfirmationMessage": "\"{0}\" başlıklı gönderiyi taslak haline getirmek istediğinize emin misiniz?", |
|
|
|
"BlogPostSendToReviewConfirmationMessage": "\"{0}\" başlıklı gönderiyi yayınlamak için admin incelemesine göndermek istediğinize emin misiniz?", |
|
|
|
"SaveAsDraft": "Taslak olarak kaydet", |
|
|
|
"SendToReview": "İncelemeye gönder", |
|
|
|
"SendToReviewToPublish": "Yayınlamak için admin incelemesine gönder", |
|
|
|
"BlogPostSendToReviewSuccessMessage": "\"{0}\" başlıklı gönderiyi yayınlamak için admin incelemesine gönderildi." |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -91,4 +91,9 @@ public class BlogPost : FullAuditedAggregateRoot<Guid>, IMultiTenant |
|
|
|
{ |
|
|
|
Status = BlogPostStatus.Published; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual void SetWaitingForReview() |
|
|
|
{ |
|
|
|
Status = BlogPostStatus.WaitingForReview; |
|
|
|
} |
|
|
|
} |
|
|
|
|