UX: Clicking admin menu does not hide select posts box.

This commit is contained in:
Guo Xiang Tan 2018-07-13 10:54:34 +08:00
parent 2901691e87
commit 18e281606a
4 changed files with 37 additions and 5 deletions

View File

@ -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() {

View File

@ -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")

View File

@ -88,6 +88,7 @@ createWidget("topic-admin-menu-button", {
position.left += $button.width() - 203;
}
this.state.position = position;
this.sendWidgetAction("hideMultiSelect");
}
});

View File

@ -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"
);
});