Navigating should set a searchContext (unused right now).
This commit is contained in:
parent
eb0c102931
commit
84fd366322
|
@ -24,6 +24,7 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, {
|
||||||
searchTerm: Discourse.debouncePromise(function(term, typeFilter) {
|
searchTerm: Discourse.debouncePromise(function(term, typeFilter) {
|
||||||
var searchController = this;
|
var searchController = this;
|
||||||
this.set('count', 0);
|
this.set('count', 0);
|
||||||
|
|
||||||
return Discourse.Search.forTerm(term, typeFilter).then(function(results) {
|
return Discourse.Search.forTerm(term, typeFilter).then(function(results) {
|
||||||
searchController.set('results', results);
|
searchController.set('results', results);
|
||||||
if (results) {
|
if (results) {
|
||||||
|
|
|
@ -38,8 +38,23 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
||||||
listController.set('category', category);
|
listController.set('category', category);
|
||||||
router.controllerFor('listTopics').set('content', topicList);
|
router.controllerFor('listTopics').set('content', topicList);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
activate: function() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
// Add a search context
|
||||||
|
this.controllerFor('search').set('searchContext', this.modelFor('listCategory'));
|
||||||
|
},
|
||||||
|
|
||||||
|
deactivate: function() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
// Clear the search context
|
||||||
|
this.controllerFor('search').set('searchContext', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,22 @@ Discourse.TopicRoute = Discourse.Route.extend({
|
||||||
return Discourse.Topic.create(params);
|
return Discourse.Topic.create(params);
|
||||||
},
|
},
|
||||||
|
|
||||||
enter: function() {
|
activate: function() {
|
||||||
Discourse.set('transient.lastTopicIdViewed', parseInt(this.modelFor('topic').get('id'), 10));
|
this._super();
|
||||||
|
|
||||||
|
var topic = this.modelFor('topic');
|
||||||
|
Discourse.set('transient.lastTopicIdViewed', parseInt(topic.get('id'), 10));
|
||||||
|
|
||||||
|
// Set the search context
|
||||||
|
this.controllerFor('search').set('searchContext', topic);
|
||||||
},
|
},
|
||||||
|
|
||||||
exit: function() {
|
deactivate: function() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
// Clear the search context
|
||||||
|
this.controllerFor('search').set('searchContext', null);
|
||||||
|
|
||||||
var headerController, topicController;
|
var headerController, topicController;
|
||||||
topicController = this.controllerFor('topic');
|
topicController = this.controllerFor('topic');
|
||||||
topicController.cancelFilter();
|
topicController.cancelFilter();
|
||||||
|
|
|
@ -26,11 +26,17 @@ Discourse.UserRoute = Discourse.Route.extend({
|
||||||
Discourse.MessageBus.subscribe("/users/" + user.get('username_lower'), function(data) {
|
Discourse.MessageBus.subscribe("/users/" + user.get('username_lower'), function(data) {
|
||||||
user.loadUserAction(data);
|
user.loadUserAction(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add a search context
|
||||||
|
this.controllerFor('search').set('searchContext', user);
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
this._super();
|
this._super();
|
||||||
Discourse.MessageBus.unsubscribe("/users/" + this.modelFor('user').get('username_lower'));
|
Discourse.MessageBus.unsubscribe("/users/" + this.modelFor('user').get('username_lower'));
|
||||||
|
|
||||||
|
// Remove the search context
|
||||||
|
this.controllerFor('search').set('searchContext', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue