FIX: Hide topics list when loading new topics by category
This commit is contained in:
parent
f47240483c
commit
1715220d77
|
@ -30,37 +30,40 @@ Discourse.ListController = Discourse.Controller.extend({
|
|||
});
|
||||
}).property('filterSummary'),
|
||||
|
||||
/**
|
||||
Load a list based on a filter
|
||||
|
||||
@method load
|
||||
@param {String} filterMode the filter we want to load
|
||||
@returns {Ember.Deferred} the promise that will resolve to the list of items.
|
||||
**/
|
||||
load: function(filterMode) {
|
||||
var current,
|
||||
_this = this;
|
||||
var listController = this;
|
||||
this.set('loading', true);
|
||||
|
||||
if (filterMode === 'categories') {
|
||||
return Ember.Deferred.promise(function(deferred) {
|
||||
return Discourse.CategoryList.list(filterMode).then(function(items) {
|
||||
_this.set('loading', false);
|
||||
_this.set('filterMode', filterMode);
|
||||
_this.set('categoryMode', true);
|
||||
Discourse.CategoryList.list(filterMode).then(function(items) {
|
||||
listController.set('loading', false);
|
||||
listController.set('filterMode', filterMode);
|
||||
listController.set('categoryMode', true);
|
||||
return deferred.resolve(items);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
current = (this.get('availableNavItems').filter(function(f) {
|
||||
return f.name === filterMode;
|
||||
}))[0];
|
||||
}
|
||||
|
||||
var current = (this.get('availableNavItems').filter(function(f) { return f.name === filterMode; }))[0];
|
||||
if (!current) {
|
||||
current = Discourse.NavItem.create({
|
||||
name: filterMode
|
||||
});
|
||||
current = Discourse.NavItem.create({ name: filterMode });
|
||||
}
|
||||
return Ember.Deferred.promise(function(deferred) {
|
||||
return Discourse.TopicList.list(current).then(function(items) {
|
||||
_this.set('filterSummary', items.filter_summary);
|
||||
_this.set('filterMode', filterMode);
|
||||
_this.set('loading', false);
|
||||
Discourse.TopicList.list(current).then(function(items) {
|
||||
listController.set('filterSummary', items.filter_summary);
|
||||
listController.set('filterMode', filterMode);
|
||||
listController.set('loading', false);
|
||||
return deferred.resolve(items);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Put in the appropriate page title based on our view
|
||||
|
|
|
@ -25,14 +25,15 @@ Discourse.FilteredListRoute = Discourse.Route.extend({
|
|||
},
|
||||
|
||||
setupController: function() {
|
||||
var listController, listTopicsController, _ref,
|
||||
_this = this;
|
||||
listController = this.controllerFor('list');
|
||||
listTopicsController = this.controllerFor('listTopics');
|
||||
var listController = this.controllerFor('list');
|
||||
var listTopicsController = this.controllerFor('listTopics');
|
||||
listController.set('filterMode', this.filter);
|
||||
if (_ref = listTopicsController.get('content')) {
|
||||
_ref.set('loaded', false);
|
||||
|
||||
var listContent = listTopicsController.get('content');
|
||||
if (listContent) {
|
||||
listContent.set('loaded', false);
|
||||
}
|
||||
|
||||
listController.load(this.filter).then(function(topicList) {
|
||||
listController.set('category', null);
|
||||
listController.set('canCreateTopic', topicList.get('can_create_topic'));
|
||||
|
|
|
@ -9,26 +9,34 @@
|
|||
Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
||||
|
||||
setupController: function(controller, model) {
|
||||
var category, listController, slug, urlId,
|
||||
_this = this;
|
||||
slug = Em.get(model, 'slug');
|
||||
category = Discourse.get('site.categories').findProperty('slug', slug);
|
||||
var slug = Em.get(model, 'slug');
|
||||
var category = Discourse.get('site.categories').findProperty('slug', slug);
|
||||
|
||||
if (!category) {
|
||||
category = Discourse.get('site.categories').findProperty('id', parseInt(slug, 10));
|
||||
}
|
||||
|
||||
if (!category) {
|
||||
category = Discourse.Category.create({ name: slug, slug: slug });
|
||||
}
|
||||
|
||||
listController = this.controllerFor('list');
|
||||
urlId = Discourse.Utilities.categoryUrlId(category);
|
||||
var listTopicsController = this.controllerFor('listTopics');
|
||||
if (listTopicsController) {
|
||||
var listContent = listTopicsController.get('content');
|
||||
if (listContent) {
|
||||
listContent.set('loaded', false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var listController = this.controllerFor('list');
|
||||
var urlId = Discourse.Utilities.categoryUrlId(category);
|
||||
listController.set('filterMode', "category/" + urlId);
|
||||
|
||||
var router = this;
|
||||
listController.load("category/" + urlId).then(function(topicList) {
|
||||
listController.set('canCreateTopic', topicList.get('can_create_topic'));
|
||||
listController.set('category', category);
|
||||
_this.controllerFor('listTopics').set('content', topicList);
|
||||
router.controllerFor('listTopics').set('content', topicList);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue