From 796a0db98b3f13bf83d5807a68bf79ac39deb0ad Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 8 Feb 2016 00:38:44 +0530 Subject: [PATCH] FEATURE: add 'New Topic' button on full page search view --- .../discourse/routes/full-page-search.js.es6 | 12 ++++++++++++ .../discourse/templates/full-page-search.hbs | 5 +++++ app/assets/stylesheets/common/base/search.scss | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 index 3cda47e9a75..dc895f43077 100644 --- a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 @@ -1,4 +1,5 @@ import { translateResults, getSearchKey, isValidSearchTerm } from "discourse/lib/search"; +import Composer from 'discourse/models/composer'; export default Discourse.Route.extend({ queryParams: { q: {}, context_id: {}, context: {}, skip_context: {} }, @@ -39,6 +40,17 @@ export default Discourse.Route.extend({ didTransition() { this.controllerFor("full-page-search")._showFooter(); return true; + }, + + createTopic(searchTerm) { + let category; + if (searchTerm.indexOf("category:")) { + const match = searchTerm.match(/category:(\S*)/); + if (match && match[1]) { + category = match[1]; + } + } + this.container.lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC, topicCategory: category}); } } diff --git a/app/assets/javascripts/discourse/templates/full-page-search.hbs b/app/assets/javascripts/discourse/templates/full-page-search.hbs index 344c28985be..e216f7ab3f1 100644 --- a/app/assets/javascripts/discourse/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/templates/full-page-search.hbs @@ -1,6 +1,11 @@