UX: Use topic list bulk select toggle for user messages list. (#13614)
This commit is contained in:
parent
100c3d6d62
commit
43058db3ca
|
@ -1,67 +1,28 @@
|
|||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { action } from "@ember/object";
|
||||
import { alias, and, equal } from "@ember/object/computed";
|
||||
import I18n from "I18n";
|
||||
import Topic from "discourse/models/topic";
|
||||
import bootbox from "bootbox";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { VIEW_NAME_WARNINGS } from "discourse/routes/user-private-messages-warnings";
|
||||
|
||||
export default Controller.extend({
|
||||
userTopicsList: controller("user-topics-list"),
|
||||
user: controller(),
|
||||
|
||||
pmView: false,
|
||||
viewingSelf: alias("user.viewingSelf"),
|
||||
isGroup: equal("pmView", "groups"),
|
||||
currentPath: alias("router._router.currentPath"),
|
||||
selected: alias("userTopicsList.selected"),
|
||||
bulkSelectEnabled: alias("userTopicsList.bulkSelectEnabled"),
|
||||
showToggleBulkSelect: true,
|
||||
pmTaggingEnabled: alias("site.can_tag_pms"),
|
||||
tagId: null,
|
||||
|
||||
showNewPM: and("user.viewingSelf", "currentUser.can_send_private_messages"),
|
||||
|
||||
@discourseComputed("selected.[]", "bulkSelectEnabled")
|
||||
hasSelection(selected, bulkSelectEnabled) {
|
||||
return bulkSelectEnabled && selected && selected.length > 0;
|
||||
},
|
||||
|
||||
@discourseComputed("viewingSelf", "pmView", "currentUser.admin")
|
||||
showWarningsWarning(viewingSelf, pmView, isAdmin) {
|
||||
return pmView === VIEW_NAME_WARNINGS && !viewingSelf && !isAdmin;
|
||||
},
|
||||
|
||||
bulkOperation(operation) {
|
||||
const selected = this.selected;
|
||||
let params = { type: operation };
|
||||
if (this.isGroup) {
|
||||
params.group = this.groupFilter;
|
||||
}
|
||||
|
||||
Topic.bulkOperation(selected, params).then(
|
||||
() => {
|
||||
const model = this.get("userTopicsList.model");
|
||||
const topics = model.get("topics");
|
||||
topics.removeObjects(selected);
|
||||
selected.clear();
|
||||
model.loadMore();
|
||||
},
|
||||
() => {
|
||||
bootbox.alert(I18n.t("user.messages.failed_to_move"));
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
@action
|
||||
changeGroupNotificationLevel(notificationLevel) {
|
||||
this.group.setNotification(notificationLevel, this.get("user.model.id"));
|
||||
},
|
||||
|
||||
@action
|
||||
toggleBulkSelect() {
|
||||
this.selected.clear();
|
||||
this.toggleProperty("bulkSelectEnabled");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||
import BulkTopicSelection from "discourse/mixins/bulk-topic-selection";
|
||||
|
||||
// Lists of topics on a user's page.
|
||||
export default Controller.extend({
|
||||
export default Controller.extend(BulkTopicSelection, {
|
||||
application: controller(),
|
||||
|
||||
hideCategory: false,
|
||||
|
|
|
@ -44,12 +44,12 @@ export default (viewName, path, channel) => {
|
|||
canBulkSelect: true,
|
||||
tagsForUser: this.modelFor("user").get("username_lower"),
|
||||
selected: [],
|
||||
showToggleBulkSelect: true,
|
||||
});
|
||||
|
||||
this.controllerFor("user-private-messages").setProperties({
|
||||
archive: false,
|
||||
pmView: viewName,
|
||||
showToggleBulkSelect: true,
|
||||
});
|
||||
|
||||
this.searchService.set("contextType", "private_messages");
|
||||
|
|
|
@ -26,8 +26,13 @@ export default DiscourseRoute.extend({
|
|||
: ["count:desc", "id"],
|
||||
tagsForUser: this.modelFor("user").get("username_lower"),
|
||||
});
|
||||
this.controllerFor("user-private-messages").setProperties({
|
||||
|
||||
this.controllerFor("user-topics-list").setProperties({
|
||||
showToggleBulkSelect: false,
|
||||
selected: [],
|
||||
});
|
||||
|
||||
this.controllerFor("user-private-messages").setProperties({
|
||||
pmView: "tags",
|
||||
});
|
||||
},
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
tagsForUser=tagsForUser
|
||||
onScroll=onScroll
|
||||
scrollOnLoad=scrollOnLoad
|
||||
toggleBulkSelect=toggleBulkSelect
|
||||
updateAutoAddTopicsToBulkSelect=updateAutoAddTopicsToBulkSelect
|
||||
}}
|
||||
{{else}}
|
||||
{{#unless loadingMore}}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
{{#unless site.mobileView}}
|
||||
{{#if showToggleBulkSelect}}
|
||||
{{bulk-select-button selected=selected action=(route-action "refresh")}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
{{#load-more class="paginated-topics-list" selector=".paginated-topics-list .topic-list tr" action=(action "loadMore")}}
|
||||
{{basic-topic-list topicList=model
|
||||
hideCategory=hideCategory
|
||||
|
@ -9,7 +15,10 @@
|
|||
showInserted=(action "showInserted")
|
||||
tagsForUser=tagsForUser
|
||||
onScroll=saveScrollPosition
|
||||
scrollOnLoad=true}}
|
||||
canBulkSelect=canBulkSelect
|
||||
scrollOnLoad=true
|
||||
toggleBulkSelect=(action "toggleBulkSelect")
|
||||
updateAutoAddTopicsToBulkSelect=(action "updateAutoAddTopicsToBulkSelect")}}
|
||||
|
||||
{{conditional-loading-spinner condition=model.loadingMore}}
|
||||
{{/load-more}}
|
||||
|
|
|
@ -57,13 +57,6 @@
|
|||
|
||||
<section class="user-content">
|
||||
<div class="list-actions">
|
||||
{{#unless site.mobileView}}
|
||||
{{#if showToggleBulkSelect}}
|
||||
{{d-button icon="list" class="btn-default bulk-select" title="topics.bulk.toggle" action=(action "toggleBulkSelect")}}
|
||||
{{bulk-select-button selected=selected action=(route-action "refresh")}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
{{#if site.mobileView}}
|
||||
{{#if showNewPM}}
|
||||
{{d-button
|
||||
|
@ -74,12 +67,6 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#if bulkSelectEnabled}}
|
||||
{{bulk-select-all
|
||||
class="btn-default btn-select-all"
|
||||
label="user.messages.select_all"}}
|
||||
{{/if}}
|
||||
|
||||
{{#if isGroup}}
|
||||
{{group-notifications-button
|
||||
value=group.group_user.notification_level
|
||||
|
|
|
@ -1172,11 +1172,9 @@ en:
|
|||
sent: "Sent"
|
||||
archive: "Archive"
|
||||
groups: "My Groups"
|
||||
bulk_select: "Select messages"
|
||||
move_to_inbox: "Move to Inbox"
|
||||
move_to_archive: "Archive"
|
||||
failed_to_move: "Failed to move selected messages (perhaps your network is down)"
|
||||
select_all: "Select All"
|
||||
tags: "Tags"
|
||||
warnings: "Official Warnings"
|
||||
|
||||
|
|
Loading…
Reference in New Issue