Commit 2da289cf22995d14e275b7c908b7e6014a11c7d9
1 parent
ee3cd06f
Exists in
spb-stable
and in
2 other branches
Add assignee and milestone to 2nd step
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
5 changed files
with
30 additions
and
4 deletions
Show diff stats
app/assets/javascripts/project_users_select.js.coffee
| 1 | 1 | @projectUsersSelect = |
| 2 | 2 | init: -> |
| 3 | 3 | $('.ajax-project-users-select').each (i, select) -> |
| 4 | - project_id = $('body').data('project-id') | |
| 4 | + project_id = $(select).data('project-id') || $('body').data('project-id') | |
| 5 | 5 | |
| 6 | 6 | $(select).select2 |
| 7 | 7 | placeholder: $(select).data('placeholder') || "Search for a user" | ... | ... |
app/helpers/issues_helper.rb
| ... | ... | @@ -82,7 +82,7 @@ module IssuesHelper |
| 82 | 82 | end |
| 83 | 83 | |
| 84 | 84 | def milestone_options object |
| 85 | - options_from_collection_for_select(@project.milestones.active, 'id', 'title', object.milestone_id) | |
| 85 | + options_from_collection_for_select(object.project.milestones.active, 'id', 'title', object.milestone_id) | |
| 86 | 86 | end |
| 87 | 87 | |
| 88 | 88 | def issue_box_class(item) | ... | ... |
app/helpers/selects_helper.rb
| ... | ... | @@ -14,7 +14,7 @@ module SelectsHelper |
| 14 | 14 | css_class << (opts[:class] || '') |
| 15 | 15 | value = opts[:selected] || '' |
| 16 | 16 | placeholder = opts[:placeholder] || 'Select user' |
| 17 | - | |
| 18 | - hidden_field_tag(id, value, class: css_class, 'data-placeholder' => placeholder) | |
| 17 | + project_id = opts[:project_id] || @project.id | |
| 18 | + hidden_field_tag(id, value, class: css_class, 'data-placeholder' => placeholder, 'data-project-id' => project_id) | |
| 19 | 19 | end |
| 20 | 20 | end | ... | ... |
app/views/projects/merge_requests/_form.html.haml
app/views/projects/merge_requests/_new_submit.html.haml
| ... | ... | @@ -25,6 +25,21 @@ |
| 25 | 25 | = f.label :description, "Description" |
| 26 | 26 | = f.text_area :description, class: "form-control js-gfm-input", rows: 10 |
| 27 | 27 | %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. |
| 28 | + .form-group | |
| 29 | + .issue-assignee | |
| 30 | + = f.label :assignee_id do | |
| 31 | + %i.icon-user | |
| 32 | + Assign to | |
| 33 | + %div | |
| 34 | + = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @merge_request.assignee_id, project_id: @merge_request.target_project_id) | |
| 35 | + | |
| 36 | + = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' | |
| 37 | + .form-group | |
| 38 | + .issue-milestone | |
| 39 | + = f.label :milestone_id do | |
| 40 | + %i.icon-time | |
| 41 | + Milestone | |
| 42 | + %div= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'}) | |
| 28 | 43 | .panel-footer |
| 29 | 44 | - if @target_repo.contribution_guide |
| 30 | 45 | - contribution_guide_url = project_blob_path(@target_project, tree_join(@target_repo.root_ref, @target_repo.contribution_guide.name)) |
| ... | ... | @@ -58,3 +73,10 @@ |
| 58 | 73 | .bs-callout.bs-callout-danger |
| 59 | 74 | %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. |
| 60 | 75 | %p To preserve performance the line changes are not shown. |
| 76 | + | |
| 77 | + | |
| 78 | +:javascript | |
| 79 | + $('.assign-to-me-link').on('click', function(e){ | |
| 80 | + $('#merge_request_assignee_id').val("#{current_user.id}").trigger("change"); | |
| 81 | + e.preventDefault(); | |
| 82 | + }); | ... | ... |