diff --git a/app/assets/javascripts/discourse/components/categorydrop_component.js b/app/assets/javascripts/discourse/components/categorydrop_component.js index 12e992d437f..5401794c029 100644 --- a/app/assets/javascripts/discourse/components/categorydrop_component.js +++ b/app/assets/javascripts/discourse/components/categorydrop_component.js @@ -16,12 +16,20 @@ Discourse.CategoryDropComponent = Ember.Component.extend({ }.property('expanded'), allCategoriesUrl: function() { - return this.get('category.parentCategory.url') || "/"; - }.property('category'), + if (this.get('subCategory')) { + return this.get('parentCategory.url') || "/"; + } else { + return "/"; + } + }.property('parentCategory.url', 'subCategory'), + + noCategoriesUrl: function() { + return this.get('parentCategory.url') + "/none"; + }.property('parentCategory.url'), allCategoriesLabel: function() { if (this.get('subCategory')) { - return I18n.t('categories.only_category', {categoryName: this.get('parentCategory.name')}); + return I18n.t('categories.all_subcategories', {categoryName: this.get('parentCategory.name')}); } return I18n.t('categories.all'); }.property('category'), diff --git a/app/assets/javascripts/discourse/controllers/list_controller.js b/app/assets/javascripts/discourse/controllers/list_controller.js index 64701102927..02d3158ec7c 100644 --- a/app/assets/javascripts/discourse/controllers/list_controller.js +++ b/app/assets/javascripts/discourse/controllers/list_controller.js @@ -43,9 +43,10 @@ Discourse.ListController = Discourse.Controller.extend({ @method load @param {String} filterMode the filter we want to load + @param {Object} params for additional filtering @returns {Ember.Deferred} the promise that will resolve to the list of items. **/ - load: function(filterMode) { + load: function(filterMode, params) { var self = this; this.set('loading', true); @@ -74,13 +75,15 @@ Discourse.ListController = Discourse.Controller.extend({ current = Discourse.NavItem.create({ name: filterMode }); } - return Discourse.TopicList.list(current).then(function(items) { + params = params || {}; + return Discourse.TopicList.list(current, params).then(function(items) { self.setProperties({ loading: false, filterMode: filterMode, draft: items.draft, draft_key: items.draft_key, - draft_sequence: items.draft_sequence + draft_sequence: items.draft_sequence, + noSubcategories: params.no_subcategories }); if(trackingState) { trackingState.sync(items, filterMode); diff --git a/app/assets/javascripts/discourse/models/category.js b/app/assets/javascripts/discourse/models/category.js index fb944c4f344..592040e0858 100644 --- a/app/assets/javascripts/discourse/models/category.js +++ b/app/assets/javascripts/discourse/models/category.js @@ -202,6 +202,8 @@ Discourse.Category.reopenClass({ if (parentSlug) { var parentCategory = Discourse.Category.findSingleBySlug(parentSlug); if (parentCategory) { + if (slug === 'none') { return parentCategory; } + category = categories.find(function(item) { return item && item.get('parentCategory') === parentCategory && Discourse.Category.slugFor(item) === (parentSlug + "/" + slug); }); diff --git a/app/assets/javascripts/discourse/models/topic_list.js b/app/assets/javascripts/discourse/models/topic_list.js index 4844842c44b..7fcbe5f0437 100644 --- a/app/assets/javascripts/discourse/models/topic_list.js +++ b/app/assets/javascripts/discourse/models/topic_list.js @@ -8,6 +8,7 @@ **/ function finderFor(filter, params) { + return function() { var url = Discourse.getURL("/") + filter + ".json"; @@ -185,9 +186,10 @@ Discourse.TopicList.reopenClass({ @method list @param {Object} The menu item to filter to + @param {Object} Any additional params @returns {Promise} a promise that resolves to the list of topics **/ - list: function(menuItem) { + list: function(menuItem, params) { var filter = menuItem.get('name'), session = Discourse.Session.current(), list = session.get('topicList'); @@ -197,11 +199,12 @@ Discourse.TopicList.reopenClass({ return Ember.RSVP.resolve(list); } session.setProperties({topicList: null, topicListScrollPos: null}); - return Discourse.TopicList.find(filter, {exclude_category: menuItem.get('excludeCategory')}); + + var findParams = {exclude_category: menuItem.get('excludeCategory')}; + return Discourse.TopicList.find(filter, _.extend(findParams, params || {})); }, find: function(filter, params) { - return PreloadStore.getAndRemove("topic_list", finderFor(filter, params)).then(function(result) { var topicList = Discourse.TopicList.create({ inserted: Em.A(), diff --git a/app/assets/javascripts/discourse/routes/application_routes.js b/app/assets/javascripts/discourse/routes/application_routes.js index bc58a4e1165..4305e9e37c3 100644 --- a/app/assets/javascripts/discourse/routes/application_routes.js +++ b/app/assets/javascripts/discourse/routes/application_routes.js @@ -40,6 +40,8 @@ Discourse.Route.buildRoutes(function() { this.route('categories', { path: '/categories' }); this.route('category', { path: '/category/:slug' }); this.route('category', { path: '/category/:slug/more' }); + this.route('categoryNone', { path: '/category/:slug/none' }); + this.route('categoryNone', { path: '/category/:slug/none/more' }); this.route('category', { path: '/category/:parentSlug/:slug' }); this.route('category', { path: '/category/:parentSlug/:slug/more' }); }); diff --git a/app/assets/javascripts/discourse/routes/list_category_route.js b/app/assets/javascripts/discourse/routes/list_category_route.js index ec12d452da9..725ac110d0d 100644 --- a/app/assets/javascripts/discourse/routes/list_category_route.js +++ b/app/assets/javascripts/discourse/routes/list_category_route.js @@ -7,7 +7,6 @@ @module Discourse **/ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({ - model: function(params) { return Discourse.Category.findBySlug(Em.get(params, 'slug'), Em.get(params, 'parentSlug')); }, @@ -24,11 +23,16 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({ var listController = this.controllerFor('list'), categorySlug = Discourse.Category.slugFor(category), self = this, - filter = this.filter || "latest", - url = "category/" + categorySlug + "/l/" + filter; + filter = this.get('filter') || "latest", + url = "category/" + categorySlug + "/l/" + filter, + params = {}; + + if (this.get('noSubcategories')) { + params.no_subcategories = true; + } listController.setProperties({ filterMode: url, category: null }); - listController.load(url).then(function(topicList) { + listController.load(url, params).then(function(topicList) { listController.setProperties({ canCreateTopic: topicList.get('can_create_topic'), category: category @@ -52,13 +56,16 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({ // Clear the search context this.controllerFor('search').set('searchContext', null); } - - }); +Discourse.ListCategoryNoneRoute = Discourse.ListCategoryRoute.extend({ + noSubcategories: true +}); Discourse.ListController.filters.forEach(function(filter) { - Discourse["List" + (filter.capitalize()) + "CategoryRoute"] = Discourse.ListCategoryRoute.extend({ filter: filter }); + Discourse["List" + (filter.capitalize()) + "CategoryRoute"] = Discourse.ListCategoryRoute.extend({ + filter: filter + }); }); diff --git a/app/assets/javascripts/discourse/templates/components/bread-crumbs.js.handlebars b/app/assets/javascripts/discourse/templates/components/bread-crumbs.js.handlebars index 9804739fb02..3608f605a9d 100644 --- a/app/assets/javascripts/discourse/templates/components/bread-crumbs.js.handlebars +++ b/app/assets/javascripts/discourse/templates/components/bread-crumbs.js.handlebars @@ -1,10 +1,10 @@