diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 index 0fff6219a69..1e23c9154a0 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 @@ -8,7 +8,6 @@ export default DiscoveryController.extend({ actions: { refresh: function() { - var self = this; // Don't refresh if we're still loading if (this.get('controllers.discovery.loading')) { return; } @@ -17,7 +16,17 @@ export default DiscoveryController.extend({ // router and ember throws an error due to missing `handlerInfos`. // Lesson learned: Don't call `loading` yourself. this.set('controllers.discovery.loading', true); - Discourse.CategoryList.list('categories').then(function(list) { + + var parentCategory = this.get('model.parentCategory'); + var promise; + if (parentCategory) { + promise = Discourse.CategoryList.listForParent(parentCategory); + } else { + promise = Discourse.CategoryList.list(); + } + + var self = this; + promise.then(function(list) { self.set('model', list); self.send('loadingComplete'); }); diff --git a/app/assets/javascripts/discourse/models/category_list.js b/app/assets/javascripts/discourse/models/category_list.js index ee8b08c1583..bd1e1711fb3 100644 --- a/app/assets/javascripts/discourse/models/category_list.js +++ b/app/assets/javascripts/discourse/models/category_list.js @@ -1,11 +1,3 @@ -/** - A data model for containing a list of categories - - @class CategoryList - @extends Discourse.Model - @namespace Discourse - @module Discourse -**/ Discourse.CategoryList = Ember.ArrayProxy.extend({ init: function() { this.set('content', []); @@ -50,7 +42,8 @@ Discourse.CategoryList.reopenClass({ var self = this; return Discourse.ajax('/categories.json?parent_category_id=' + category.get('id')).then(function(result) { return Discourse.CategoryList.create({ - categories: self.categoriesFrom(result) + categories: self.categoriesFrom(result), + parentCategory: category }); }); }, diff --git a/app/assets/javascripts/discourse/templates/discovery/categories.hbs b/app/assets/javascripts/discourse/templates/discovery/categories.hbs index 691b4d04738..c3055c93b66 100644 --- a/app/assets/javascripts/discourse/templates/discovery/categories.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/categories.hbs @@ -10,71 +10,71 @@ {{#each c in categories}} - - -
-
- {{category-title-link category=c}} - {{#if c.unreadTopics}} - {{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}} - {{/if}} - {{#if c.newTopics}} - {{i18n 'filters.new.lower_title_with_count' count=c.newTopics}} - {{/if}} -
-
-
- {{#if c.description_excerpt}} -
- {{{c.description_excerpt}}} -
- {{/if}} - {{#if c.subcategories}} -
- {{#each s in c.subcategories}} - {{category-link s showParent="true" onlyStripe="true"}} - {{#if s.unreadTopics}} - {{unbound s.unreadTopics}} + + +
+
+ {{category-title-link category=c}} + {{#if c.unreadTopics}} + {{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}} {{/if}} - {{#if s.newTopics}} - {{unbound s.newTopics}} + {{#if c.newTopics}} + {{i18n 'filters.new.lower_title_with_count' count=c.newTopics}} {{/if}} - {{/each}} +
+
- {{/if}} - - - {{#each f in c.featuredTopics}} -