From 4dcb29acbf79c2a848300118116644ab4298c3b2 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 19 Dec 2016 14:06:19 -0500 Subject: [PATCH] UX: Show Back button above mobile progress widget --- .../discourse/components/topic-progress.js.es6 | 11 +++++++++++ .../templates/components/topic-progress.hbs | 6 ++++++ .../javascripts/discourse/templates/topic.hbs | 3 ++- .../discourse/widgets/topic-timeline.js.es6 | 2 +- app/assets/stylesheets/mobile/topic.scss | 15 ++++++++++++++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-progress.js.es6 b/app/assets/javascripts/discourse/components/topic-progress.js.es6 index 938c7085494..8321d70148c 100644 --- a/app/assets/javascripts/discourse/components/topic-progress.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-progress.js.es6 @@ -37,6 +37,13 @@ export default Ember.Component.extend({ } }, + @computed('progressPosition', 'topic.last_read_post_id') + showBackButton(position, lastReadId) { + if (!this.site.mobileView || !lastReadId) { return; } + const readPos = this.get('postStream.stream').indexOf(lastReadId) || 0; + return readPos > position; + }, + @observes('postStream.stream.[]') _updateBar() { Ember.run.scheduleOnce('afterRender', this, this._updateProgressBar); @@ -140,6 +147,10 @@ export default Ember.Component.extend({ actions: { toggleExpansion() { this.toggleProperty('expanded'); + }, + + goBack() { + this.attrs.jumpToPost(this.get('topic.last_read_post_number')); } }, diff --git a/app/assets/javascripts/discourse/templates/components/topic-progress.hbs b/app/assets/javascripts/discourse/templates/components/topic-progress.hbs index a64af643e7b..797e12f0738 100644 --- a/app/assets/javascripts/discourse/templates/components/topic-progress.hbs +++ b/app/assets/javascripts/discourse/templates/components/topic-progress.hbs @@ -1,3 +1,9 @@ +{{#if showBackButton}} +
+ {{d-button label="topic.timeline.back" class="btn-primary progress-back" action="goBack"}} +
+{{/if}} +