Merge pull request #4001 from techAPJ/search-page

FEATURE: add 'New Topic' button on full page search view
This commit is contained in:
Jeff Atwood 2016-02-08 01:57:44 -08:00
commit 2ca1449f17
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 {