Work in progress, full page search

This commit is contained in:
Sam
2015-06-22 18:09:08 +10:00
parent b3e583faf3
commit 41e427bd2e
15 changed files with 108 additions and 18 deletions
@@ -7,7 +7,8 @@ export var queryParams = {
status: { replace: true },
state: { replace: true },
search: { replace: true },
max_posts: { replace: true }
max_posts: { replace: true },
q: { replace: true }
};
// Basic controller options
@@ -16,6 +16,8 @@ var controllerOpts = {
expandGloballyPinned: false,
expandAllPinned: false,
isSearch: Em.computed.equal('model.filter', 'search'),
actions: {
changeSort: function(sortBy) {
@@ -13,13 +13,13 @@ export default DiscourseController.extend({
isSearch: Em.computed.equal('filterMode', 'search'),
searchTerm: Em.computed.alias('controllers.discovery/topics.model.params.search'),
searchTerm: Em.computed.alias('controllers.discovery/topics.model.params.q'),
actions: {
search: function(){
var discovery = this.get('controllers.discovery/topics');
var model = discovery.get('model');
discovery.set('search', this.get("searchTerm"));
discovery.set('q', this.get("searchTerm"));
model.refreshSort();
}
}
@@ -2,5 +2,6 @@ import registerUnbound from 'discourse/helpers/register-unbound';
registerUnbound('topic-link', function(topic) {
var title = topic.get('fancyTitle');
return new Handlebars.SafeString("<a href='" + topic.get('lastUnreadUrl') + "' class='title'>" + title + "</a>");
var url = topic.linked_post_number ? topic.urlForPostNumber(topic.linked_post_number) : topic.get('lastUnreadUrl');
return new Handlebars.SafeString("<a href='" + url + "' class='title'>" + title + "</a>");
});
@@ -40,8 +40,8 @@ const TopicList = RestModel.extend({
},
refreshSort: function(order, ascending) {
const self = this,
params = this.get('params') || {};
const self = this;
var params = this.get('params') || {};
params.order = order || params.order;
@@ -51,6 +51,11 @@ const TopicList = RestModel.extend({
params.ascending = ascending;
}
if (params.q) {
// search is unique, nothing else allowed with it
params = {q: params.q};
}
this.set('loaded', false);
const store = this.store;
store.findFiltered('topicList', {filter: this.get('filter'), params}).then(function(tl) {
@@ -363,8 +363,7 @@ const Topic = RestModel.extend({
);
},
excerptNotEmpty: Em.computed.notEmpty('excerpt'),
hasExcerpt: Em.computed.and('pinned', 'excerptNotEmpty'),
hasExcerpt: Em.computed.notEmpty('excerpt'),
excerptTruncated: function() {
const e = this.get('excerpt');
@@ -3,7 +3,9 @@
{{topic-list
showParticipants=showParticipants
hideCategory=hideCategory
topics=topics}}
topics=topics
expandExcerpts=expandExcerpts
}}
{{else}}
<div class='alert alert-info'>
{{i18n 'choose_topic.none_found'}}
@@ -46,6 +46,7 @@
selected=selected
expandGloballyPinned=expandGloballyPinned
expandAllPinned=expandAllPinned
expandExcerpts=isSearch
topics=model.topics}}
{{/if}}
</div>
@@ -65,6 +65,10 @@ export default Discourse.View.extend(StringBuffer, {
},
expandPinned: function() {
if (this.get('controller.expandExcerpts')) {
return true;
}
const pinned = this.get('topic.pinned');
if (!pinned) {
return false;