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/app/components/shared-draft-controls.js
Robin Ward eab560fe2a
DEV: import I18n instead of global usage (#9768)
Co-authored-by: Mark VanLandingham <markvanlan@gmail.com>
Co-authored-by: Robin Ward <robin.ward@gmail.com>

Co-authored-by: Mark VanLandingham <markvanlan@gmail.com>
2020-05-13 16:23:41 -04:00

37 lines
979 B
JavaScript

import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component";
export default Component.extend({
tagName: "",
publishing: false,
@discourseComputed("topic.destination_category_id")
validCategory(destCatId) {
return destCatId && destCatId !== this.site.shared_drafts_category_id;
},
actions: {
updateDestinationCategory(categoryId) {
return this.topic.updateDestinationCategory(categoryId);
},
publish() {
bootbox.confirm(I18n.t("shared_drafts.confirm_publish"), result => {
if (result) {
this.set("publishing", true);
let destId = this.get("topic.destination_category_id");
this.topic
.publish()
.then(() => {
this.set("topic.category_id", destId);
})
.finally(() => {
this.set("publishing", false);
});
}
});
}
}
});