From 59e51e3cabfb960f5b78b8f8cda7478c79846de5 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 21 Mar 2016 11:31:50 +0000 Subject: Fixed bug where participants would not work correctly on merge requests Also fixed alignment bug with can't merge badge --- app/assets/javascripts/issuable_context.js.coffee | 28 +++++++++++++++++++++-- app/assets/javascripts/issue.js.coffee | 25 -------------------- app/views/shared/issuable/_participants.html.haml | 2 +- app/views/shared/issuable/_sidebar.html.haml | 6 ++--- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/app/assets/javascripts/issuable_context.js.coffee b/app/assets/javascripts/issuable_context.js.coffee index e52b73f94f6..d6d09b36d8d 100644 --- a/app/assets/javascripts/issuable_context.js.coffee +++ b/app/assets/javascripts/issuable_context.js.coffee @@ -1,7 +1,7 @@ -#= require jquery.waitforimages - class @IssuableContext constructor: -> + @initParticipants() + new UsersSelect() $('select.select2').select2({width: 'resolve', dropdownAutoWidth: true}) @@ -17,3 +17,27 @@ class @IssuableContext block.find('.js-select2').select2("open") $(".right-sidebar").niceScroll() + + initParticipants: -> + _this = @ + $(document).on "click", ".js-participants-more", @toggleHiddenParticipants + + $(".js-participants-author").each (i) -> + if i >= _this.PARTICIPANTS_ROW_COUNT + $(@) + .addClass "js-participants-hidden" + .hide() + + toggleHiddenParticipants: (e) -> + e.preventDefault() + + currentText = $(this).text().trim() + lessText = $(this).data("less-text") + originalText = $(this).data("original-text") + + if currentText is originalText + $(this).text(lessText) + else + $(this).text(originalText) + + $(".js-participants-hidden").toggle() diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee index f50df1f5ea3..d663e34871c 100644 --- a/app/assets/javascripts/issue.js.coffee +++ b/app/assets/javascripts/issue.js.coffee @@ -7,7 +7,6 @@ class @Issue # Prevent duplicate event bindings @disableTaskList() @fixAffixScroll() - @initParticipants() if $('a.btn-close').length @initTaskList() @initIssueBtnEventListeners() @@ -85,27 +84,3 @@ class @Issue type: 'PATCH' url: $('form.js-issuable-update').attr('action') data: patchData - - initParticipants: -> - _this = @ - $(document).on "click", ".js-participants-more", @toggleHiddenParticipants - - $(".js-participants-author").each (i) -> - if i >= _this.PARTICIPANTS_ROW_COUNT - $(@) - .addClass "js-participants-hidden" - .hide() - - toggleHiddenParticipants: (e) -> - e.preventDefault() - - currentText = $(this).text().trim() - lessText = $(this).data("less-text") - originalText = $(this).data("original-text") - - if currentText is originalText - $(this).text(lessText) - else - $(this).text(originalText) - - $(".js-participants-hidden").toggle() diff --git a/app/views/shared/issuable/_participants.html.haml b/app/views/shared/issuable/_participants.html.haml index 3fb409ff727..33a9a494857 100644 --- a/app/views/shared/issuable/_participants.html.haml +++ b/app/views/shared/issuable/_participants.html.haml @@ -17,4 +17,4 @@ %a.js-participants-more{href: "#", data: {original_text: "+ #{participants_size - 7} more", less_text: "- show less"}} + #{participants_extra} more :javascript - Issue.prototype.PARTICIPANTS_ROW_COUNT = #{participants_row}; + IssuableContext.prototype.PARTICIPANTS_ROW_COUNT = #{participants_row}; diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index 2b95b19facc..5b2772de3f1 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -33,11 +33,11 @@ .value.bold.hide-collapsed - if issuable.assignee = link_to_member(@project, issuable.assignee, size: 32) do + - if issuable.instance_of?(MergeRequest) && !issuable.can_be_merged_by?(issuable.assignee) + %span.pull-right.cannot-be-merged{ data: { toggle: 'tooltip', placement: 'left' }, title: 'Not allowed to merge' } + = icon('exclamation-triangle') %span.username = issuable.assignee.to_reference - - if issuable.instance_of?(MergeRequest) && !issuable.can_be_merged_by?(issuable.assignee) - %a.pull-right.cannot-be-merged{href: '#', data: {toggle: 'tooltip'}, title: 'Not allowed to merge'} - = icon('exclamation-triangle') - else .light None -- cgit v1.2.1