mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
reply to first post === reply to topic
This commit is contained in:
parent
a3155858a0
commit
fce2d0e3b6
2 changed files with 47 additions and 42 deletions
|
@ -100,11 +100,16 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
|
|||
var post = this.get('post');
|
||||
var composerController = this.get('controllers.composer');
|
||||
var composerOpts = {
|
||||
post: post,
|
||||
action: Discourse.Composer.REPLY,
|
||||
draftKey: this.get('post.topic.draft_key')
|
||||
};
|
||||
|
||||
if(post.get('post_number') === 1) {
|
||||
composerOpts.topic = post.get("topic");
|
||||
} else {
|
||||
composerOpts.post = post;
|
||||
}
|
||||
|
||||
// If the composer is associated with a different post, we don't change it.
|
||||
var composerPost = composerController.get('content.post');
|
||||
if (composerPost && (composerPost.get('id') !== this.get('post.id'))) {
|
||||
|
|
|
@ -198,41 +198,6 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
Discourse.URL.routeTo(this.get('lastPostUrl'));
|
||||
},
|
||||
|
||||
replyAsNewTopic: function(post) {
|
||||
// TODO shut down topic draft cleanly if it exists ...
|
||||
var composerController = this.get('controllers.composer');
|
||||
var promise = composerController.open({
|
||||
action: Discourse.Composer.CREATE_TOPIC,
|
||||
draftKey: Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY
|
||||
});
|
||||
var postUrl = "" + location.protocol + "//" + location.host + (post.get('url'));
|
||||
var postLink = "[" + (this.get('title')) + "](" + postUrl + ")";
|
||||
|
||||
promise.then(function() {
|
||||
Discourse.Post.loadQuote(post.get('id')).then(function(q) {
|
||||
composerController.appendText("" + (I18n.t("post.continue_discussion", {
|
||||
postLink: postLink
|
||||
})) + "\n\n" + q);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Topic related
|
||||
reply: function() {
|
||||
var composerController = this.get('controllers.composer');
|
||||
if (composerController.get('content.topic.id') === this.get('content.id') &&
|
||||
composerController.get('content.action') === Discourse.Composer.REPLY) {
|
||||
composerController.set('content.post', null);
|
||||
composerController.set('content.composeState', Discourse.Composer.OPEN);
|
||||
} else {
|
||||
composerController.open({
|
||||
topic: this.get('content'),
|
||||
action: Discourse.Composer.REPLY,
|
||||
draftKey: this.get('content.draft_key'),
|
||||
draftSequence: this.get('content.draft_sequence')
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Toggle a participant for filtering
|
||||
|
@ -336,25 +301,60 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
var composerController = this.get('controllers.composer');
|
||||
var quoteController = this.get('controllers.quoteButton');
|
||||
var quotedText = Discourse.BBCode.buildQuoteBBCode(quoteController.get('post'), quoteController.get('buffer'));
|
||||
|
||||
var topic = post ? post.get('topic') : this.get('model');
|
||||
|
||||
quoteController.set('buffer', '');
|
||||
|
||||
if (composerController.get('content.topic.id') === post.get('topic.id') &&
|
||||
if (composerController.get('content.topic.id') === topic.get('id') &&
|
||||
composerController.get('content.action') === Discourse.Composer.REPLY) {
|
||||
composerController.set('content.post', post);
|
||||
composerController.set('content.composeState', Discourse.Composer.OPEN);
|
||||
composerController.appendText(quotedText);
|
||||
} else {
|
||||
var promise = composerController.open({
|
||||
post: post,
|
||||
|
||||
var opts = {
|
||||
action: Discourse.Composer.REPLY,
|
||||
draftKey: post.get('topic.draft_key'),
|
||||
draftSequence: post.get('topic.draft_sequence')
|
||||
});
|
||||
draftKey: topic.get('draft_key'),
|
||||
draftSequence: topic.get('draft_sequence')
|
||||
};
|
||||
|
||||
if(post && post.get("post_number") !== 1){
|
||||
opts.post = post;
|
||||
} else {
|
||||
opts.topic = topic;
|
||||
}
|
||||
|
||||
var promise = composerController.open(opts);
|
||||
promise.then(function() { composerController.appendText(quotedText); });
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
replyAsNewTopic: function(post) {
|
||||
// TODO shut down topic draft cleanly if it exists ...
|
||||
var composerController = this.get('controllers.composer');
|
||||
var promise = composerController.open({
|
||||
action: Discourse.Composer.CREATE_TOPIC,
|
||||
draftKey: Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY
|
||||
});
|
||||
var postUrl = "" + location.protocol + "//" + location.host + (post.get('url'));
|
||||
var postLink = "[" + (this.get('title')) + "](" + postUrl + ")";
|
||||
|
||||
promise.then(function() {
|
||||
Discourse.Post.loadQuote(post.get('id')).then(function(q) {
|
||||
composerController.appendText("" + (I18n.t("post.continue_discussion", {
|
||||
postLink: postLink
|
||||
})) + "\n\n" + q);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Topic related
|
||||
reply: function() {
|
||||
this.replyToPost();
|
||||
},
|
||||
|
||||
// Edits a post
|
||||
editPost: function(post) {
|
||||
this.get('controllers.composer').open({
|
||||
|
|
Loading…
Reference in a new issue