Messages are now in 3 buckets - Inbox for all new messages - Sent for all sent messages - Archive for all messages you are done with You can select messages from your Inbox or Sent and move them to your Archive, you can move messages out of your Archive similarly Similar concept applied to group messages, except that archiving and unarchiving will apply to all group members
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
import computed from 'ember-addons/ember-computed-decorators';
|
|
import Topic from 'discourse/models/topic';
|
|
|
|
export default Ember.Controller.extend({
|
|
|
|
needs: ["user-topics-list"],
|
|
pmView: false,
|
|
|
|
isGroup: Em.computed.equal('pmView', 'groups'),
|
|
|
|
selected: Em.computed.alias('controllers.user-topics-list.selected'),
|
|
bulkSelectEnabled: Em.computed.alias('controllers.user-topics-list.bulkSelectEnabled'),
|
|
|
|
@computed('selected.@each', 'bulkSelectEnabled')
|
|
hasSelection(selected, bulkSelectEnabled){
|
|
return bulkSelectEnabled && selected && selected.length > 0;
|
|
},
|
|
|
|
@computed('hasSelection', 'pmView', 'archive')
|
|
canMoveToInbox(hasSelection, pmView, archive){
|
|
return hasSelection && (pmView === "archive" || archive);
|
|
},
|
|
|
|
@computed('hasSelection', 'pmView', 'archive')
|
|
canArchive(hasSelection, pmView, archive){
|
|
return hasSelection && pmView !== "archive" && !archive;
|
|
},
|
|
|
|
|
|
bulkOperation(operation) {
|
|
const selected = this.get('selected');
|
|
var params = {type: operation};
|
|
if (this.get('isGroup')) {
|
|
params.group = this.get('groupFilter');
|
|
}
|
|
|
|
Topic.bulkOperation(selected,params).then(() => {
|
|
const model = this.get('controllers.user-topics-list.model');
|
|
const topics = model.get('topics');
|
|
topics.removeObjects(selected);
|
|
selected.clear();
|
|
model.loadMore();
|
|
}, () => {
|
|
bootbox.alert(I18n.t("user.messages.failed_to_move"));
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
archive() {
|
|
this.bulkOperation("archive_messages");
|
|
},
|
|
toInbox() {
|
|
this.bulkOperation("move_messages_to_inbox");
|
|
},
|
|
toggleBulkSelect(){
|
|
this.toggleProperty("bulkSelectEnabled");
|
|
},
|
|
selectAll() {
|
|
$('input.bulk-select:not(checked)').click();
|
|
}
|
|
}
|
|
});
|