From a1f8dcebd1027c45f178b2ea11e8f5336293e95b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 19 Feb 2013 17:38:58 -0500 Subject: [PATCH] Custom messages for the footers of all list views --- .../list_topics_controller.js.coffee | 8 ++++++ .../discourse/models/topic_list.js.coffee | 10 -------- .../templates/list/topics.js.handlebars | 23 ++++++++++------- .../views/list/list_topics_view.js.coffee | 13 ++++++++++ config/locales/client.en.yml | 25 +++++++++++++------ 5 files changed, 53 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/list_topics_controller.js.coffee b/app/assets/javascripts/discourse/controllers/list_topics_controller.js.coffee index 98b589273bb..228bf415bca 100644 --- a/app/assets/javascripts/discourse/controllers/list_topics_controller.js.coffee +++ b/app/assets/javascripts/discourse/controllers/list_topics_controller.js.coffee @@ -4,6 +4,10 @@ Discourse.ListTopicsController = Ember.ObjectController.extend # If we're changing our channel previousChannel: null + popular: (-> + @get('content.filter') is 'popular' + ).property('content.filter') + filterModeChanged: (-> # Unsubscribe from a previous channel if necessary if previousChannel = @get('previousChannel') @@ -36,6 +40,10 @@ Discourse.ListTopicsController = Ember.ObjectController.extend topic.toggleStar() false + createTopic: -> + @get('controllers.list').createTopic() + false + observer: (-> @set('filterMode', @get('controllser.list.filterMode')) ).observes('controller.list.filterMode') diff --git a/app/assets/javascripts/discourse/models/topic_list.js.coffee b/app/assets/javascripts/discourse/models/topic_list.js.coffee index 6e9edbefa8b..59ee26c70da 100644 --- a/app/assets/javascripts/discourse/models/topic_list.js.coffee +++ b/app/assets/javascripts/discourse/models/topic_list.js.coffee @@ -1,15 +1,5 @@ window.Discourse.TopicList = Discourse.Model.extend - emptyListTip: (-> - return null unless @get('loaded') - - t = @get('topics') - return null if t && t.length > 0 - - Em.String.i18n('topics.no_' + @get('filter')) - ).property('topics', 'topics@each', 'filter', 'loaded') - - loadMoreTopics: -> promise = new RSVP.Promise() if moreUrl = @get('more_topics_url') diff --git a/app/assets/javascripts/discourse/templates/list/topics.js.handlebars b/app/assets/javascripts/discourse/templates/list/topics.js.handlebars index 49aaccef160..44c0be22897 100644 --- a/app/assets/javascripts/discourse/templates/list/topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/list/topics.js.handlebars @@ -1,7 +1,7 @@ {{#unless controller.loading}} {{#if content.loaded}}
- {{#unless content.emptyListTip}} + {{#if content.topics.length}} @@ -42,11 +42,7 @@ {{/group}}
- {{else}} -

- {{content.emptyListTip}} -

- {{/unless}} + {{/if}}
- {{#if view.allLoaded}} -

{{{i18n topics.footer}}}

- {{/if}} +

+ {{view.footerMessage}} + {{#if view.allLoaded}} + {{#if controller.popular}} + {{#if view.canCreateTopic}} + {{i18n topic.suggest_create_topic}} + {{/if}} + {{else}} + {{#linkTo list.categories}}{{i18n topic.browse_all_categories}}{{/linkTo}} {{i18n or}} {{#linkTo list.popular}}{{i18n topic.view_popular_topics}}{{/linkTo}} + {{/if}} + {{/if}} +

{{/if}} {{/unless}} diff --git a/app/assets/javascripts/discourse/views/list/list_topics_view.js.coffee b/app/assets/javascripts/discourse/views/list/list_topics_view.js.coffee index cd50ddebf20..3a571df2a54 100644 --- a/app/assets/javascripts/discourse/views/list/list_topics_view.js.coffee +++ b/app/assets/javascripts/discourse/views/list/list_topics_view.js.coffee @@ -2,6 +2,7 @@ window.Discourse.ListTopicsView = Ember.View.extend Discourse.Scrolling, Discour templateName: 'list/topics' categoryBinding: 'Discourse.router.listController.category' filterModeBinding: 'Discourse.router.listController.filterMode' + canCreateTopicBinding: 'controller.controllers.list.canCreateTopic' insertedCount: (-> inserted = @get('controller.inserted') @@ -52,3 +53,15 @@ window.Discourse.ListTopicsView = Ember.View.extend Discourse.Scrolling, Discour scrolled: (e) -> @saveScrollPos() @get('eyeline')?.update() + + footerMessage: (-> + return unless @get('allLoaded') + + content = @get('controller.content') + if content.get('topics.length') == 0 + Em.String.i18n("topics.none.#{content.get('filter')}") + else + Em.String.i18n("topics.bottom.#{content.get('filter')}") + + ).property('allLoaded', 'controller.content.topics.length') + diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 46e7ee46153..aab3410930a 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -23,6 +23,7 @@ en: faq: "FAQ" you: "You" ok: "ok" + or: "or" suggested_topics: title: "Suggested Topics" @@ -309,13 +310,22 @@ en: help: 'add this topic to your favorites list' topics: - no_favorited: "You haven't favorited any topics yet. To favorite a topic, click or tap the star next to the title." - no_unread: "You have no unread topics to read." - no_new: "You have no new topics to read." - no_read: "You haven't read any topics yet." - no_posted: "You haven't posted in any topics yet." - no_popular: "There are no popular topics. That's sad." - footer: "No more topics in this category. Browse all categories or view popular topics" + none: + favorited: "You haven't favorited any topics yet. To favorite a topic, click or tap the star next to the title." + unread: "You have no unread topics to read." + new: "You have no new topics to read." + read: "You haven't read any topics yet." + posted: "You haven't posted in any topics yet." + popular: "There are no popular topics. That's sad." + bottom: + popular: "There are no more popular topics to read." + posted: "There are no more posted topics to read." + read: "There are no more read topics to read." + new: "There are no more new topics to read." + unread: "There are no more unread topics to read." + favorited: "There are no more favorited topics to read." + + topic: create_in: 'Create {{categoryName}} Topic' @@ -342,6 +352,7 @@ en: read_more: "Want to read more? {{catLink}} or {{popularLink}}." browse_all_categories: Browse all categories view_popular_topics: view popular topics + suggest_create_topic: Why not create a topic? progress: title: topic progress