mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
Support for custom reasons for things being queued for approval
This commit is contained in:
parent
cf0c2d09d4
commit
c2f7676370
|
@ -228,7 +228,7 @@ export default DiscourseController.extend({
|
|||
}).then(function(result) {
|
||||
|
||||
if (result.responseJson.action === "enqueued") {
|
||||
self.send('postWasEnqueued', {pending_count: result.responseJson.pending_count });
|
||||
self.send('postWasEnqueued', result.responseJson);
|
||||
self.destroyDraft();
|
||||
self.close();
|
||||
return result;
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
export default Ember.Controller.extend();
|
||||
export default Ember.Controller.extend({
|
||||
description: Ember.computed('model.reason', function() {
|
||||
const reason = this.get('model.reason');
|
||||
return reason ? I18n.t('queue_reason.' + reason + '.description') : I18n.t('queue.approval.description');
|
||||
})
|
||||
});
|
||||
|
|
|
@ -38,7 +38,8 @@ const ApplicationRoute = Discourse.Route.extend({
|
|||
},
|
||||
|
||||
postWasEnqueued(details) {
|
||||
showModal('post-enqueued', {model: details, title: 'queue.approval.title' });
|
||||
const title = details.reason ? 'queue_reason.' + details.reason + '.title' : 'queue.approval.title';
|
||||
showModal('post-enqueued', {model: details, title });
|
||||
},
|
||||
|
||||
composePrivateMessage(user, post) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="modal-body">
|
||||
<p>{{i18n "queue.approval.description"}}</p>
|
||||
<p>{{{description}}}</p>
|
||||
|
||||
<p>{{{i18n "queue.approval.pending_posts" count=model.pending_count}}}
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,8 @@ class NewPostResultSerializer < ApplicationSerializer
|
|||
:post,
|
||||
:errors,
|
||||
:success,
|
||||
:pending_count
|
||||
:pending_count,
|
||||
:reason
|
||||
|
||||
def post
|
||||
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
||||
|
@ -33,6 +34,14 @@ class NewPostResultSerializer < ApplicationSerializer
|
|||
!object.errors.empty?
|
||||
end
|
||||
|
||||
def reason
|
||||
object.reason
|
||||
end
|
||||
|
||||
def include_reason?
|
||||
reason.present?
|
||||
end
|
||||
|
||||
def action
|
||||
object.action
|
||||
end
|
||||
|
|
|
@ -60,7 +60,7 @@ class NewPostManager
|
|||
end
|
||||
|
||||
# Enqueue this post in a queue
|
||||
def enqueue(queue)
|
||||
def enqueue(queue, reason=nil)
|
||||
result = NewPostResult.new(:enqueued)
|
||||
enqueuer = PostEnqueuer.new(@user, queue)
|
||||
|
||||
|
@ -73,6 +73,7 @@ class NewPostManager
|
|||
QueuedPost.broadcast_new! if post && post.errors.empty?
|
||||
|
||||
result.queued_post = post
|
||||
result.reason = reason if reason
|
||||
result.check_errors_from(enqueuer)
|
||||
result.pending_count = QueuedPost.new_posts.where(user_id: @user.id).count
|
||||
result
|
||||
|
|
|
@ -4,6 +4,8 @@ class NewPostResult
|
|||
include HasErrors
|
||||
|
||||
attr_reader :action
|
||||
|
||||
attr_accessor :reason
|
||||
attr_accessor :post
|
||||
attr_accessor :queued_post
|
||||
attr_accessor :pending_count
|
||||
|
|
Loading…
Reference in New Issue
Block a user