implemented UI for filtered down by category view

This commit is contained in:
Sam 2013-10-25 14:18:34 +11:00
parent 572f036e74
commit a65407b2cb
14 changed files with 157 additions and 109 deletions

View File

@ -22,7 +22,7 @@ Discourse.ListController = Discourse.Controller.extend({
category: category category: category
}); });
}).filter(function(i) { }).filter(function(i) {
return i !== null && !(category && i.get("name") === "categories"); return i !== null && !(category && i.get("name").indexOf("categor") === 0);
}); });
}.property("category"), }.property("category"),
@ -134,7 +134,11 @@ Discourse.ListController = Discourse.Controller.extend({
} else { } else {
return false; return false;
} }
}.property('category') }.property('category'),
categories: function() {
return Discourse.Category.list();
}.property()
}); });

View File

@ -34,6 +34,13 @@ Discourse.Category = Discourse.Model.extend({
return Discourse.getURL("/category/") + (this.get('slug')); return Discourse.getURL("/category/") + (this.get('slug'));
}.property('name'), }.property('name'),
unreadUrl: function() {
return this.get('url') + '/unread';
}.property('url'),
newUrl: function() {
return this.get('url') + '/new';
}.property('url'),
style: function() { style: function() {
return "background-color: #" + (this.get('category.color')) + "; color: #" + (this.get('category.text_color')) + ";"; return "background-color: #" + (this.get('category.color')) + "; color: #" + (this.get('category.text_color')) + ";";

View File

@ -31,11 +31,21 @@ Discourse.NavItem = Discourse.Model.extend({
// href from this item // href from this item
href: function() { href: function() {
return Discourse.getURL("/") + this.get('filterMode');
}.property('filterMode'),
// href from this item
filterMode: function() {
var name = this.get('name'); var name = this.get('name');
if( name.split('/')[0] === 'category' ) { if( name.split('/')[0] === 'category' ) {
return Discourse.getURL("/") + 'category/' + this.get('categorySlug'); return 'category/' + this.get('categorySlug');
} else { } else {
return Discourse.getURL("/") + name.replace(' ', '-'); var mode = "";
var category = this.get("category");
if(category){
mode += "category/" + category.get("slug") + "/";
}
return mode + name.replace(' ', '-');
} }
}.property('name'), }.property('name'),

View File

@ -146,7 +146,6 @@ Discourse.TopicList.reopenClass({
return Ember.RSVP.resolve(list); return Ember.RSVP.resolve(list);
} }
session.setProperties({topicList: null, topicListScrollPos: null}); session.setProperties({topicList: null, topicListScrollPos: null});
return Discourse.TopicList.find(filter, menuItem.get('excludeCategory')); return Discourse.TopicList.find(filter, menuItem.get('excludeCategory'));
} }
}); });

View File

@ -22,11 +22,14 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
} }
var listController = this.controllerFor('list'), var listController = this.controllerFor('list'),
urlId = Discourse.Category.slugFor(category), categorySlug = Discourse.Category.slugFor(category),
self = this; self = this;
listController.set('filterMode', "category/" + urlId); var filter = this.filter || "latest";
listController.load("category/" + urlId).then(function(topicList) { var url = "category/" + categorySlug + "/" + filter;
listController.set('filterMode', url);
listController.load(url).then(function(topicList) {
listController.setProperties({ listController.setProperties({
canCreateTopic: topicList.get('can_create_topic'), canCreateTopic: topicList.get('can_create_topic'),
category: category category: category

View File

@ -1,7 +1,7 @@
{{#if category}} {{#if category}}
{{categoryLink category}} {{categoryLink category}}
{{else}} {{else}}
<a href="/">{{title}}</a> <a href="/"><i class='icon icon-home'></i></a>
{{/if}} {{/if}}
{{#if categories}} {{#if categories}}

View File

@ -1,5 +1,10 @@
<div id='list-controls'> <div class='list-controls'>
<div class="container"> <div class="container">
{{#if category}}
{{discourse-breadcrumbs category=category categories=categories}}
{{/if}}
<ul class="nav nav-pills" id='category-filter'> <ul class="nav nav-pills" id='category-filter'>
{{each availableNavItems itemViewClass="Discourse.NavItemView"}} {{each availableNavItems itemViewClass="Discourse.NavItemView"}}
</ul> </ul>

View File

@ -41,9 +41,11 @@
{{/if}} {{/if}}
</td> </td>
{{#unless controller.category}}
<td class='category'> <td class='category'>
{{categoryLink category}} {{categoryLink category}}
</td> </td>
{{/unless}}
<td class='posters'> <td class='posters'>
{{#each posters}} {{#each posters}}

View File

@ -10,10 +10,6 @@
</button> </button>
{{/if}} {{/if}}
{{#if category}}
{{discourse-breadcrumbs title=Discourse.SiteSettings.title category=category categories=categories}}
{{/if}}
<table id='topic-list'> <table id='topic-list'>
<thead> <thead>
<tr> <tr>
@ -23,7 +19,9 @@
<th class='main-link'> <th class='main-link'>
{{i18n topic.title}} {{i18n topic.title}}
</th> </th>
{{#unless category}}
<th class='category'>{{i18n category_title}}</th> <th class='category'>{{i18n category_title}}</th>
{{/unless}}
<th class='posters'>{{i18n top_contributors}}</th> <th class='posters'>{{i18n top_contributors}}</th>
<th class='num posts'>{{i18n posts}}</th> <th class='num posts'>{{i18n posts}}</th>
<th class='num likes'>{{i18n likes}}</th> <th class='num likes'>{{i18n likes}}</th>

View File

@ -22,10 +22,10 @@
{{/if}} {{/if}}
{{categoryLink this allowUncategorized=true}} {{categoryLink this allowUncategorized=true}}
{{#if unreadTopics}} {{#if unreadTopics}}
<a href={{unbound url}} class='badge new-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unbound unreadTopics}}</a> <a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unbound unreadTopics}}</a>
{{/if}} {{/if}}
{{#if newTopics}} {{#if newTopics}}
<a href={{unbound url}} class='badge new-posts badge-notification' title='{{i18n topic.new_topics count="newTopics"}}'>{{unbound newTopics}} <i class='icon icon-asterisk'></i></a> <a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n topic.new_topics count="newTopics"}}'>{{unbound newTopics}} <i class='icon icon-asterisk'></i></a>
{{/if}} {{/if}}
<div class='featured-users'> <div class='featured-users'>
{{#each featured_users}} {{#each featured_users}}

View File

@ -14,7 +14,7 @@ Discourse.NavItemView = Discourse.View.extend({
hidden: Em.computed.not('content.visible'), hidden: Em.computed.not('content.visible'),
count: Ember.computed.alias('content.count'), count: Ember.computed.alias('content.count'),
shouldRerender: Discourse.View.renderIfChanged('count'), shouldRerender: Discourse.View.renderIfChanged('count'),
active: Discourse.computed.propertyEqual('contentNameSlug', 'controller.filterMode'), active: Discourse.computed.propertyEqual('content.filterMode', 'controller.filterMode'),
title: function() { title: function() {
var categoryName, extra, name; var categoryName, extra, name;
@ -27,13 +27,6 @@ Discourse.NavItemView = Discourse.View.extend({
return I18n.t("filters." + name + ".help", extra); return I18n.t("filters." + name + ".help", extra);
}.property("content.filter"), }.property("content.filter"),
contentNameSlug: function() {
return this.get("content.name").toLowerCase().replace(' ','-');
}.property('content.name'),
// active: function() {
// return (this.get("contentNameSlug") === this.get("controller.filterMode"));
// }.property("contentNameSlug", "controller.filterMode"),
name: function() { name: function() {
var categoryName, extra, name; var categoryName, extra, name;

View File

@ -8,7 +8,7 @@
// List controls // List controls
// -------------------------------------------------- // --------------------------------------------------
#list-controls { .list-controls {
.nav { .nav {
float: left; float: left;
margin-bottom: 15px; margin-bottom: 15px;
@ -349,8 +349,7 @@
// Misc. stuff // Misc. stuff
// -------------------------------------------------- // --------------------------------------------------
#main { .list-controls {
#list-controls {
.badge-category { .badge-category {
display: inline-block; display: inline-block;
background-color: yellow; background-color: yellow;
@ -358,8 +357,8 @@
float: left; float: left;
} }
clear: both; clear: both;
} }
#list-area { #list-area {
margin-bottom: 300px; margin-bottom: 300px;
@ -378,8 +377,8 @@
font-size: 13px; font-size: 13px;
cursor: default; cursor: default;
} }
} }
#topic-list { #topic-list {
.alert { .alert {
margin-bottom: 0; margin-bottom: 0;
font-size: 14px; font-size: 14px;
@ -387,8 +386,8 @@
.spinner { .spinner {
margin-top: 40px; margin-top: 40px;
} }
} }
span.posted { span.posted {
display: inline-block; display: inline-block;
text-indent: -9999em; text-indent: -9999em;
width: 15px; width: 15px;
@ -396,5 +395,4 @@
background: { background: {
image: image-url("posted.png"); image: image-url("posted.png");
}; };
}
} }

View File

@ -199,17 +199,20 @@ i {background: #e4f2f8;
} }
ol.category-breadcrumb { ol.category-breadcrumb {
display: block;
float: left;
list-style: none; list-style: none;
margin: 0 0 10px 0; margin: 0 10px 0 0;
padding: 0; padding: 0;
li { li {
float: left; float: left;
margin-right: 5px; margin-right: 5px;
border: 1px solid transparent; border: 1px solid transparent;
line-height: 31px;
&.no-category { &.no-category {
font-size: 13px; font-size: 22px;
a { a {
margin-right: 3px; margin-right: 3px;
@ -243,7 +246,9 @@ ol.category-breadcrumb {
.badge-category { .badge-category {
margin: 0; margin: 0;
display: inline-block; display: inline-block;
padding: 1px 6px 2px 6px; font-size: 14px;
padding: 0px 10px;
float: none;
} }
button { button {
@ -286,6 +291,12 @@ ol.category-breadcrumb {
padding: 8px 5px 0 7px; padding: 8px 5px 0 7px;
z-index: 100; z-index: 100;
.badge-category {
font-size: 13px;
line-height: 26px;
padding: 0px 8px;
}
div { div {
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@ -8,7 +8,7 @@
// List controls // List controls
// -------------------------------------------------- // --------------------------------------------------
#list-controls { .list-controls {
margin: 5px; margin: 5px;
.nav { .nav {
float: left; float: left;
@ -239,8 +239,7 @@
// Misc. stuff // Misc. stuff
// -------------------------------------------------- // --------------------------------------------------
#main { .list-controls {
#list-controls {
.badge-category { .badge-category {
display: inline-block; display: inline-block;
background-color: yellow; background-color: yellow;
@ -248,8 +247,8 @@
float: left; float: left;
} }
clear: both; clear: both;
} }
#list-area { #list-area {
margin-bottom: 300px; margin-bottom: 300px;
.empty-topic-list { .empty-topic-list {
padding: 10px; padding: 10px;
@ -262,8 +261,8 @@
font-size: 13px; font-size: 13px;
cursor: default; cursor: default;
} }
} }
#topic-list { #topic-list {
.alert { .alert {
margin-bottom: 0; margin-bottom: 0;
font-size: 14px; font-size: 14px;
@ -271,8 +270,8 @@
.spinner { .spinner {
margin-top: 40px; margin-top: 40px;
} }
} }
span.posted { span.posted {
display: inline-block; display: inline-block;
text-indent: -9999em; text-indent: -9999em;
width: 15px; width: 15px;
@ -280,7 +279,6 @@
background: { background: {
image: image-url("posted.png"); image: image-url("posted.png");
}; };
}
} }
@ -364,3 +362,23 @@ clear: both;
opacity: 1; opacity: 1;
} }
ol.category-breadcrumb {
display: block;
margin-top: 5px;
float: left;
list-style: none;
.icon-home {
font-size: 20px;
}
.badge-category {
margin: 3px 8px 0;
}
button {
padding: 5px 10px;
font-size: 16px;
}
li {
float: left;
}
}