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