mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
work-in-progress full page search
This commit is contained in:
parent
2843224e80
commit
4dbd065026
|
@ -1,11 +1,25 @@
|
|||
import DiscourseController from 'discourse/controllers/controller';
|
||||
|
||||
export default DiscourseController.extend({
|
||||
needs: ['discovery', 'discovery/topics'],
|
||||
categories: function() {
|
||||
return Discourse.Category.list();
|
||||
}.property(),
|
||||
|
||||
navItems: function() {
|
||||
return Discourse.NavItem.buildList();
|
||||
}.property()
|
||||
return Discourse.NavItem.buildList(null, {filterMode: this.get('filterMode')});
|
||||
}.property('filterMode'),
|
||||
|
||||
isSearch: Em.computed.equal('filterMode', 'search'),
|
||||
|
||||
searchTerm: Em.computed.alias('controllers.discovery/topics.model.params.search'),
|
||||
|
||||
actions: {
|
||||
search: function(){
|
||||
var discovery = this.get('controllers.discovery/topics');
|
||||
var model = discovery.get('model');
|
||||
discovery.set('search', this.get("searchTerm"));
|
||||
model.refreshSort();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -84,7 +84,15 @@ Discourse.NavItem.reopenClass({
|
|||
args = args || {};
|
||||
if (category) { args.category = category }
|
||||
|
||||
return Discourse.SiteSettings.top_menu.split("|").map(function(i) {
|
||||
var items = Discourse.SiteSettings.top_menu.split("|");
|
||||
|
||||
if (args.filterMode && !_.some(items, function(i){
|
||||
return i.indexOf(args.filterMode) !== -1;
|
||||
})) {
|
||||
items.push(args.filterMode);
|
||||
}
|
||||
|
||||
return items.map(function(i) {
|
||||
return Discourse.NavItem.fromText(i, args);
|
||||
}).filter(function(i) {
|
||||
return i !== null && !(category && i.get("name").indexOf("categor") === 0);
|
||||
|
|
|
@ -41,8 +41,8 @@ Discourse.TopicList = Discourse.Model.extend({
|
|||
var self = this,
|
||||
params = this.get('params');
|
||||
|
||||
params.order = order;
|
||||
params.ascending = ascending;
|
||||
params.order = order || params.order;
|
||||
params.ascending = ascending || params.ascending || true;
|
||||
|
||||
this.set('loaded', false);
|
||||
var finder = finderFor(this.get('filter'), params);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
{{#if isSearch}}
|
||||
<div class="search row">
|
||||
{{input type="text" value=searchTerm class="input-xxlarge search" action="search"}}
|
||||
<button {{action "search"}} class="btn btn-primary"><i class='fa fa-search'></i></button>
|
||||
</div>
|
||||
{{else}}
|
||||
{{bread-crumbs categories=categories}}
|
||||
|
||||
<ul class="nav nav-pills" id='navigation-bar'>
|
||||
|
@ -10,3 +16,4 @@
|
|||
{{#if canCreateTopic}}
|
||||
<button id="create-topic" class='btn btn-default' {{action "createTopic"}}><i class='fa fa-plus'></i>{{i18n 'topic.create'}}</button>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
font-weight: normal;
|
||||
}
|
||||
|
||||
.search .btn {
|
||||
float: none;
|
||||
}
|
||||
|
||||
|
||||
a.badge-category {
|
||||
padding: 3px 12px;
|
||||
font-size: 1.143em;
|
||||
|
|
|
@ -867,6 +867,7 @@ en:
|
|||
category: "There are no more {{category}} topics."
|
||||
top: "There are no more top topics."
|
||||
bookmarks: "There are no more bookmarked topics."
|
||||
search: "There are no more search results."
|
||||
|
||||
topic:
|
||||
filter_to: "{{post_count}} posts in topic"
|
||||
|
@ -1497,6 +1498,9 @@ en:
|
|||
read:
|
||||
title: "Read"
|
||||
help: "topics you've read, in the order that you last read them"
|
||||
search:
|
||||
title: "Search"
|
||||
help: "search all topics"
|
||||
categories:
|
||||
title: "Categories"
|
||||
title_in: "Category - {{categoryName}}"
|
||||
|
|
|
@ -56,7 +56,7 @@ module Discourse
|
|||
class CSRF < StandardError; end
|
||||
|
||||
def self.filters
|
||||
@filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks]
|
||||
@filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks, :search]
|
||||
end
|
||||
|
||||
def self.feed_filters
|
||||
|
|
|
@ -70,6 +70,10 @@ class TopicQuery
|
|||
create_list(:latest, {}, latest_results)
|
||||
end
|
||||
|
||||
def list_search
|
||||
create_list(:latest, {}, latest_results)
|
||||
end
|
||||
|
||||
def list_read
|
||||
create_list(:read, unordered: true) do |topics|
|
||||
topics.order('COALESCE(tu.last_visited_at, topics.bumped_at) DESC')
|
||||
|
|
Loading…
Reference in New Issue
Block a user