_form.html.haml 3.8 KB
Newer Older
1
= form_for [@project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f|
2
  -if @merge_request.errors.any?
3
    .alert.alert-error
4 5 6
      %ul
        - @merge_request.errors.full_messages.each do |msg|
          %li= msg
7

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
8
  .merge-request-branches
9
    .row
10
      .col-md-5
11 12
        .clearfix
          .pull-left
13
            = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project chosen span3', disabled: @merge_request.persisted? })
14 15 16 17
          .pull-left
             
            = f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span2'})
        .mr_source_commit.prepend-top-10
18
      .col-md-2
19 20
        %h2.merge-request-angle.light
          %i.icon-long-arrow-right
21
      .col-md-5
22 23 24
        .clearfix
          .pull-left
            - projects =  @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project]
25
            = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project chosen span3', disabled: @merge_request.persisted? })
26 27 28 29
          .pull-left
             
            = f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span2'})
        .mr_target_commit.prepend-top-10
30

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
31
  %hr
32
  .merge-request-form-info
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
33
    .form-group
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
34 35
      = f.label :title do
        %strong= "Title *"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
36 37
      .col-sm-10= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true
    .form-group
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
38 39 40 41
      .left
        = f.label :assignee_id do
          %i.icon-user
          Assign to
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
42
        .col-sm-10= f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select user" }, {class: 'chosen span3'})
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
43 44 45 46
      .left
        = f.label :milestone_id do
          %i.icon-time
          Milestone
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
47 48
        .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'chosen'})
    .form-group
49
      = f.label :description, "Description"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
50
      .col-sm-10
51 52 53
        = f.text_area :description, class: "input-xxlarge js-gfm-input", rows: 14
        %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.

54

randx's avatar
randx committed
55
  .form-actions
56
    - if @merge_request.new_record?
57
      = f.submit 'Submit merge request', class: "btn btn-create"
58
    -else
59
      = f.submit 'Save changes', class: "btn btn-save"
60
    - if @merge_request.new_record?
Izaak Alpert's avatar
Izaak Alpert committed
61
      = link_to project_merge_requests_path(@source_project), class: "btn btn-cancel" do
62
        Cancel
63
    - else
Izaak Alpert's avatar
Izaak Alpert committed
64
      = link_to project_merge_request_path(@target_project, @merge_request), class: "btn btn-cancel" do
65
        Cancel
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
66 67

:javascript
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
68
  disableButtonIfEmptyField("#merge_request_title", ".btn-save");
69

Izaak Alpert's avatar
Izaak Alpert committed
70 71 72
  var source_branch = $("#merge_request_source_branch")
    , target_branch = $("#merge_request_target_branch")
    , target_project = $("#merge_request_target_project_id");
73

Izaak Alpert's avatar
Izaak Alpert committed
74 75
  $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: source_branch.val() });
  $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() });
76

77
  target_project.on("change", function() {
Izaak Alpert's avatar
Izaak Alpert committed
78 79
    $.get("#{update_branches_project_merge_requests_path(@source_project)}", {target_project_id:  $(this).val() });
  });
80
  source_branch.on("change", function() {
Izaak Alpert's avatar
Izaak Alpert committed
81 82
    $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: $(this).val() });
  });
83
  target_branch.on("change", function() {
Izaak Alpert's avatar
Izaak Alpert committed
84
    $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
85
  });