Clicking on the date of a featured topic should show topic entrance

This commit is contained in:
Robin Ward 2015-02-24 12:56:06 -05:00
parent 7e2dd2463e
commit 5a7ae8c63f
4 changed files with 33 additions and 26 deletions

View File

@ -0,0 +1,11 @@
export default Ember.Component.extend({
classNameBindings: [':featured-topic'],
click(e) {
const $target = $(e.target);
if ($target.closest('.last-posted-at').length) {
this.sendAction('action', {topic: this.get('topic'), position: $target.offset()});
return false;
}
}
});

View File

@ -7,7 +7,8 @@ export default DiscoveryController.extend({
showPostsColumn: Em.computed.empty('withLogo'), showPostsColumn: Em.computed.empty('withLogo'),
actions: { actions: {
refresh: function() {
refresh() {
// Don't refresh if we're still loading // Don't refresh if we're still loading
if (this.get('controllers.discovery.loading')) { return; } if (this.get('controllers.discovery.loading')) { return; }
@ -17,15 +18,11 @@ export default DiscoveryController.extend({
// Lesson learned: Don't call `loading` yourself. // Lesson learned: Don't call `loading` yourself.
this.set('controllers.discovery.loading', true); this.set('controllers.discovery.loading', true);
var parentCategory = this.get('model.parentCategory'); const parentCategory = this.get('model.parentCategory');
var promise; const promise = parentCategory ? Discourse.CategoryList.listForParent(parentCategory) :
if (parentCategory) { Discourse.CategoryList.list();
promise = Discourse.CategoryList.listForParent(parentCategory);
} else {
promise = Discourse.CategoryList.list();
}
var self = this; const self = this;
promise.then(function(list) { promise.then(function(list) {
self.set('model', list); self.set('model', list);
self.send('loadingComplete'); self.send('loadingComplete');

View File

@ -0,0 +1,13 @@
{{topic-status topic=topic}}
<a class='title' href="{{unbound topic.lastUnreadUrl}}">{{{unbound topic.fancy_title}}}</a>
{{topic-post-badges newPosts=topic.totalUnread unseen=topic.unseen url=topic.lastUnreadUrl}}
{{#if latestTopicOnly}}
<div class='last-user-info'>
{{i18n 'categories.latest_by'}} <a href="{{{unbound topic.lastPosterUrl}}}">{{unbound topic.last_poster.username}}</a>
<a href="{{unbound topic.lastPostUrl}}">{{format-age topic.last_posted_at}}</a>
</div>
{{else}}
&nbsp;
<a href class="last-posted-at">{{format-age topic.last_posted_at}}</a>
{{/if}}

View File

@ -16,10 +16,10 @@
<div class="pull-left"> <div class="pull-left">
{{category-title-link category=c}} {{category-title-link category=c}}
{{#if c.unreadTopics}} {{#if c.unreadTopics}}
<a href={{unbound c.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=c.unreadTopics}}'>{{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}}</a> <a href="{{unbound c.unreadUrl}}" class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=c.unreadTopics}}'>{{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}}</a>
{{/if}} {{/if}}
{{#if c.newTopics}} {{#if c.newTopics}}
<a href={{unbound c.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=c.newTopics}}'>{{i18n 'filters.new.lower_title_with_count' count=c.newTopics}}</a> <a href="{{unbound c.newUrl}}" class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=c.newTopics}}'>{{i18n 'filters.new.lower_title_with_count' count=c.newTopics}}</a>
{{/if}} {{/if}}
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
@ -45,21 +45,7 @@
</td> </td>
<td {{bind-attr class="c.archived :latest"}}> <td {{bind-attr class="c.archived :latest"}}>
{{#each f in c.featuredTopics}} {{#each f in c.featuredTopics}}
<div class="featured-topic"> {{featured-topic topic=f latestTopicOnly=latestTopicOnly action="showTopicEntrance"}}
{{topic-status topic=f}}
<a class='title' href="{{unbound f.lastUnreadUrl}}">{{{unbound f.fancy_title}}}</a>
{{topic-post-badges newPosts=f.totalUnread unseen=f.unseen url=f.lastUnreadUrl}}
{{#if controller.latestTopicOnly}}
<div class='last-user-info'>
{{i18n 'categories.latest_by'}} <a href="{{{unbound f.lastPosterUrl}}}">{{unbound f.last_poster.username}}</a>
<a href="{{unbound f.lastPostUrl}}">{{format-age f.last_posted_at}}</a>
</div>
{{else}}
&nbsp;
<a href="{{unbound f.lastPostUrl}}" class="last-posted-at">{{format-age f.last_posted_at}}</a>
{{/if}}
</div>
{{/each}} {{/each}}
</td> </td>
<td class='stats' {{bind-attr title="c.topicStatsTitle"}}> <td class='stats' {{bind-attr title="c.topicStatsTitle"}}>