From 35e6e5ff677e40304d3624de88147cda5b7b82f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 5 Aug 2015 16:14:26 +0200 Subject: [PATCH] FIX: footer was missing in some pages - error pages - search results pages - list of all tags - topics list of a specific tag - user leaderboard --- .../controllers/full-page-search.js.es6 | 51 ++++++++------ .../discourse/controllers/users.js.es6 | 21 +++--- .../discourse/models/topic-list.js.es6 | 1 - .../discourse/routes/application.js.es6 | 4 +- .../discourse/routes/exception.js.es6 | 9 ++- .../discourse/routes/full-page-search.js.es6 | 23 +++--- .../javascripts/discourse/routes/users.js.es6 | 17 +++-- .../discourse/templates/full-page-search.hbs | 70 +++++++++---------- .../discourse/views/full-page-search.js.es6 | 6 +- app/views/layouts/crawler.html.erb | 2 +- app/views/layouts/no_ember.html.erb | 5 +- 11 files changed, 120 insertions(+), 89 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index a763a94c3db..4f3c38b6291 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -1,32 +1,39 @@ -import DiscourseController from 'discourse/controllers/controller'; -import { translateResults } from 'discourse/lib/search-for-term'; +import DiscourseController from "discourse/controllers/controller"; +import { translateResults } from "discourse/lib/search-for-term"; export default DiscourseController.extend({ - loading: Em.computed.not('model'), - queryParams: ['q'], + needs: ["application"], + + loading: Em.computed.not("model"), + queryParams: ["q"], q: null, - modelChanged: function(){ - if (this.get('searchTerm') !== this.get('q')) { - this.set('searchTerm', this.get('q')); - } - }.observes('model'), - qChanged: function(){ - var model = this.get('model'); - if (model && this.get('model.q') !== this.get('q')){ - this.set('searchTerm', this.get('q')); - this.send('search'); + modelChanged: function() { + if (this.get("searchTerm") !== this.get("q")) { + this.set("searchTerm", this.get("q")); } - }.observes('q'), + }.observes("model"), + + qChanged: function() { + const model = this.get("model"); + if (model && this.get("model.q") !== this.get("q")) { + this.set("searchTerm", this.get("q")); + this.send("search"); + } + }.observes("q"), + + _showFooter: function() { + this.set("controllers.application.showFooter", !this.get("loading")); + }.observes("loading"), + actions: { - search: function(){ - var self = this; - this.set('q', this.get('searchTerm')); - this.set('model', null); + search() { + this.set("q", this.get("searchTerm")); + this.set("model", null); - Discourse.ajax('/search', {data: {q: this.get('searchTerm')}}).then(function(results) { - self.set('model', translateResults(results) || {}); - self.set('model.q', self.get('q')); + Discourse.ajax("/search", { data: { q: this.get("searchTerm") } }).then(results => { + this.set("model", translateResults(results) || {}); + this.set("model.q", this.get("q")); }); } } diff --git a/app/assets/javascripts/discourse/controllers/users.js.es6 b/app/assets/javascripts/discourse/controllers/users.js.es6 index 8ff6e6e498d..8705fb850ba 100644 --- a/app/assets/javascripts/discourse/controllers/users.js.es6 +++ b/app/assets/javascripts/discourse/controllers/users.js.es6 @@ -1,19 +1,24 @@ export default Ember.Controller.extend({ - queryParams: ['period', 'order', 'asc', 'name'], - period: 'weekly', - order: 'likes_received', + needs: ["application"], + queryParams: ["period", "order", "asc", "name"], + period: "weekly", + order: "likes_received", asc: null, - name: '', + name: "", - showTimeRead: Ember.computed.equal('period', 'all'), + showTimeRead: Ember.computed.equal("period", "all"), _setName: Discourse.debounce(function() { - this.set('name', this.get('nameInput')); - }, 500).observes('nameInput'), + this.set("name", this.get("nameInput")); + }, 500).observes("nameInput"), + + _showFooter: function() { + this.set("controllers.application.showFooter", !this.get("model.canLoadMore")); + }.observes("model.canLoadMore"), actions: { loadMore() { - this.get('model').loadMore(); + this.get("model").loadMore(); } } }); diff --git a/app/assets/javascripts/discourse/models/topic-list.js.es6 b/app/assets/javascripts/discourse/models/topic-list.js.es6 index d685b2f60cb..782cb9fd066 100644 --- a/app/assets/javascripts/discourse/models/topic-list.js.es6 +++ b/app/assets/javascripts/discourse/models/topic-list.js.es6 @@ -1,7 +1,6 @@ import RestModel from 'discourse/models/rest'; import Model from 'discourse/models/model'; - function topicsFrom(result, store) { if (!result) { return; } diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index b2c58f4fc8f..f0af569b02a 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -53,7 +53,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { error(err, transition) { if (err.status === 404) { // 404 - this.intermediateTransitionTo('unknown'); + this.transitionTo('unknown'); return; } @@ -74,7 +74,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { } exceptionController.setProperties({ lastTransition: transition, thrown: err }); - this.intermediateTransitionTo('exception'); + this.transitionTo('exception'); }, showLogin: unlessReadOnly('handleShowLogin'), diff --git a/app/assets/javascripts/discourse/routes/exception.js.es6 b/app/assets/javascripts/discourse/routes/exception.js.es6 index d20795d0289..2c911a989d4 100644 --- a/app/assets/javascripts/discourse/routes/exception.js.es6 +++ b/app/assets/javascripts/discourse/routes/exception.js.es6 @@ -1,3 +1,10 @@ export default Discourse.Route.extend({ - serialize() { return ""; } + serialize() { return ""; }, + + actions: { + didTransition() { + this.controllerFor("application").set("showFooter", true); + return true; + } + } }); diff --git a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 index b092136ee51..482ebf1fc50 100644 --- a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 @@ -1,18 +1,23 @@ -import { translateResults } from 'discourse/lib/search-for-term'; +import { translateResults } from "discourse/lib/search-for-term"; export default Discourse.Route.extend({ - queryParams: { - q: { - } - }, - model: function(params) { + queryParams: { q: {} }, + + model(params) { return PreloadStore.getAndRemove("search", function() { - return Discourse.ajax('/search', {data: {q: params.q}}); - }).then(function(results){ - var model = translateResults(results) || {}; + return Discourse.ajax("/search", { data: { q: params.q } }); + }).then(results => { + const model = translateResults(results) || {}; model.q = params.q; return model; }); + }, + + actions: { + didTransition() { + this.controllerFor("full-page-search")._showFooter(); + return true; + } } }); diff --git a/app/assets/javascripts/discourse/routes/users.js.es6 b/app/assets/javascripts/discourse/routes/users.js.es6 index e9d516543f3..beb25276fcc 100644 --- a/app/assets/javascripts/discourse/routes/users.js.es6 +++ b/app/assets/javascripts/discourse/routes/users.js.es6 @@ -9,16 +9,16 @@ export default Discourse.Route.extend({ refreshQueryWithoutTransition: true, titleToken() { - return I18n.t('directory.title'); + return I18n.t("directory.title"); }, resetController(controller, isExiting) { if (isExiting) { controller.setProperties({ - period: 'weekly', - order: 'likes_received', + period: "weekly", + order: "likes_received", asc: null, - name: '' + name: "" }); } }, @@ -26,11 +26,18 @@ export default Discourse.Route.extend({ model(params) { // If we refresh via `refreshModel` set the old model to loading this._params = params; - return this.store.find('directoryItem', params); + return this.store.find("directoryItem", params); }, setupController(controller, model) { const params = this._params; controller.setProperties({ model, period: params.period, nameInput: params.name }); + }, + + actions: { + didTransition() { + this.controllerFor("users")._showFooter(); + return true; + } } }); diff --git a/app/assets/javascripts/discourse/templates/full-page-search.hbs b/app/assets/javascripts/discourse/templates/full-page-search.hbs index 848215c73ed..9ea1d65ca3c 100644 --- a/app/assets/javascripts/discourse/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/templates/full-page-search.hbs @@ -1,45 +1,45 @@ {{#conditional-loading-spinner condition=loading}} -{{#unless model.posts}} -

{{i18n "search.no_results"}} {{i18n "search.search_help"}} -

-{{/unless}} + {{#unless model.posts}} +

+ {{i18n "search.no_results"}} {{i18n "search.search_help"}} +

+ {{/unless}} -{{#each model.posts as |result|}} -
-
- {{avatar result imageSize="tiny"}} - - {{topic-status topic=result.topic disableActions=true}}{{unbound result.topic.title}} - {{category-link result.topic.category}} -
-
- - {{format-age result.created_at}} - {{#if result.blurb}} - - - {{/if}} - - {{#if result.blurb}} - {{#highlight-text highlight=controller.q}} - {{{unbound result.blurb}}} - {{/highlight-text}} - {{/if}} -
-
-{{/each}} + {{#each model.posts as |result|}} +
+
+ {{avatar result imageSize="tiny"}} + + {{topic-status topic=result.topic disableActions=true}}{{unbound result.topic.title}} + {{category-link result.topic.category}} +
+
+ + {{format-age result.created_at}} + {{#if result.blurb}} + - + {{/if}} + + {{#if result.blurb}} + {{#highlight-text highlight=controller.q}} + {{{unbound result.blurb}}} + {{/highlight-text}} + {{/if}} +
+
+ {{/each}} -{{#if model.posts}} - -{{/if}} + {{#if model.posts}} + + {{/if}} {{/conditional-loading-spinner}} - diff --git a/app/assets/javascripts/discourse/views/full-page-search.js.es6 b/app/assets/javascripts/discourse/views/full-page-search.js.es6 index b05aa16848b..98225e4f79b 100644 --- a/app/assets/javascripts/discourse/views/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/views/full-page-search.js.es6 @@ -1,5 +1,3 @@ -import ScrollTop from 'discourse/mixins/scroll-top'; +import ScrollTop from "discourse/mixins/scroll-top"; -export default Ember.View.extend(ScrollTop, { - -}); +export default Ember.View.extend(ScrollTop, {}); diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index 2786a25422b..e68f58beb2a 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -16,7 +16,7 @@ <%- unless customization_disabled? %> - <%= SiteCustomization.custom_header(session[:preview_style]) %> + <%= SiteCustomization.custom_header(session[:preview_style], mobile_view? ? :mobile : :desktop) %> <%- end %>
"> diff --git a/app/views/layouts/no_ember.html.erb b/app/views/layouts/no_ember.html.erb index 019c83f801b..fe12e2df93e 100644 --- a/app/views/layouts/no_ember.html.erb +++ b/app/views/layouts/no_ember.html.erb @@ -16,7 +16,7 @@ <%- unless customization_disabled? %> - <%= SiteCustomization.custom_header(session[:preview_style]) %> + <%= SiteCustomization.custom_header(session[:preview_style], mobile_view? ? :mobile : :desktop) %> <%- end %>
<%= render partial: 'header' %> @@ -24,5 +24,8 @@ <%= yield %>
+ <%- unless customization_disabled? %> + <%= SiteCustomization.custom_footer(session[:preview_style], mobile_view? ? :mobile : :desktop) %> + <%- end %>