mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: build-topic-selection mixin (#7635)
This commit is contained in:
parent
468cfa39f7
commit
b2fc80e4b7
@ -1,4 +1,5 @@
|
|||||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||||
|
import { on } from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
export default Ember.Mixin.create({
|
export default Ember.Mixin.create({
|
||||||
bulkSelectEnabled: false,
|
bulkSelectEnabled: false,
|
||||||
@ -6,9 +7,10 @@ export default Ember.Mixin.create({
|
|||||||
|
|
||||||
canBulkSelect: Ember.computed.alias("currentUser.staff"),
|
canBulkSelect: Ember.computed.alias("currentUser.staff"),
|
||||||
|
|
||||||
resetSelected: function() {
|
@on("init")
|
||||||
|
resetSelected() {
|
||||||
this.set("selected", []);
|
this.set("selected", []);
|
||||||
}.on("init"),
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleBulkSelect() {
|
toggleBulkSelect() {
|
||||||
@ -17,9 +19,6 @@ export default Ember.Mixin.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
dismissRead(operationType) {
|
dismissRead(operationType) {
|
||||||
const self = this,
|
|
||||||
selected = this.selected;
|
|
||||||
|
|
||||||
let operation;
|
let operation;
|
||||||
if (operationType === "posts") {
|
if (operationType === "posts") {
|
||||||
operation = { type: "dismiss_posts" };
|
operation = { type: "dismiss_posts" };
|
||||||
@ -31,8 +30,8 @@ export default Ember.Mixin.create({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let promise;
|
let promise;
|
||||||
if (selected.length > 0) {
|
if (this.selected.length > 0) {
|
||||||
promise = Discourse.Topic.bulkOperation(selected, operation);
|
promise = Discourse.Topic.bulkOperation(this.selected, operation);
|
||||||
} else {
|
} else {
|
||||||
promise = Discourse.Topic.bulkOperationByFilter(
|
promise = Discourse.Topic.bulkOperationByFilter(
|
||||||
"unread",
|
"unread",
|
||||||
@ -40,16 +39,16 @@ export default Ember.Mixin.create({
|
|||||||
this.get("category.id")
|
this.get("category.id")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
promise.then(function(result) {
|
|
||||||
|
promise.then(result => {
|
||||||
if (result && result.topic_ids) {
|
if (result && result.topic_ids) {
|
||||||
const tracker = self.topicTrackingState;
|
const tracker = this.topicTrackingState;
|
||||||
result.topic_ids.forEach(function(t) {
|
result.topic_ids.forEach(t => tracker.removeTopic(t));
|
||||||
tracker.removeTopic(t);
|
|
||||||
});
|
|
||||||
tracker.incrementMessageCount();
|
tracker.incrementMessageCount();
|
||||||
}
|
}
|
||||||
self.send("closeModal");
|
|
||||||
self.send("refresh");
|
this.send("closeModal");
|
||||||
|
this.send("refresh");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user