FIX: Categories pill wasn't always being highlighted properly.

This commit is contained in:
Robin Ward 2013-05-29 11:02:07 -04:00
parent df63045699
commit 5cb1cc6fcb
4 changed files with 21 additions and 30 deletions

View File

@ -17,7 +17,6 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
latest: Ember.computed.equal('content.filter', 'latest'),
filterModeChanged: function() {
// Unsubscribe from a previous channel if necessary
var previousChannel = this.get('previousChannel');
if (previousChannel) {

View File

@ -26,6 +26,7 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
this.controllerFor('list').setProperties({
canCreateCategory: categoryList.get('can_create_category'),
canCreateTopic: categoryList.get('can_create_topic'),
filterMode: 'categories',
category: null
});
}

View File

@ -1,9 +1,7 @@
<div id='list-controls'>
<div class="container">
<ul class="nav nav-pills" id='category-filter'>
{{#each availableNavItems}}
{{view Discourse.NavItemView contentBinding="this"}}
{{/each}}
{{each availableNavItems itemViewClass="Discourse.NavItemView"}}
</ul>
{{#if canCreateTopic}}

View File

@ -11,51 +11,44 @@ Discourse.NavItemView = Discourse.View.extend({
classNameBindings: ['isActive', 'content.hasIcon:has-icon'],
attributeBindings: ['title'],
title: (function() {
var categoryName, extra, name;
name = this.get('content.name');
categoryName = this.get('content.categoryName');
title: function() {
var name = this.get('content.name');
var categoryName = this.get('content.categoryName');
var extra;
if (categoryName) {
extra = {
categoryName: categoryName
};
extra = { categoryName: categoryName };
name = "category";
}
return Ember.String.i18n("filters." + name + ".help", extra);
}).property("content.filter"),
}.property("content.filter"),
isActive: (function() {
isActive: function() {
if (this.get("content.name").replace(' ','-') === this.get("controller.filterMode")) return "active";
return "";
}).property("content.name", "controller.filterMode"),
}.property("content.name", "controller.filterMode"),
hidden: (function() {
return !this.get('content.visible');
}).property('content.visible'),
hidden: Em.computed.not('content.visible'),
name: (function() {
var categoryName, extra, name;
name = this.get('content.name');
categoryName = this.get('content.categoryName');
extra = {
count: this.get('content.count') || 0
};
name: function() {
var name = this.get('content.name');
var categoryName = this.get('content.categoryName');
var extra = { count: this.get('content.count') || 0 };
if (categoryName) {
name = 'category';
extra.categoryName = categoryName.titleize();
}
return I18n.t("js.filters." + name + ".title", extra);
}).property('count'),
}.property('count'),
render: function(buffer) {
var content;
content = this.get('content');
buffer.push("<a href='" + (content.get('href')) + "'>");
var content = this.get('content');
buffer.push("<a href='" + content.get('href') + "'>");
if (content.get('hasIcon')) {
buffer.push("<span class='" + (content.get('name')) + "'></span>");
buffer.push("<span class='" + content.get('name') + "'></span>");
}
buffer.push(this.get('name'));
return buffer.push("</a>");
buffer.push("</a>");
}
});