This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/convert-to-public-topic.js.es6

28 lines
784 B
JavaScript

import Controller from "@ember/controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Controller.extend(ModalFunctionality, {
publicCategoryId: null,
saving: true,
onShow() {
this.setProperties({ publicCategoryId: null, saving: false });
},
actions: {
makePublic() {
let topic = this.model;
topic
.convertTopic("public", { categoryId: this.publicCategoryId })
.then(() => {
topic.set("archetype", "regular");
topic.set("category_id", this.publicCategoryId);
this.appEvents.trigger("header:show-topic", topic);
this.send("closeModal");
})
.catch(popupAjaxError);
}
}
});