From 5a7ae8c63fbdec4d16adaac183f5c9f9202f5de2 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 24 Feb 2015 12:56:06 -0500 Subject: [PATCH] Clicking on the date of a featured topic should show topic entrance --- .../components/featured-topic.js.es6 | 11 ++++++++++ .../controllers/discovery/categories.js.es6 | 15 ++++++-------- .../templates/components/featured-topic.hbs | 13 ++++++++++++ .../templates/discovery/categories.hbs | 20 +++---------------- 4 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 app/assets/javascripts/discourse/components/featured-topic.js.es6 create mode 100644 app/assets/javascripts/discourse/templates/components/featured-topic.hbs diff --git a/app/assets/javascripts/discourse/components/featured-topic.js.es6 b/app/assets/javascripts/discourse/components/featured-topic.js.es6 new file mode 100644 index 00000000000..def196f7a1d --- /dev/null +++ b/app/assets/javascripts/discourse/components/featured-topic.js.es6 @@ -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; + } + } +}); diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 index 1e23c9154a0..37078d492dd 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 @@ -7,7 +7,8 @@ export default DiscoveryController.extend({ showPostsColumn: Em.computed.empty('withLogo'), actions: { - refresh: function() { + + refresh() { // Don't refresh if we're still loading if (this.get('controllers.discovery.loading')) { return; } @@ -17,15 +18,11 @@ export default DiscoveryController.extend({ // Lesson learned: Don't call `loading` yourself. this.set('controllers.discovery.loading', true); - var parentCategory = this.get('model.parentCategory'); - var promise; - if (parentCategory) { - promise = Discourse.CategoryList.listForParent(parentCategory); - } else { - promise = Discourse.CategoryList.list(); - } + const parentCategory = this.get('model.parentCategory'); + const promise = parentCategory ? Discourse.CategoryList.listForParent(parentCategory) : + Discourse.CategoryList.list(); - var self = this; + const self = this; promise.then(function(list) { self.set('model', list); self.send('loadingComplete'); diff --git a/app/assets/javascripts/discourse/templates/components/featured-topic.hbs b/app/assets/javascripts/discourse/templates/components/featured-topic.hbs new file mode 100644 index 00000000000..e0475953014 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/featured-topic.hbs @@ -0,0 +1,13 @@ +{{topic-status topic=topic}} +{{{unbound topic.fancy_title}}} +{{topic-post-badges newPosts=topic.totalUnread unseen=topic.unseen url=topic.lastUnreadUrl}} + +{{#if latestTopicOnly}} +
+ {{i18n 'categories.latest_by'}} {{unbound topic.last_poster.username}} + {{format-age topic.last_posted_at}} +
+{{else}} +   + {{format-age topic.last_posted_at}} +{{/if}} diff --git a/app/assets/javascripts/discourse/templates/discovery/categories.hbs b/app/assets/javascripts/discourse/templates/discovery/categories.hbs index 192cc7a77d1..2612f25f5b2 100644 --- a/app/assets/javascripts/discourse/templates/discovery/categories.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/categories.hbs @@ -16,10 +16,10 @@
{{category-title-link category=c}} {{#if c.unreadTopics}} - {{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}} + {{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}} {{/if}} {{#if c.newTopics}} - {{i18n 'filters.new.lower_title_with_count' count=c.newTopics}} + {{i18n 'filters.new.lower_title_with_count' count=c.newTopics}} {{/if}}
@@ -45,21 +45,7 @@ {{#each f in c.featuredTopics}} - + {{featured-topic topic=f latestTopicOnly=latestTopicOnly action="showTopicEntrance"}} {{/each}}