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/mixins/open-composer.js.es6
Bianca Nenciu eef21625c6
Rename 'target usernames' with 'target recipients' in Composer (#8606)
* Reapply "Rename 'target usernames' with 'target recipients' in Composer"

This reverts commit 9fe11d0fc3 which
reverted ebb288dc2c.

* DEV: Add test for replying to PM
2020-01-07 15:33:48 +02:00

53 lines
1.4 KiB
JavaScript

// This mixin allows a route to open the composer
import Composer from "discourse/models/composer";
import Mixin from "@ember/object/mixin";
export default Mixin.create({
openComposer(controller) {
let categoryId = controller.get("category.id");
if (
categoryId &&
controller.category.isUncategorizedCategory &&
!this.siteSettings.allow_uncategorized_topics
) {
categoryId = null;
}
this.controllerFor("composer").open({
categoryId,
action: Composer.CREATE_TOPIC,
draftKey: controller.get("model.draft_key") || Composer.NEW_TOPIC_KEY,
draftSequence: controller.get("model.draft_sequence") || 0
});
},
openComposerWithTopicParams(
controller,
topicTitle,
topicBody,
topicCategoryId,
topicTags
) {
this.controllerFor("composer").open({
action: Composer.CREATE_TOPIC,
topicTitle,
topicBody,
topicCategoryId,
topicTags,
draftKey: controller.get("model.draft_key") || Composer.NEW_TOPIC_KEY,
draftSequence: controller.get("model.draft_sequence")
});
},
openComposerWithMessageParams(recipients, topicTitle, topicBody) {
this.controllerFor("composer").open({
action: Composer.PRIVATE_MESSAGE,
recipients,
topicTitle,
topicBody,
archetypeId: "private_message",
draftKey: Composer.NEW_PRIVATE_MESSAGE_KEY
});
}
});