Navigating should set a searchContext (unused right now).

This commit is contained in:
Robin Ward 2013-05-23 18:51:40 -04:00
parent eb0c102931
commit 84fd366322
4 changed files with 36 additions and 3 deletions

View File

@ -24,6 +24,7 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, {
searchTerm: Discourse.debouncePromise(function(term, typeFilter) {
var searchController = this;
this.set('count', 0);
return Discourse.Search.forTerm(term, typeFilter).then(function(results) {
searchController.set('results', results);
if (results) {

View File

@ -38,8 +38,23 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
listController.set('category', category);
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);
}
});

View File

@ -18,11 +18,22 @@ Discourse.TopicRoute = Discourse.Route.extend({
return Discourse.Topic.create(params);
},
enter: function() {
Discourse.set('transient.lastTopicIdViewed', parseInt(this.modelFor('topic').get('id'), 10));
activate: function() {
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;
topicController = this.controllerFor('topic');
topicController.cancelFilter();

View File

@ -26,11 +26,17 @@ Discourse.UserRoute = Discourse.Route.extend({
Discourse.MessageBus.subscribe("/users/" + user.get('username_lower'), function(data) {
user.loadUserAction(data);
});
// Add a search context
this.controllerFor('search').set('searchContext', user);
},
deactivate: function() {
this._super();
Discourse.MessageBus.unsubscribe("/users/" + this.modelFor('user').get('username_lower'));
// Remove the search context
this.controllerFor('search').set('searchContext', null);
}