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

8 9
  %h4.cdark 1. Select Branches
  %br
randx's avatar
randx committed
10

11
  .row
12
    .span5
randx's avatar
randx committed
13
      .mr_branch_box
14 15 16
        %h5 From (Head Branch)
        .body 
          .padded
17
            = f.label :source_branch, "From", class: "control-label"
18
            .controls
19
              = f.select(:source_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span3'})
20
      .mr_source_commit
21

22 23 24
    .span2
      %center= image_tag "merge.png", class: 'mr_direction_tip'
    .span5
randx's avatar
randx committed
25
      .mr_branch_box
26 27 28
        %h5 To (Base Branch)
        .body
          .padded
29
            = f.label :target_branch, "To", class: "control-label"
30
            .controls
31
              = f.select(:target_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span3'})
32
      .mr_target_commit
33

34 35
  %h4.cdark 2. Fill info

36
  .clearfix
37 38 39 40
    .main_box
      .top_box_content
        = f.label :title do 
          %strong= "Title *"
41
        .input= f.text_field :title, class: "input-xxlarge pad", maxlength: 255, rows: 5
42 43 44 45
      .middle_box_content
        = f.label :assignee_id do 
          %i.icon-user 
          Assign to
46
        .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
47

48 49
  .control-group

randx's avatar
randx committed
50
  .form-actions
51
    = f.submit 'Save', class: "btn save-btn"
52
    - if @merge_request.new_record?
53
      = link_to project_merge_requests_path(@project), class: "btn cancel-btn" do
54
        Cancel
55
    - else
56
      = link_to project_merge_request_path(@project, @merge_request), class: "btn cancel-btn" do
57
        Cancel
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
58 59 60

:javascript
  $(function(){
61
    disableButtonIfEmptyField("#merge_request_title", ".save-btn");
62 63
    var source_branch = $("#merge_request_source_branch");
    var target_branch = $("#merge_request_target_branch");
64

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

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

72
    target_branch.live("change", function() {
73 74
      $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() });
    });
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
75
  });