summaryrefslogtreecommitdiff
path: root/app/views/merge_requests/_form.html.haml
blob: 9a4f0617a3a60210616083a11188263209308882 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
= form_for [@project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f|
  -if @merge_request.errors.any?
    .alert-message.block-message.error
      %ul
        - @merge_request.errors.full_messages.each do |msg|
          %li= msg

  %fieldset
    %legend 1. Select Branches

    .row
      .span5
        .mr_branch_box
          %h5.cgray From (Head Branch)
          .body
            .padded= f.select(:source_branch, @repository.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span4'})
        .mr_source_commit

      .span2
        %center= image_tag "merge.png", class: 'mr_direction_tip'
      .span5
        .mr_branch_box
          %h5.cgray To (Base Branch)
          .body
            .padded= f.select(:target_branch, @repository.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span4'})
        .mr_target_commit

  %fieldset
    %legend 2. Fill info

    .ui-box.ui-box-show
      .ui-box-head
        .clearfix
          = f.label :title do
            %strong= "Title *"
          .input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true
      .ui-box-body
        .clearfix
          .left
            = f.label :assignee_id do
              %i.icon-user
              Assign to
            .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
          .left
            = f.label :milestone_id do
              %i.icon-time
              Milestone
            .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})

  .control-group

  .form-actions
    - if @merge_request.new_record?
      = f.submit 'Submit merge request', class: "btn success"
    -else
      = f.submit 'Save changes', class: "save-btn btn"
    - if @merge_request.new_record?
      = link_to project_merge_requests_path(@project), class: "btn cancel-btn" do
        Cancel
    - else
      = link_to project_merge_request_path(@project, @merge_request), class: "btn cancel-btn" do
        Cancel

:javascript
  $(function(){
    disableButtonIfEmptyField("#merge_request_title", ".save-btn");

    var source_branch = $("#merge_request_source_branch")
      , target_branch = $("#merge_request_target_branch");

    $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() });
    $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() });

    source_branch.live("change", function() {
      $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() });
    });

    target_branch.live("change", function() {
      $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() });
    });
  });