work-in-progress full page search

This commit is contained in:
Sam 2015-04-02 16:02:07 +11:00
parent 2843224e80
commit 4dbd065026
8 changed files with 48 additions and 6 deletions

View File

@ -1,11 +1,25 @@
import DiscourseController from 'discourse/controllers/controller'; import DiscourseController from 'discourse/controllers/controller';
export default DiscourseController.extend({ export default DiscourseController.extend({
needs: ['discovery', 'discovery/topics'],
categories: function() { categories: function() {
return Discourse.Category.list(); return Discourse.Category.list();
}.property(), }.property(),
navItems: function() { navItems: function() {
return Discourse.NavItem.buildList(); return Discourse.NavItem.buildList(null, {filterMode: this.get('filterMode')});
}.property() }.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();
}
}
}); });

View File

@ -84,7 +84,15 @@ Discourse.NavItem.reopenClass({
args = args || {}; args = args || {};
if (category) { args.category = category } 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); return Discourse.NavItem.fromText(i, args);
}).filter(function(i) { }).filter(function(i) {
return i !== null && !(category && i.get("name").indexOf("categor") === 0); return i !== null && !(category && i.get("name").indexOf("categor") === 0);

View File

@ -41,8 +41,8 @@ Discourse.TopicList = Discourse.Model.extend({
var self = this, var self = this,
params = this.get('params'); params = this.get('params');
params.order = order; params.order = order || params.order;
params.ascending = ascending; params.ascending = ascending || params.ascending || true;
this.set('loaded', false); this.set('loaded', false);
var finder = finderFor(this.get('filter'), params); var finder = finderFor(this.get('filter'), params);

View File

@ -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}} {{bread-crumbs categories=categories}}
<ul class="nav nav-pills" id='navigation-bar'> <ul class="nav nav-pills" id='navigation-bar'>
@ -10,3 +16,4 @@
{{#if canCreateTopic}} {{#if canCreateTopic}}
<button id="create-topic" class='btn btn-default' {{action "createTopic"}}><i class='fa fa-plus'></i>{{i18n 'topic.create'}}</button> <button id="create-topic" class='btn btn-default' {{action "createTopic"}}><i class='fa fa-plus'></i>{{i18n 'topic.create'}}</button>
{{/if}} {{/if}}
{{/if}}

View File

@ -19,6 +19,11 @@
font-weight: normal; font-weight: normal;
} }
.search .btn {
float: none;
}
a.badge-category { a.badge-category {
padding: 3px 12px; padding: 3px 12px;
font-size: 1.143em; font-size: 1.143em;

View File

@ -867,6 +867,7 @@ en:
category: "There are no more {{category}} topics." category: "There are no more {{category}} topics."
top: "There are no more top topics." top: "There are no more top topics."
bookmarks: "There are no more bookmarked topics." bookmarks: "There are no more bookmarked topics."
search: "There are no more search results."
topic: topic:
filter_to: "{{post_count}} posts in topic" filter_to: "{{post_count}} posts in topic"
@ -1497,6 +1498,9 @@ en:
read: read:
title: "Read" title: "Read"
help: "topics you've read, in the order that you last read them" help: "topics you've read, in the order that you last read them"
search:
title: "Search"
help: "search all topics"
categories: categories:
title: "Categories" title: "Categories"
title_in: "Category - {{categoryName}}" title_in: "Category - {{categoryName}}"

View File

@ -56,7 +56,7 @@ module Discourse
class CSRF < StandardError; end class CSRF < StandardError; end
def self.filters def self.filters
@filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks] @filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks, :search]
end end
def self.feed_filters def self.feed_filters

View File

@ -70,6 +70,10 @@ class TopicQuery
create_list(:latest, {}, latest_results) create_list(:latest, {}, latest_results)
end end
def list_search
create_list(:latest, {}, latest_results)
end
def list_read def list_read
create_list(:read, unordered: true) do |topics| create_list(:read, unordered: true) do |topics|
topics.order('COALESCE(tu.last_visited_at, topics.bumped_at) DESC') topics.order('COALESCE(tu.last_visited_at, topics.bumped_at) DESC')