From 8c882fd3924289422f0efb07d03b042ba6f1ee97 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 28 Oct 2013 15:34:38 -0400 Subject: [PATCH] Changed breadcrumb dropdowns --- .../discourse/components/breadcrumbs_component.js | 12 ++++++++---- .../discourse/components/categorydrop_component.js | 11 +++++++++++ app/assets/javascripts/discourse/models/category.js | 2 +- .../components/discourse-breadcrumbs.js.handlebars | 10 ++++------ .../components/discourse-categorydrop.js.handlebars | 5 +++-- .../discourse/templates/list.js.handlebars | 4 +--- app/assets/stylesheets/desktop/topic-list.scss | 4 ++-- app/assets/stylesheets/mobile/topic-list.scss | 4 ++-- config/locales/client.en.yml | 2 ++ 9 files changed, 34 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/discourse/components/breadcrumbs_component.js b/app/assets/javascripts/discourse/components/breadcrumbs_component.js index 1f4d900942e..d1efb82aef8 100644 --- a/app/assets/javascripts/discourse/components/breadcrumbs_component.js +++ b/app/assets/javascripts/discourse/components/breadcrumbs_component.js @@ -7,16 +7,20 @@ Discourse.DiscourseBreadcrumbsComponent = Ember.Component.extend({ return !c.get('parentCategory'); }), - targetCategory: function() { - // Note we can't use Em.computed.or here because it returns a boolean not the object + firstCategory: function() { return this.get('parentCategory') || this.get('category'); }.property('parentCategory', 'category'), + secondCategory: function() { + if (this.get('parentCategory')) return this.get('category'); + return null; + }.property('category', 'parentCategory'), + childCategories: function() { var self = this; return this.get('categories').filter(function (c) { - return c.get('parentCategory') === self.get('targetCategory'); + return c.get('parentCategory') === self.get('firstCategory'); }); - }.property('targetCategory') + }.property('firstCategory') }); diff --git a/app/assets/javascripts/discourse/components/categorydrop_component.js b/app/assets/javascripts/discourse/components/categorydrop_component.js index 0eb45d09951..cc1ef418a44 100644 --- a/app/assets/javascripts/discourse/components/categorydrop_component.js +++ b/app/assets/javascripts/discourse/components/categorydrop_component.js @@ -7,6 +7,17 @@ Discourse.DiscourseCategorydropComponent = Ember.Component.extend({ return "icon icon-caret-right"; }.property('expanded'), + allCategoriesUrl: function() { + return this.get('category.parentCategory.url') || "/"; + }.property('category'), + + allCategoriesLabel: function() { + if (this.get('subCategory')) { + return I18n.t('categories.all_subcategories'); + } + return I18n.t('categories.all'); + }.property('category'), + badgeStyle: function() { var category = this.get('category'); if (category) { diff --git a/app/assets/javascripts/discourse/models/category.js b/app/assets/javascripts/discourse/models/category.js index dc75876c55c..afd286cf8ec 100644 --- a/app/assets/javascripts/discourse/models/category.js +++ b/app/assets/javascripts/discourse/models/category.js @@ -31,7 +31,7 @@ Discourse.Category = Discourse.Model.extend({ }.property('id'), url: function() { - return Discourse.getURL("/category/") + (this.get('slug')); + return Discourse.getURL("/category/") + Discourse.Category.slugFor(this); }.property('name'), unreadUrl: function() { diff --git a/app/assets/javascripts/discourse/templates/components/discourse-breadcrumbs.js.handlebars b/app/assets/javascripts/discourse/templates/components/discourse-breadcrumbs.js.handlebars index a67132bf284..a25f303fc21 100644 --- a/app/assets/javascripts/discourse/templates/components/discourse-breadcrumbs.js.handlebars +++ b/app/assets/javascripts/discourse/templates/components/discourse-breadcrumbs.js.handlebars @@ -1,12 +1,10 @@
  • -{{discourse-categorydrop parentCategory=category categories=parentCategories}} +{{discourse-categorydrop category=firstCategory categories=parentCategories}}
  • -
  • - {{discourse-categorydrop parentCategory=category category=targetCategory categories=childCategories}} -
  • -{{#if parentCategory}} + +{{#if childCategories}}
  • - {{boundCategoryLink category}} + {{discourse-categorydrop category=secondCategory categories=childCategories subCategory="true"}}
  • {{/if}} diff --git a/app/assets/javascripts/discourse/templates/components/discourse-categorydrop.js.handlebars b/app/assets/javascripts/discourse/templates/components/discourse-categorydrop.js.handlebars index c7431539092..c3b09e9cc7f 100644 --- a/app/assets/javascripts/discourse/templates/components/discourse-categorydrop.js.handlebars +++ b/app/assets/javascripts/discourse/templates/components/discourse-categorydrop.js.handlebars @@ -1,12 +1,13 @@ {{#if category}} - {{boundCategoryLink category allowUncategorized=true}} + {{category.name}} {{else}} - + {{allCategoriesLabel}} {{/if}} {{#if categories}}
    + {{#each categories}}
    {{categoryLink this allowUncategorized=true}}
    {{/each}}
    {{/if}} diff --git a/app/assets/javascripts/discourse/templates/list.js.handlebars b/app/assets/javascripts/discourse/templates/list.js.handlebars index ab0c79b242f..929844a99a7 100644 --- a/app/assets/javascripts/discourse/templates/list.js.handlebars +++ b/app/assets/javascripts/discourse/templates/list.js.handlebars @@ -1,9 +1,7 @@
    - {{#if category}} - {{discourse-breadcrumbs category=category categories=categories}} - {{/if}} + {{discourse-breadcrumbs category=category categories=categories}}