From 1e289d1443f72dcff57600b428c948be132d9c20 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sat, 4 Jun 2016 01:54:35 +0530 Subject: [PATCH] FEATURE: support adding tags when creating new topic via link --- app/assets/javascripts/discourse/controllers/composer.js.es6 | 4 ++++ app/assets/javascripts/discourse/mixins/open-composer.js.es6 | 3 ++- app/assets/javascripts/discourse/routes/application.js.es6 | 4 ++-- app/assets/javascripts/discourse/routes/new-topic.js.es6 | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 40b047a11..c32f08990 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -532,6 +532,10 @@ export default Ember.Controller.extend({ } } + if (opts.topicTags && !this.site.mobileView && this.site.get('can_tag_topics')) { + this.set('model.tags', opts.topicTags.split(",")); + } + if (opts.topicBody) { this.set('model.reply', opts.topicBody); } diff --git a/app/assets/javascripts/discourse/mixins/open-composer.js.es6 b/app/assets/javascripts/discourse/mixins/open-composer.js.es6 index 5d432f20b..13f7000da 100644 --- a/app/assets/javascripts/discourse/mixins/open-composer.js.es6 +++ b/app/assets/javascripts/discourse/mixins/open-composer.js.es6 @@ -12,13 +12,14 @@ export default Ember.Mixin.create({ }); }, - openComposerWithTopicParams(controller, topicTitle, topicBody, topicCategoryId, topicCategory) { + openComposerWithTopicParams(controller, topicTitle, topicBody, topicCategoryId, topicCategory, topicTags) { this.controllerFor('composer').open({ action: Composer.CREATE_TOPIC, topicTitle, topicBody, topicCategoryId, topicCategory, + topicTags, draftKey: controller.get('model.draft_key'), draftSequence: controller.get('model.draft_sequence') }); diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 7954ade89..3164199ff 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -166,8 +166,8 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { this.render(w, {into: 'modal/topic-bulk-actions', outlet: 'bulkOutlet', controller: factory ? controllerName : 'topic-bulk-actions'}); }, - createNewTopicViaParams(title, body, category_id, category) { - this.openComposerWithTopicParams(this.controllerFor('discovery/topics'), title, body, category_id, category); + createNewTopicViaParams(title, body, category_id, category, tags) { + this.openComposerWithTopicParams(this.controllerFor('discovery/topics'), title, body, category_id, category, tags); }, createNewMessageViaParams(username, title, body) { diff --git a/app/assets/javascripts/discourse/routes/new-topic.js.es6 b/app/assets/javascripts/discourse/routes/new-topic.js.es6 index d27d6a236..53336a67f 100644 --- a/app/assets/javascripts/discourse/routes/new-topic.js.es6 +++ b/app/assets/javascripts/discourse/routes/new-topic.js.es6 @@ -7,7 +7,7 @@ export default Discourse.Route.extend({ if (self.controllerFor('navigation/default').get('canCreateTopic')) { // User can create topic Ember.run.next(function() { - e.send('createNewTopicViaParams', transition.queryParams.title, transition.queryParams.body, transition.queryParams.category_id, transition.queryParams.category); + e.send('createNewTopicViaParams', transition.queryParams.title, transition.queryParams.body, transition.queryParams.category_id, transition.queryParams.category, transition.queryParams.tags); }); } });