Merge pull request #4001 from techAPJ/search-page
FEATURE: add 'New Topic' button on full page search view
This commit is contained in:
commit
2ca1449f17
|
@ -1,4 +1,5 @@
|
||||||
import { translateResults, getSearchKey, isValidSearchTerm } from "discourse/lib/search";
|
import { translateResults, getSearchKey, isValidSearchTerm } from "discourse/lib/search";
|
||||||
|
import Composer from 'discourse/models/composer';
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
queryParams: { q: {}, context_id: {}, context: {}, skip_context: {} },
|
queryParams: { q: {}, context_id: {}, context: {}, skip_context: {} },
|
||||||
|
@ -39,6 +40,17 @@ export default Discourse.Route.extend({
|
||||||
didTransition() {
|
didTransition() {
|
||||||
this.controllerFor("full-page-search")._showFooter();
|
this.controllerFor("full-page-search")._showFooter();
|
||||||
return true;
|
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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<div class="search row clearfix">
|
<div class="search row clearfix">
|
||||||
{{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
|
{{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}}
|
{{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 canBulkSelect}}
|
||||||
{{#if model.posts}}
|
{{#if model.posts}}
|
||||||
{{d-button icon="list" class="bulk-select" title="topics.bulk.toggle" action="toggleBulkSelect"}}
|
{{d-button icon="list" class="bulk-select" title="topics.bulk.toggle" action="toggleBulkSelect"}}
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
height: 22px;
|
height: 22px;
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-topic-btn {
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-footer {
|
.search-footer {
|
||||||
|
|
Loading…
Reference in New Issue