diff --git a/app/assets/javascripts/discourse/controllers/composer_controller.js b/app/assets/javascripts/discourse/controllers/composer_controller.js index 7666505be5b..6ef3ad662ef 100644 --- a/app/assets/javascripts/discourse/controllers/composer_controller.js +++ b/app/assets/javascripts/discourse/controllers/composer_controller.js @@ -27,11 +27,56 @@ Discourse.ComposerController = Discourse.Controller.extend({ } }, - save: function() { + save: function(force) { var composer, - _this = this; + _this = this, + topic, + message, + buttons; + composer = this.get('content'); composer.set('disableDrafts', true); + + // 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(!force && composer.get('replyingToTopic')) { + topic = this.get('topic'); + if (!topic || topic.get('id') !== composer.get('topic.id')) + { + message = Em.String.i18n("composer.posting_not_on_topic", {title: this.get('content.topic.title')}); + + buttons = [{ + "label": Em.String.i18n("composer.cancel"), + "class": "btn" + }]; + + buttons.push({ + "label": Em.String.i18n("composer.reply_original"), + "class": "btn-primary", + "callback": function(){ + _this.save(true); + } + }); + + if(topic) { + buttons.push({ + "label": Em.String.i18n("composer.reply_here"), + "class": "btn-primary", + "callback": function(){ + composer.set('topic', topic); + composer.set('post', null); + _this.save(true); + } + }); + } + + bootbox.dialog(message, buttons); + + return; + } + } + return composer.save({ imageSizes: this.get('view').imageSizes() }).then(function(opts) { diff --git a/app/assets/javascripts/discourse/models/composer.js b/app/assets/javascripts/discourse/models/composer.js index c4ee4e24e2a..b7eb770b82c 100644 --- a/app/assets/javascripts/discourse/models/composer.js +++ b/app/assets/javascripts/discourse/models/composer.js @@ -44,6 +44,10 @@ Discourse.Composer = Discourse.Model.extend({ return this.get('action') === EDIT; }).property('action'), + replyingToTopic: (function() { + return this.get('action') === REPLY; + }).property('action'), + viewOpen: (function() { return this.get('composeState') === OPEN; }).property('composeState'), diff --git a/app/assets/javascripts/discourse/routes/topic_route.js b/app/assets/javascripts/discourse/routes/topic_route.js index 9c7e7436d0c..ad73fc0ba43 100644 --- a/app/assets/javascripts/discourse/routes/topic_route.js +++ b/app/assets/javascripts/discourse/routes/topic_route.js @@ -27,6 +27,8 @@ Discourse.TopicRoute = Discourse.Route.extend({ topicController = this.controllerFor('topic'); topicController.cancelFilter(); topicController.set('multiSelect', false); + this.controllerFor('composer').set('topic', null); + if (headerController = this.controllerFor('header')) { headerController.set('topic', null); headerController.set('showExtraInfo', false); @@ -35,6 +37,7 @@ Discourse.TopicRoute = Discourse.Route.extend({ setupController: function(controller, model) { this.controllerFor('header').set('topic', model); + this.controllerFor('composer').set('topic', model); } }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 20a1cab96f9..dbc41a921d5 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -260,6 +260,7 @@ en: message: "Authenticating with Persona (make sure pop up blockers are not enabled)" composer: + posting_not_on_topic: "You have composed a reply to \"{{title}}\", however you are no longer looking at that topic." saving_draft_tip: "saving" saved_draft_tip: "saved" saved_local_draft_tip: "saved locally" @@ -269,7 +270,10 @@ en: more: "{{n}} to go..." save_edit: "Save Edit" + reply_original: "Reply on Original Topic" + reply_here: "Reply Here" reply: "Reply" + cancel: "Cancel" create_topic: "Create Topic" create_pm: "Create Private Message"