FEATURE: add 'New Topic' button on full page search view

This commit is contained in:
Arpit Jalan 2016-02-08 00:38:44 +05:30
parent b0567f9c62
commit 796a0db98b
3 changed files with 21 additions and 0 deletions

View File

@ -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});
}
}

View File

@ -1,6 +1,11 @@
<div class="search row clearfix">
{{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
{{d-button action="search" icon="search" class="btn-primary" disabled=searchButtonDisabled}}
{{#if currentUser}}
{{#unless site.mobileView}}
<span class="new-topic-btn">{{d-button id="create-topic" class="btn-default" action="createTopic" actionParam=searchTerm icon="plus" label="topic.create"}}</span>
{{/unless}}
{{/if}}
{{#if canBulkSelect}}
{{#if model.posts}}
{{d-button icon="list" class="bulk-select" title="topics.bulk.toggle" action="toggleBulkSelect"}}

View File

@ -74,6 +74,10 @@
height: 22px;
padding-left: 6px;
}
.new-topic-btn {
float:right;
}
}
.search-footer {