From 0841cd2ba6ef988c08439ccf10f81079d1ea5d73 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 18 Aug 2014 16:17:35 -0400 Subject: [PATCH] FEATURE: Add education text to new and unread pages when there are no results --- .../controllers/discovery/topics.js.es6 | 12 +++++++++++ .../templates/discovery/topics.js.handlebars | 20 +++++++++++------- .../mobile/discovery/topics.js.handlebars | 21 ++++++++++++------- config/locales/client.en.yml | 3 +++ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 index 6869f88f4a..8bde80be30 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 @@ -145,6 +145,18 @@ var controllerOpts = { } }.property('allLoaded', 'topics.length'), + footerEducation: function() { + if (!this.get('allLoaded') || this.get('topics.length') > 0 || !Discourse.User.current()) { return; } + + var split = this.get('filter').split('/'); + + if (split[0] !== 'new' && split[0] !== 'unread') { return; } + + return I18n.t("topics.none.educate." + split[0], { + userPrefsUrl: Discourse.getURL("/users/") + (Discourse.User.currentProp("username_lower")) + "/preferences" + }); + }.property('allLoaded', 'topics.length'), + loadMoreTopics: function() { return this.get('model').loadMore(); } diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars index e7f620ed4a..cee89c8b8a 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars @@ -91,21 +91,27 @@ {{/if}} -

- {{#if latest}} + {{#if latest}} + {{{footerEducation}}} +

{{footerMessage}} {{#if can_create_topic}}{{i18n topic.suggest_create_topic}}{{/if}} - {{else}} - {{#if top}} +

+ {{else}} + {{#if top}} +

{{#link-to "discovery.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}}, {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}} {{i18n or}} {{i18n filters.top.other_periods}} {{#unless yearly}}{{i18n filters.top.this_year}}{{/unless}} {{#unless monthly}}{{i18n filters.top.this_month}}{{/unless}} {{#unless weekly}}{{i18n filters.top.this_week}}{{/unless}} {{#unless daily}}{{i18n filters.top.today}}{{/unless}} - {{else}} +

+ {{else}} + {{{footerEducation}}} +

{{footerMessage}}{{#link-to "discovery.categories"}} {{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}} - {{/if}} +

{{/if}} - + {{/if}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars b/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars index ae08623ad3..9864db826f 100644 --- a/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars @@ -36,21 +36,28 @@ {{#if showResetNew}} {{/if}} -

- {{#if latest}} + + {{#if latest}} + {{{footerEducation}}} +

{{footerMessage}} {{#if can_create_topic}}{{i18n topic.suggest_create_topic}}{{/if}} - {{else}} - {{#if top}} +

+ {{else}} + {{#if top}} +

{{#link-to "discovery.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}}, {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}} {{i18n or}} {{i18n filters.top.other_periods}} {{#unless yearly}}{{i18n filters.top.this_year}}{{/unless}} {{#unless monthly}}{{i18n filters.top.this_month}}{{/unless}} {{#unless weekly}}{{i18n filters.top.this_week}}{{/unless}} {{#unless daily}}{{i18n filters.top.today}}{{/unless}} - {{else}} +

+ {{else}} + {{{footerEducation}}} +

{{footerMessage}}{{#link-to "discovery.categories"}} {{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}} - {{/if}} +

{{/if}} - + {{/if}} {{/if}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 257b1a42ee..d150f7f466 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -769,6 +769,9 @@ en: hot: "There are no hot topics." category: "There are no {{category}} topics." top: "There are no top topics." + educate: + new: '

Your preferences define which topics are considered new.

' + unread: "

You have read all of the posts in the topics you are tracking or watching.

" bottom: latest: "There are no more latest topics." hot: "There are no more hot topics."