Custom messages for the footers of all list views

This commit is contained in:
Robin Ward 2013-02-19 17:38:58 -05:00
parent 28dc08e7ef
commit a1f8dcebd1
5 changed files with 53 additions and 26 deletions

View File

@ -4,6 +4,10 @@ Discourse.ListTopicsController = Ember.ObjectController.extend
# If we're changing our channel # If we're changing our channel
previousChannel: null previousChannel: null
popular: (->
@get('content.filter') is 'popular'
).property('content.filter')
filterModeChanged: (-> filterModeChanged: (->
# Unsubscribe from a previous channel if necessary # Unsubscribe from a previous channel if necessary
if previousChannel = @get('previousChannel') if previousChannel = @get('previousChannel')
@ -36,6 +40,10 @@ Discourse.ListTopicsController = Ember.ObjectController.extend
topic.toggleStar() topic.toggleStar()
false false
createTopic: ->
@get('controllers.list').createTopic()
false
observer: (-> observer: (->
@set('filterMode', @get('controllser.list.filterMode')) @set('filterMode', @get('controllser.list.filterMode'))
).observes('controller.list.filterMode') ).observes('controller.list.filterMode')

View File

@ -1,15 +1,5 @@
window.Discourse.TopicList = Discourse.Model.extend 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: -> loadMoreTopics: ->
promise = new RSVP.Promise() promise = new RSVP.Promise()
if moreUrl = @get('more_topics_url') if moreUrl = @get('more_topics_url')

View File

@ -1,7 +1,7 @@
{{#unless controller.loading}} {{#unless controller.loading}}
{{#if content.loaded}} {{#if content.loaded}}
<div class='contents'> <div class='contents'>
{{#unless content.emptyListTip}} {{#if content.topics.length}}
<table id='topic-list' {{bindAttr class="controller.category:filter-category"}}> <table id='topic-list' {{bindAttr class="controller.category:filter-category"}}>
<thead> <thead>
<tr> <tr>
@ -42,11 +42,7 @@
{{/group}} {{/group}}
</table> </table>
{{else}} {{/if}}
<p class='empty-topic-list'>
{{content.emptyListTip}}
</p>
{{/unless}}
</div> </div>
<footer id='topic-list-bottom'> <footer id='topic-list-bottom'>
@ -55,9 +51,18 @@
{{/if}} {{/if}}
</footer> </footer>
<h3>
{{view.footerMessage}}
{{#if view.allLoaded}} {{#if view.allLoaded}}
<h3>{{{i18n topics.footer}}}</h3> {{#if controller.popular}}
{{#if view.canCreateTopic}}
<a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
{{/if}} {{/if}}
{{else}}
{{#linkTo list.categories}}{{i18n topic.browse_all_categories}}{{/linkTo}} {{i18n or}} {{#linkTo list.popular}}{{i18n topic.view_popular_topics}}{{/linkTo}}
{{/if}}
{{/if}}
</h3>
{{/if}} {{/if}}
{{/unless}} {{/unless}}

View File

@ -2,6 +2,7 @@ window.Discourse.ListTopicsView = Ember.View.extend Discourse.Scrolling, Discour
templateName: 'list/topics' templateName: 'list/topics'
categoryBinding: 'Discourse.router.listController.category' categoryBinding: 'Discourse.router.listController.category'
filterModeBinding: 'Discourse.router.listController.filterMode' filterModeBinding: 'Discourse.router.listController.filterMode'
canCreateTopicBinding: 'controller.controllers.list.canCreateTopic'
insertedCount: (-> insertedCount: (->
inserted = @get('controller.inserted') inserted = @get('controller.inserted')
@ -52,3 +53,15 @@ window.Discourse.ListTopicsView = Ember.View.extend Discourse.Scrolling, Discour
scrolled: (e) -> scrolled: (e) ->
@saveScrollPos() @saveScrollPos()
@get('eyeline')?.update() @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')

View File

@ -23,6 +23,7 @@ en:
faq: "FAQ" faq: "FAQ"
you: "You" you: "You"
ok: "ok" ok: "ok"
or: "or"
suggested_topics: suggested_topics:
title: "Suggested Topics" title: "Suggested Topics"
@ -309,13 +310,22 @@ en:
help: 'add this topic to your favorites list' help: 'add this topic to your favorites list'
topics: topics:
no_favorited: "You haven't favorited any topics yet. To favorite a topic, click or tap the star next to the title." none:
no_unread: "You have no unread topics to read." favorited: "You haven't favorited any topics yet. To favorite a topic, click or tap the star next to the title."
no_new: "You have no new topics to read." unread: "You have no unread topics to read."
no_read: "You haven't read any topics yet." new: "You have no new topics to read."
no_posted: "You haven't posted in any topics yet." read: "You haven't read any topics yet."
no_popular: "There are no popular topics. That's sad." posted: "You haven't posted in any topics yet."
footer: "No more topics in this category. <a href=\"/categories\">Browse all categories</a> or <a href=\"/\">view popular topics</a>" 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: topic:
create_in: 'Create {{categoryName}} Topic' create_in: 'Create {{categoryName}} Topic'
@ -342,6 +352,7 @@ en:
read_more: "Want to read more? {{catLink}} or {{popularLink}}." read_more: "Want to read more? {{catLink}} or {{popularLink}}."
browse_all_categories: Browse all categories browse_all_categories: Browse all categories
view_popular_topics: view popular topics view_popular_topics: view popular topics
suggest_create_topic: Why not create a topic?
progress: progress:
title: topic progress title: topic progress