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
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')

View File

@ -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')

View File

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

View File

@ -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')

View File

@ -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. <a href=\"/categories\">Browse all categories</a> or <a href=\"/\">view popular topics</a>"
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