diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-18 13:15:43 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-18 13:15:43 +0200 |
commit | 8a55636f8974d73c097a52721e2208cea727bc17 (patch) | |
tree | 9eb2e732662c2a6ffd342159b50963f388a96db9 | |
parent | 26ebfa20f082214f3dbd5d5ca49957d8cc83d234 (diff) | |
download | gitlab-ce-8a55636f8974d73c097a52721e2208cea727bc17.tar.gz |
Dont replace all issue context when change assignee/milestone
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/issue.js.coffee | 9 | ||||
-rw-r--r-- | app/assets/javascripts/issues.js.coffee | 6 | ||||
-rw-r--r-- | app/assets/javascripts/project_users_select.js.coffee | 58 | ||||
-rw-r--r-- | app/views/projects/issues/_issue_context.html.haml | 3 | ||||
-rw-r--r-- | app/views/projects/issues/update.js.haml | 3 |
6 files changed, 42 insertions, 39 deletions
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 9afb5974858..46d6db0f05c 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -19,6 +19,8 @@ class Dispatcher switch page when 'projects:issues:index' Issues.init() + when 'projects:issues:show' + new Issue() when 'projects:issues:new', 'projects:merge_requests:new' GitLab.GfmAutoComplete.setup() when 'dashboard:show' diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee new file mode 100644 index 00000000000..36935a0a159 --- /dev/null +++ b/app/assets/javascripts/issue.js.coffee @@ -0,0 +1,9 @@ +class Issue + constructor: -> + $('.edit-issue.inline-update input[type="submit"]').hide() + $(".issue-box .inline-update").on "change", "select", -> + $(this).submit() + $(".issue-box .inline-update").on "change", "#issue_assignee_id", -> + $(this).submit() + +@Issue = Issue diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index 6c239c66c0a..e2f1bc743f7 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -77,9 +77,3 @@ $("#update_issues_ids").val [] $(".issues_bulk_update").hide() $(".issues-filters").show() - -$ -> - $('.edit-issue.inline-update input[type="submit"]').hide(); - $("body").on "change", ".edit-issue.inline-update select", -> - $(this).submit() - diff --git a/app/assets/javascripts/project_users_select.js.coffee b/app/assets/javascripts/project_users_select.js.coffee index 59a53cb52bc..aa8b70d9b8a 100644 --- a/app/assets/javascripts/project_users_select.js.coffee +++ b/app/assets/javascripts/project_users_select.js.coffee @@ -1,5 +1,31 @@ -$ -> - projectUserFormatResult = (user) -> +@projectUsersSelect = + init: -> + $('.ajax-project-users-select').each (i, select) -> + project_id = $('body').data('project-id') + + $(select).select2 + placeholder: $(select).data('placeholder') || "Search for a user" + multiple: $(select).hasClass('multiselect') + minimumInputLength: 0 + query: (query) -> + Api.projectUsers project_id, query.term, (users) -> + data = { results: users } + query.callback(data) + + initSelection: (element, callback) -> + id = $(element).val() + if id isnt "" + Api.user(id, callback) + + + formatResult: projectUsersSelect.projectUserFormatResult + formatSelection: projectUsersSelect.projectUserFormatSelection + dropdownCssClass: "ajax-project-users-dropdown" + dropdownAutoWidth: true + escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results + m + + projectUserFormatResult: (user) -> if user.avatar_url avatar = user.avatar_url else if gon.gravatar_enabled @@ -15,30 +41,8 @@ $ -> <div class='user-username'>#{user.username}</div> </div>" - projectUserFormatSelection = (user) -> + projectUserFormatSelection: (user) -> user.name - $('.ajax-project-users-select').each (i, select) -> - project_id = $('body').data('project-id') - - $(select).select2 - placeholder: $(select).data('placeholder') || "Search for a user" - multiple: $(select).hasClass('multiselect') - minimumInputLength: 0 - query: (query) -> - Api.projectUsers project_id, query.term, (users) -> - data = { results: users } - query.callback(data) - - initSelection: (element, callback) -> - id = $(element).val() - if id isnt "" - Api.user(id, callback) - - - formatResult: projectUserFormatResult - formatSelection: projectUserFormatSelection - dropdownCssClass: "ajax-project-users-dropdown" - dropdownAutoWidth: true - escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results - m +$ -> + projectUsersSelect.init() diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 029d7d6f0f4..fb124a8ab44 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -4,9 +4,6 @@ \ and currently assigned to - if can?(current_user, :modify_issue, @issue) - = link_to profile_path(issue.assignee) do - = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee - = project_users_select_tag('issue[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @issue.assignee_id) - elsif issue.assignee = link_to_member(@project, @issue.assignee) diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml index 59524e0f224..5199e9fc61f 100644 --- a/app/views/projects/issues/update.js.haml +++ b/app/views/projects/issues/update.js.haml @@ -3,10 +3,7 @@ :plain $("##{dom_id(@issue)}").fadeOut(); - elsif params[:issue_context] - $('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}"); $('.issue-box .context').effect('highlight'); - $('.select2').select2(); - $('.edit-issue.inline-update input[type="submit"]').hide(); - if @issue.milestone $('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}</span>") - else |