- {{#each post in model}}
+ {{#each ctrl in model itemController='queued-post'}}
- {{avatar post.user imageSize="large"}}
+ {{avatar ctrl.post.user imageSize="large"}}
- {{post.user.username}}
+ {{ctrl.post.user.username}}
{{i18n "queue.topic"}}
- {{#if post.topic}}
- {{topic-link post.topic}}
+ {{#if ctrl.post.topic}}
+ {{topic-link ctrl.post.topic}}
{{else}}
- {{post.post_options.title}}
+ {{ctrl.post.post_options.title}}
{{/if}}
- {{category-badge post.category}}
+ {{category-badge ctrl.post.category}}
- {{{cook-text post.raw}}}
+
+ {{#if ctrl.editing}}
+ {{pagedown-editor value=ctrl.buffered.raw}}
+ {{else}}
+ {{{cook-text ctrl.post.raw}}}
+ {{/if}}
+
- {{d-button action="approve"
- actionParam=post
- disabled=post.isSaving
- label="queue.approve"
- icon="check"
- class="btn-primary approve"}}
- {{d-button action="reject"
- actionParam=post
- disabled=post.isSaving
- label="queue.reject"
- icon="times"
- class="btn-warning reject"}}
+ {{#if ctrl.editing}}
+ {{d-button action="confirmEdit"
+ label="queue.confirm"
+ disabled=ctrl.post.isSaving
+ class="btn-primary confirm"}}
+ {{d-button action="cancelEdit"
+ label="queue.cancel"
+ icon="times"
+ disabled=ctrl.post.isSaving
+ class="btn-danger cancel"}}
+
+ {{else}}
+ {{d-button action="approve"
+ disabled=ctrl.post.isSaving
+ label="queue.approve"
+ icon="check"
+ class="btn-primary approve"}}
+ {{d-button action="reject"
+ disabled=ctrl.post.isSaving
+ label="queue.reject"
+ icon="times"
+ class="btn-danger reject"}}
+ {{d-button action="edit"
+ disabled=ctrl.post.isSaving
+ label="queue.edit"
+ icon="pencil"
+ class="edit"}}
+ {{/if}}
diff --git a/app/assets/stylesheets/desktop/queued-posts.scss b/app/assets/stylesheets/desktop/queued-posts.scss
index 19f1bc0737..dc3bb1fda7 100644
--- a/app/assets/stylesheets/desktop/queued-posts.scss
+++ b/app/assets/stylesheets/desktop/queued-posts.scss
@@ -9,8 +9,19 @@
.cooked {
width: $topic-body-width;
float: left;
+
+ #wmd-input {
+ width: 98%;
+ height: 15em;
+ }
}
+ .queue-controls {
+ button {
+ float: left;
+ margin-right: 0.5em;
+ }
+ }
.post-title {
color: darken(scale-color-diff(), 50%);
font-weight: bold;
diff --git a/app/controllers/queued_posts_controller.rb b/app/controllers/queued_posts_controller.rb
index 8ee84538eb..ad4c0c5d05 100644
--- a/app/controllers/queued_posts_controller.rb
+++ b/app/controllers/queued_posts_controller.rb
@@ -15,6 +15,10 @@ class QueuedPostsController < ApplicationController
def update
qp = QueuedPost.where(id: params[:id]).first
+ if params[:queued_post][:raw].present?
+ qp.update_column(:raw, params[:queued_post][:raw])
+ end
+
state = params[:queued_post][:state]
if state == 'approved'
qp.approve!(current_user)
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f6a1d4e878..8bcf0d01c5 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -227,10 +227,13 @@ en:
queue:
topic: "Topic:"
- approve: 'Approve Post'
- reject: 'Reject Post'
+ approve: 'Approve'
+ reject: 'Reject'
title: "Needs Approval"
none: "There are no posts to review."
+ edit: "Edit"
+ cancel: "Cancel"
+ confirm: "Save Changes"
approval:
title: "Post Needs Approval"
diff --git a/test/javascripts/acceptance/queued-posts-test.js.es6 b/test/javascripts/acceptance/queued-posts-test.js.es6
index 33b301790f..de358c92a2 100644
--- a/test/javascripts/acceptance/queued-posts-test.js.es6
+++ b/test/javascripts/acceptance/queued-posts-test.js.es6
@@ -5,10 +5,6 @@ acceptance("Queued Posts", { loggedIn: true });
test("approve a post", () => {
visit("/queued-posts");
- andThen(() => {
- ok(exists('.queued-post'), 'it has posts listed');
- });
-
click('.queued-post:eq(0) button.approve');
andThen(() => {
ok(!exists('.queued-post'), 'it removes the post');
@@ -18,12 +14,40 @@ test("approve a post", () => {
test("reject a post", () => {
visit("/queued-posts");
- andThen(() => {
- ok(exists('.queued-post'), 'it has posts listed');
- });
-
click('.queued-post:eq(0) button.reject');
andThen(() => {
ok(!exists('.queued-post'), 'it removes the post');
});
});
+
+test("edit a post - cancel", () => {
+ visit("/queued-posts");
+
+ click('.queued-post:eq(0) button.edit');
+ andThen(() => {
+ equal(find('.queued-post:eq(0) textarea').val(), 'queued post text', 'it shows an editor');
+ });
+
+ fillIn('.queued-post:eq(0) textarea', 'new post text');
+ click('.queued-post:eq(0) button.cancel');
+ andThen(() => {
+ ok(!exists('textarea'), 'it disables editing');
+ equal(find('.queued-post:eq(0) .body p').text(), 'queued post text', 'it reverts the new text');
+ });
+});
+
+test("edit a post - confirm", () => {
+ visit("/queued-posts");
+
+ click('.queued-post:eq(0) button.edit');
+ andThen(() => {
+ equal(find('.queued-post:eq(0) textarea').val(), 'queued post text', 'it shows an editor');
+ });
+
+ fillIn('.queued-post:eq(0) textarea', 'new post text');
+ click('.queued-post:eq(0) button.confirm');
+ andThen(() => {
+ ok(!exists('textarea'), 'it disables editing');
+ equal(find('.queued-post:eq(0) .body p').text(), 'new post text', 'it has the new text');
+ });
+});
diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6
index 43e35b8cab..4de1461546 100644
--- a/test/javascripts/helpers/create-pretender.js.es6
+++ b/test/javascripts/helpers/create-pretender.js.es6
@@ -104,7 +104,7 @@ export default function() {
this.get('/queued_posts', function() {
return response({
- queued_posts: [{id: 1}]
+ queued_posts: [{id: 1, raw: 'queued post text'}]
});
});