From 229f1122744836c949ab1ca0453483490dc9be01 Mon Sep 17 00:00:00 2001 From: alisan617 Date: Wed, 28 Dec 2016 14:20:16 -0500 Subject: [PATCH] hide add a response button if 0 other responses --- .../js/discussion/views/discussion_thread_view.js | 10 ++++++++-- .../templates/discussion/thread-show.underscore | 2 +- .../common/templates/discussion/thread.underscore | 12 +++++++----- lms/static/sass/discussion/views/_response.scss | 3 ++- lms/static/sass/discussion/views/_thread.scss | 7 ++++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/common/static/common/js/discussion/views/discussion_thread_view.js b/common/static/common/js/discussion/views/discussion_thread_view.js index 5544e8fb52..e531523044 100644 --- a/common/static/common/js/discussion/views/discussion_thread_view.js +++ b/common/static/common/js/discussion/views/discussion_thread_view.js @@ -280,6 +280,9 @@ responseCountFormat = ngettext( '{numResponses} other response', '{numResponses} other responses', responseTotal ); + if (responseTotal === 0) { + this.$el.find('.response-count').hide(); + } } else { responseCountFormat = ngettext( '{numResponses} response', '{numResponses} responses', responseTotal @@ -288,6 +291,7 @@ this.$el.find('.response-count').text( edx.StringUtils.interpolate(responseCountFormat, {numResponses: responseTotal}, true) ); + responsePagination = this.$el.find('.response-pagination'); responsePagination.empty(); if (responseTotal > 0) { @@ -327,6 +331,8 @@ }); return responsePagination.append($loadMoreButton); } + } else { + this.$el.find('.add-response').hide(); } }; @@ -345,9 +351,9 @@ DiscussionThreadView.prototype.renderAddResponseButton = function() { if (this.model.hasResponses() && this.model.can('can_reply') && !this.model.get('closed')) { - return this.$el.find('div.add-response').show(); + return this.$el.find('.add-response').show(); } else { - return this.$el.find('div.add-response').hide(); + return this.$el.find('.add-response').hide(); } }; diff --git a/common/static/common/templates/discussion/thread-show.underscore b/common/static/common/templates/discussion/thread-show.underscore index 5055f5be29..471e87f218 100644 --- a/common/static/common/templates/discussion/thread-show.underscore +++ b/common/static/common/templates/discussion/thread-show.underscore @@ -1,7 +1,7 @@
<% if (!readOnly) { %> -
+
<%= _.template( $('#forum-actions').html())( diff --git a/common/static/common/templates/discussion/thread.underscore b/common/static/common/templates/discussion/thread.underscore index 23520e68d9..165a4e3af1 100644 --- a/common/static/common/templates/discussion/thread.underscore +++ b/common/static/common/templates/discussion/thread.underscore @@ -7,16 +7,18 @@
- <% if (!readOnly) { %> +
+ <% if (!readOnly) { %>
- <% } %> -
-
    -
    + <% } %> +
    +
    +
      +
      diff --git a/lms/static/sass/discussion/views/_response.scss b/lms/static/sass/discussion/views/_response.scss index 5ab87a3a2e..2712e07350 100644 --- a/lms/static/sass/discussion/views/_response.scss +++ b/lms/static/sass/discussion/views/_response.scss @@ -182,13 +182,14 @@ .response-count { @include float(right); + @include margin-right($baseline / 2); color: $forum-color-response-count; font-size: $forum-base-font-size; } .response-pagination { visibility: visible; - padding: 0 ($baseline/2); + margin: ($baseline / 2) 0; &:empty { visibility: hidden; diff --git a/lms/static/sass/discussion/views/_thread.scss b/lms/static/sass/discussion/views/_thread.scss index 722fbe97c4..5980d49296 100644 --- a/lms/static/sass/discussion/views/_thread.scss +++ b/lms/static/sass/discussion/views/_thread.scss @@ -45,7 +45,8 @@ font-weight: 600; } -.thread-responses-wrapper { +.thread-responses-wrapper, +.post-extended-content { padding: 0 ($baseline/2); } @@ -96,8 +97,8 @@ // +thread - wrapper styling .thread-wrapper { - .thread-main-wrapper { - padding-bottom: $baseline; + .response-btn-count-wrapper { + margin: $baseline 0; } }