summaryrefslogtreecommitdiff
path: root/app/views/projects/merge_requests/_form.html.haml
blob: 3088f0cf864a3d31a10899514d7117ac66fc70d0 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
= form_for [@project, @merge_request], html: { class: "merge-request-form form-horizontal" } do |f|
  .row
    .col-sm-2
    .col-sm-10
      - if @repository.contribution_guide && !@merge_request.persisted?
        - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name))
        .alert.alert-info
          Please review the
          %strong #{link_to "guidelines for contribution", contribution_guide_url}
          to this repository.

      -if @merge_request.errors.any?
        .alert.alert-danger
          - @merge_request.errors.full_messages.each do |msg|
            %div= msg

  .merge-request-form-info
    .form-group
      = f.label :title, class: 'control-label' do
        %strong= "Title *"
      .col-sm-10= f.text_field :title, class: "form-control pad js-gfm-input", maxlength: 255, rows: 5, required: true
    .form-group
      = f.label :description, "Description", class: 'control-label'
      .col-sm-10
        = f.text_area :description, class: "form-control js-gfm-input markdown-area", rows: 14
        .col-sm-12.hint
          .pull-left Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
          .pull-right Attach images (JPG, PNG, GIF) by dragging & dropping or #{link_to "selecting them", '#', class: 'markdown-selector' }.
        .clearfix
        .error-alert
    %hr
    .form-group
      .issue-assignee
        = f.label :assignee_id, class: 'control-label' do
          %i.icon-user
          Assign to
        .col-sm-10
          = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @merge_request.assignee_id)
           
          = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
    .form-group
      .issue-milestone
        = f.label :milestone_id, class: 'control-label' do
          %i.icon-time
          Milestone
        .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'})


    - if @merge_request.persisted? # Only allow labels on edit to avoid fork vs upstream repo labels issue
      .form-group
        = f.label :label_list, class: 'control-label' do
          %i.icon-tag
          Labels
        .col-sm-10
          = f.text_field :label_list, maxlength: 2000, class: "form-control"
          %p.hint Separate labels with commas.

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

:javascript
  disableButtonIfEmptyField("#merge_request_title", ".btn-save");
  $('.assign-to-me-link').on('click', function(e){
    $('#merge_request_assignee_id').val("#{current_user.id}").trigger("change");
    e.preventDefault();
  });

  $("#merge_request_label_list")
    .bind( "keydown", function( event ) {
      if ( event.keyCode === $.ui.keyCode.TAB &&
        $( this ).data( "autocomplete" ).menu.active ) {
        event.preventDefault();
      }
    })
    .bind("click", function(event) {
      $(this).autocomplete("search", "");
    })
    .autocomplete({
      minLength: 0,
      source: function( request, response ) {
        response( $.ui.autocomplete.filter(
          #{raw labels_autocomplete_source}, extractLast( request.term ) ) );
      },
      focus: function() {
        return false;
      },
      select: function(event, ui) {
        var terms = split( this.value );
        terms.pop();
        terms.push( ui.item.value );
        terms.push( "" );
        this.value = terms.join( ", " );
        return false;
      }
    });

  window.project_image_path_upload = "#{upload_image_project_path @project}";