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/components/shared-draft-controls.js.es6
2019-05-27 10:15:39 +02:00

35 lines
911 B
JavaScript

import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
tagName: "",
publishing: false,
@computed("topic.destination_category_id")
validCategory(destCatId) {
return destCatId && destCatId !== this.site.shared_drafts_category_id;
},
actions: {
updateDestinationCategory(category) {
return this.topic.updateDestinationCategory(category.get("id"));
},
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);
});
}
});
}
}
});