diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 763f9708cc7..01161633777 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -148,6 +148,10 @@ export default Ember.Controller.extend(BufferedContent, { ); }, + _forceRefreshPostStream() { + this.appEvents.trigger("post-stream:refresh", { force: true }); + }, + actions: { showPostFlags(post) { return this.send("showFlags", post); @@ -587,19 +591,24 @@ export default Ember.Controller.extend(BufferedContent, { this._jumpToPostId(postId); }, + hideMultiSelect() { + this.set("multiSelect", false); + this._forceRefreshPostStream(); + }, + toggleMultiSelect() { this.toggleProperty("multiSelect"); - this.appEvents.trigger("post-stream:refresh", { force: true }); + this._forceRefreshPostStream(); }, selectAll() { this.set("selectedPostIds", [...this.get("model.postStream.stream")]); - this.appEvents.trigger("post-stream:refresh", { force: true }); + this._forceRefreshPostStream(); }, deselectAll() { this.set("selectedPostIds", []); - this.appEvents.trigger("post-stream:refresh", { force: true }); + this._forceRefreshPostStream(); }, togglePostSelection(post) { @@ -613,7 +622,7 @@ export default Ember.Controller.extend(BufferedContent, { ajax(`/posts/${post.id}/reply-ids.json`).then(replies => { const replyIds = replies.map(r => r.id); this.get("selectedPostIds").pushObjects([post.id, ...replyIds]); - this.appEvents.trigger("post-stream:refresh", { force: true }); + this._forceRefreshPostStream(); }); }, @@ -621,7 +630,7 @@ export default Ember.Controller.extend(BufferedContent, { const stream = [...this.get("model.postStream.stream")]; const below = stream.slice(stream.indexOf(post.id)); this.get("selectedPostIds").pushObjects(below); - this.appEvents.trigger("post-stream:refresh", { force: true }); + this._forceRefreshPostStream(); }, deleteSelected() { diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index 47f221ec08a..e08cea7e03e 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -85,6 +85,7 @@ topic=model fixed="true" toggleMultiSelect=(action "toggleMultiSelect") + hideMultiSelect=(action "hideMultiSelect") deleteTopic=(action "deleteTopic") recoverTopic=(action "recoverTopic") toggleClosed=(action "toggleClosed") @@ -111,6 +112,7 @@ jumpToIndex=(action "jumpToIndex") replyToPost=(action "replyToPost") toggleMultiSelect=(action "toggleMultiSelect") + hideMultiSelect=(action "hideMultiSelect") deleteTopic=(action "deleteTopic") recoverTopic=(action "recoverTopic") toggleClosed=(action "toggleClosed") @@ -133,6 +135,7 @@ openUpwards="true" rightSide="true" toggleMultiSelect=(action "toggleMultiSelect") + hideMultiSelect=(action "hideMultiSelect") deleteTopic=(action "deleteTopic") recoverTopic=(action "recoverTopic") toggleClosed=(action "toggleClosed") @@ -242,6 +245,7 @@ {{topic-footer-buttons topic=model toggleMultiSelect=(action "toggleMultiSelect") + hideMultiSelect=(action "hideMultiSelect") deleteTopic=(action "deleteTopic") recoverTopic=(action "recoverTopic") toggleClosed=(action "toggleClosed") diff --git a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 index 6445700aa00..c66887995c7 100644 --- a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 @@ -88,6 +88,7 @@ createWidget("topic-admin-menu-button", { position.left += $button.width() - 203; } this.state.position = position; + this.sendWidgetAction("hideMultiSelect"); } }); diff --git a/test/javascripts/acceptance/topic-test.js.es6 b/test/javascripts/acceptance/topic-test.js.es6 index 4d5e935a97a..57cff8e85b1 100644 --- a/test/javascripts/acceptance/topic-test.js.es6 +++ b/test/javascripts/acceptance/topic-test.js.es6 @@ -241,3 +241,21 @@ QUnit.test("remove featured link", assert => { // assert.ok(!exists('.title-wrapper .topic-featured-link'), 'link is gone'); // }); }); + +QUnit.test("selecting posts", async assert => { + await visit("/t/internationalization-localization/280"); + await click(".toggle-admin-menu"); + await click(".topic-admin-multi-select .btn"); + + assert.ok( + exists(".selected-posts:not(.hidden)"), + "it should show the multi select menu" + ); + + await click(".toggle-admin-menu"); + + assert.ok( + exists(".selected-posts.hidden"), + "it should hide the multi select menu" + ); +});