mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 15:33:55 +08:00
67b34600d5
Even though `type` is an alias for `method`, we have custom logic in `/discourse/lib/ajax` that checks only `type`, and ~200 other ajax calls in the codebase already use `type` param.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import Controller from "@ember/controller";
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
export default Controller.extend(ModalFunctionality, {
|
|
loading: true,
|
|
reseeding: false,
|
|
categories: null,
|
|
topics: null,
|
|
|
|
onShow() {
|
|
ajax("/admin/customize/reseed")
|
|
.then(result => {
|
|
this.setProperties({
|
|
categories: result.categories,
|
|
topics: result.topics
|
|
});
|
|
})
|
|
.finally(() => this.set("loading", false));
|
|
},
|
|
|
|
_extractSelectedIds(items) {
|
|
return items.filter(item => item.selected).map(item => item.id);
|
|
},
|
|
|
|
actions: {
|
|
reseed() {
|
|
this.set("reseeding", true);
|
|
ajax("/admin/customize/reseed", {
|
|
data: {
|
|
category_ids: this._extractSelectedIds(this.categories),
|
|
topic_ids: this._extractSelectedIds(this.topics)
|
|
},
|
|
type: "POST"
|
|
})
|
|
.then(
|
|
() => this.send("closeModal"),
|
|
() => bootbox.alert(I18n.t("generic_error"))
|
|
)
|
|
.finally(() => this.set("reseeding", false));
|
|
}
|
|
}
|
|
});
|