mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Reply as new Topic wasn't clearing drafts
This commit is contained in:
parent
52acbec647
commit
e73c809836
@ -9,6 +9,8 @@
|
|||||||
Discourse.ComposerController = Discourse.Controller.extend({
|
Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
needs: ['modal', 'topic'],
|
needs: ['modal', 'topic'],
|
||||||
|
|
||||||
|
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY),
|
||||||
|
|
||||||
togglePreview: function() {
|
togglePreview: function() {
|
||||||
this.get('model').togglePreview();
|
this.get('model').togglePreview();
|
||||||
},
|
},
|
||||||
@ -32,13 +34,8 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
save: function(force) {
|
save: function(force) {
|
||||||
var composer,
|
var composer = this.get('model'),
|
||||||
_this = this,
|
composerController = this;
|
||||||
topic,
|
|
||||||
message,
|
|
||||||
buttons;
|
|
||||||
|
|
||||||
composer = this.get('model');
|
|
||||||
|
|
||||||
if( composer.get('cantSubmitPost') ) {
|
if( composer.get('cantSubmitPost') ) {
|
||||||
this.set('view.showTitleTip', Date.now());
|
this.set('view.showTitleTip', Date.now());
|
||||||
@ -52,12 +49,12 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||||||
// for now handle a very narrow use case
|
// for now handle a very narrow use case
|
||||||
// if we are replying to a topic AND not on the topic pop the window up
|
// if we are replying to a topic AND not on the topic pop the window up
|
||||||
if(!force && composer.get('replyingToTopic')) {
|
if(!force && composer.get('replyingToTopic')) {
|
||||||
topic = this.get('topic');
|
var topic = this.get('topic');
|
||||||
if (!topic || topic.get('id') !== composer.get('topic.id'))
|
if (!topic || topic.get('id') !== composer.get('topic.id'))
|
||||||
{
|
{
|
||||||
message = I18n.t("composer.posting_not_on_topic", {title: this.get('model.topic.title')});
|
var message = I18n.t("composer.posting_not_on_topic", {title: this.get('model.topic.title')});
|
||||||
|
|
||||||
buttons = [{
|
var buttons = [{
|
||||||
"label": I18n.t("composer.cancel"),
|
"label": I18n.t("composer.cancel"),
|
||||||
"class": "cancel",
|
"class": "cancel",
|
||||||
"link": true
|
"link": true
|
||||||
@ -70,7 +67,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||||||
"callback": function(){
|
"callback": function(){
|
||||||
composer.set('topic', topic);
|
composer.set('topic', topic);
|
||||||
composer.set('post', null);
|
composer.set('post', null);
|
||||||
_this.save(true);
|
composerController.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -79,7 +76,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||||||
"label": I18n.t("composer.reply_original") + "<br/><div class='topic-title'>" + this.get('model.topic.title') + "</div>",
|
"label": I18n.t("composer.reply_original") + "<br/><div class='topic-title'>" + this.get('model.topic.title') + "</div>",
|
||||||
"class": "btn-primary btn-reply-on-original",
|
"class": "btn-primary btn-reply-on-original",
|
||||||
"callback": function(){
|
"callback": function(){
|
||||||
_this.save(true);
|
composerController.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -91,8 +88,15 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||||||
return composer.save({
|
return composer.save({
|
||||||
imageSizes: this.get('view').imageSizes()
|
imageSizes: this.get('view').imageSizes()
|
||||||
}).then(function(opts) {
|
}).then(function(opts) {
|
||||||
|
|
||||||
|
// If we replied as a new topic successfully, remove the draft.
|
||||||
|
if (composerController.get('replyAsNewTopicDraft')) {
|
||||||
|
composerController.destroyDraft();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
_this.close();
|
composerController.close();
|
||||||
|
|
||||||
var currentUser = Discourse.User.current();
|
var currentUser = Discourse.User.current();
|
||||||
if (composer.get('creatingTopic')) {
|
if (composer.get('creatingTopic')) {
|
||||||
@ -101,6 +105,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||||||
currentUser.set('reply_count', currentUser.get('reply_count') + 1);
|
currentUser.set('reply_count', currentUser.get('reply_count') + 1);
|
||||||
}
|
}
|
||||||
Discourse.URL.routeTo(opts.post.get('url'));
|
Discourse.URL.routeTo(opts.post.get('url'));
|
||||||
|
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
composer.set('disableDrafts', false);
|
composer.set('disableDrafts', false);
|
||||||
bootbox.alert(error);
|
bootbox.alert(error);
|
||||||
|
@ -332,7 +332,6 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||||||
},
|
},
|
||||||
|
|
||||||
replyAsNewTopic: function(post) {
|
replyAsNewTopic: function(post) {
|
||||||
// TODO shut down topic draft cleanly if it exists ...
|
|
||||||
var composerController = this.get('controllers.composer');
|
var composerController = this.get('controllers.composer');
|
||||||
var promise = composerController.open({
|
var promise = composerController.open({
|
||||||
action: Discourse.Composer.CREATE_TOPIC,
|
action: Discourse.Composer.CREATE_TOPIC,
|
||||||
@ -343,9 +342,9 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||||||
|
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
Discourse.Post.loadQuote(post.get('id')).then(function(q) {
|
Discourse.Post.loadQuote(post.get('id')).then(function(q) {
|
||||||
composerController.appendText("" + (I18n.t("post.continue_discussion", {
|
composerController.appendText(I18n.t("post.continue_discussion", {
|
||||||
postLink: postLink
|
postLink: postLink
|
||||||
})) + "\n\n" + q);
|
}) + "\n\n" + q);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
//= require ./discourse/components/debounce
|
//= require ./discourse/components/debounce
|
||||||
//= require ./discourse/models/model
|
//= require ./discourse/models/model
|
||||||
//= require ./discourse/models/user_action
|
//= require ./discourse/models/user_action
|
||||||
|
//= require ./discourse/models/composer
|
||||||
//= require ./discourse/controllers/controller
|
//= require ./discourse/controllers/controller
|
||||||
//= require ./discourse/controllers/object_controller
|
//= require ./discourse/controllers/object_controller
|
||||||
//= require ./discourse/views/modal/modal_body_view
|
//= require ./discourse/views/modal/modal_body_view
|
||||||
|
Loading…
Reference in New Issue
Block a user