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
Robin Ward 8dd3cbfcb9
FEATURE: Allow choice of category when making a PM public (#7907)
* FEATURE: Allow choice of category when making a PM public

Previously it would default to uncategorized, which was not ideal on
some forums. This gives the staff member more choice about what they'd
like to do.

* Make the optional category more explicit

* Joffrey's feedback
2019-07-19 11:52:50 -04:00

27 lines
746 B
JavaScript

import { popupAjaxError } from "discourse/lib/ajax-error";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Ember.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);
}
}
});