mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
Show pending posts count in modal when your posts are enqueued
This commit is contained in:
@ -228,7 +228,7 @@ export default DiscourseController.extend({
|
|||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
|
|
||||||
if (result.responseJson.action === "enqueued") {
|
if (result.responseJson.action === "enqueued") {
|
||||||
self.send('postWasEnqueued');
|
self.send('postWasEnqueued', {pending_count: result.responseJson.pending_count });
|
||||||
self.destroyDraft();
|
self.destroyDraft();
|
||||||
self.close();
|
self.close();
|
||||||
return result;
|
return result;
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
export default Ember.Controller.extend();
|
@ -37,8 +37,8 @@ const ApplicationRoute = Discourse.Route.extend({
|
|||||||
this.controllerFor('topic-entrance').send('show', data);
|
this.controllerFor('topic-entrance').send('show', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
postWasEnqueued() {
|
postWasEnqueued(details) {
|
||||||
showModal('post-enqueued', {title: 'queue.approval.title' });
|
showModal('post-enqueued', {model: details, title: 'queue.approval.title' });
|
||||||
},
|
},
|
||||||
|
|
||||||
composePrivateMessage(user, post) {
|
composePrivateMessage(user, post) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>{{i18n "queue.approval.description"}}</p>
|
<p>{{i18n "queue.approval.description"}}</p>
|
||||||
|
|
||||||
|
<p>{{{i18n "queue.approval.pending_posts" count=model.pending_count}}}
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
{{d-button action="closeModal" class="btn-primary" label="queue.approval.ok"}}
|
{{d-button action="closeModal" class="btn-primary" label="queue.approval.ok"}}
|
||||||
|
@ -28,8 +28,12 @@ class QueuedPost < ActiveRecord::Base
|
|||||||
where(queue: visible_queues.to_a)
|
where(queue: visible_queues.to_a)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.new_posts
|
||||||
|
visible.where(state: states[:new])
|
||||||
|
end
|
||||||
|
|
||||||
def self.new_count
|
def self.new_count
|
||||||
visible.where(state: states[:new]).count
|
new_posts.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible?
|
def visible?
|
||||||
|
@ -4,7 +4,8 @@ class NewPostResultSerializer < ApplicationSerializer
|
|||||||
attributes :action,
|
attributes :action,
|
||||||
:post,
|
:post,
|
||||||
:errors,
|
:errors,
|
||||||
:success
|
:success,
|
||||||
|
:pending_count
|
||||||
|
|
||||||
def post
|
def post
|
||||||
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
||||||
@ -36,4 +37,12 @@ class NewPostResultSerializer < ApplicationSerializer
|
|||||||
object.action
|
object.action
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pending_count
|
||||||
|
object.pending_count
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_pending_count?
|
||||||
|
pending_count.present?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -240,6 +240,9 @@ en:
|
|||||||
approval:
|
approval:
|
||||||
title: "Post Needs Approval"
|
title: "Post Needs Approval"
|
||||||
description: "We've received your new post but it needs to be approved by a moderator before it will appear. Please be patient."
|
description: "We've received your new post but it needs to be approved by a moderator before it will appear. Please be patient."
|
||||||
|
pending_posts:
|
||||||
|
one: "You have <strong>1</strong> post pending."
|
||||||
|
other: "You have <strong>{{count}}</strong> posts pending."
|
||||||
ok: "OK"
|
ok: "OK"
|
||||||
|
|
||||||
user_action:
|
user_action:
|
||||||
|
@ -67,6 +67,7 @@ class NewPostManager
|
|||||||
|
|
||||||
result.queued_post = post
|
result.queued_post = post
|
||||||
result.check_errors_from(enqueuer)
|
result.check_errors_from(enqueuer)
|
||||||
|
result.pending_count = QueuedPost.new_posts.where(user_id: @user.id).count
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ class NewPostResult
|
|||||||
attr_reader :action
|
attr_reader :action
|
||||||
attr_accessor :post
|
attr_accessor :post
|
||||||
attr_accessor :queued_post
|
attr_accessor :queued_post
|
||||||
|
attr_accessor :pending_count
|
||||||
|
|
||||||
def initialize(action, success=false)
|
def initialize(action, success=false)
|
||||||
@action = action
|
@action = action
|
||||||
|
@ -109,8 +109,9 @@ describe NewPostManager do
|
|||||||
expect(enqueued.post_options['title']).to eq('this is the title of the queued post')
|
expect(enqueued.post_options['title']).to eq('this is the title of the queued post')
|
||||||
expect(result.action).to eq(:enqueued)
|
expect(result.action).to eq(:enqueued)
|
||||||
expect(result).to be_success
|
expect(result).to be_success
|
||||||
|
expect(result.pending_count).to eq(1)
|
||||||
expect(result.post).to be_blank
|
expect(result.post).to be_blank
|
||||||
expect(QueuedPost.new_count).to be(1)
|
expect(QueuedPost.new_count).to eq(1)
|
||||||
expect(@counter).to be(0)
|
expect(@counter).to be(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user