mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
Show pending posts count in modal when your posts are enqueued
This commit is contained in:
parent
3660fe4f60
commit
15dbce5886
10 changed files with 28 additions and 6 deletions
|
@ -228,7 +228,7 @@ export default DiscourseController.extend({
|
|||
}).then(function(result) {
|
||||
|
||||
if (result.responseJson.action === "enqueued") {
|
||||
self.send('postWasEnqueued');
|
||||
self.send('postWasEnqueued', {pending_count: result.responseJson.pending_count });
|
||||
self.destroyDraft();
|
||||
self.close();
|
||||
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);
|
||||
},
|
||||
|
||||
postWasEnqueued() {
|
||||
showModal('post-enqueued', {title: 'queue.approval.title' });
|
||||
postWasEnqueued(details) {
|
||||
showModal('post-enqueued', {model: details, title: 'queue.approval.title' });
|
||||
},
|
||||
|
||||
composePrivateMessage(user, post) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<div class="modal-body">
|
||||
<p>{{i18n "queue.approval.description"}}</p>
|
||||
|
||||
<p>{{{i18n "queue.approval.pending_posts" count=model.pending_count}}}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{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)
|
||||
end
|
||||
|
||||
def self.new_posts
|
||||
visible.where(state: states[:new])
|
||||
end
|
||||
|
||||
def self.new_count
|
||||
visible.where(state: states[:new]).count
|
||||
new_posts.count
|
||||
end
|
||||
|
||||
def visible?
|
||||
|
|
|
@ -4,7 +4,8 @@ class NewPostResultSerializer < ApplicationSerializer
|
|||
attributes :action,
|
||||
:post,
|
||||
:errors,
|
||||
:success
|
||||
:success,
|
||||
:pending_count
|
||||
|
||||
def post
|
||||
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
||||
|
@ -36,4 +37,12 @@ class NewPostResultSerializer < ApplicationSerializer
|
|||
object.action
|
||||
end
|
||||
|
||||
def pending_count
|
||||
object.pending_count
|
||||
end
|
||||
|
||||
def include_pending_count?
|
||||
pending_count.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -240,6 +240,9 @@ en:
|
|||
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."
|
||||
pending_posts:
|
||||
one: "You have <strong>1</strong> post pending."
|
||||
other: "You have <strong>{{count}}</strong> posts pending."
|
||||
ok: "OK"
|
||||
|
||||
user_action:
|
||||
|
|
|
@ -67,6 +67,7 @@ class NewPostManager
|
|||
|
||||
result.queued_post = post
|
||||
result.check_errors_from(enqueuer)
|
||||
result.pending_count = QueuedPost.new_posts.where(user_id: @user.id).count
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class NewPostResult
|
|||
attr_reader :action
|
||||
attr_accessor :post
|
||||
attr_accessor :queued_post
|
||||
attr_accessor :pending_count
|
||||
|
||||
def initialize(action, success=false)
|
||||
@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(result.action).to eq(:enqueued)
|
||||
expect(result).to be_success
|
||||
expect(result.pending_count).to eq(1)
|
||||
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)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue