summaryrefslogtreecommitdiff
path: root/app/views/shared/issuable/_form.html.haml
blob: d5a4aad05d9f9824357219a47d1a0d0b4fc0cf6e (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
- if issuable.errors.any?
  .row
    .col-sm-offset-2.col-sm-10
      .alert.alert-danger
        - issuable.errors.full_messages.each do |msg|
          %span= msg
          %br
.form-group
  = f.label :title, class: 'control-label'
  .col-sm-10
    = f.text_field :title, maxlength: 255, autofocus: true, autocomplete: 'off',
        class: 'form-control pad js-gfm-input', required: true

    - if issuable.is_a?(MergeRequest)
      %p.help-block
        - if issuable.work_in_progress?
          Remove the <code>WIP</code> prefix from the title to allow this
          <strong>Work In Progress</strong> merge request to be merged when it's ready.
        - else
          Start the title with <code>[WIP]</code> or <code>WIP:</code> to prevent a
          <strong>Work In Progress</strong> merge request from being merged before it's ready.
.form-group.detail-page-description
  = f.label :description, 'Description', class: 'control-label'
  .col-sm-10

    = render layout: 'projects/md_preview', locals: { preview_class: "md-preview", referenced_users: true } do
      = render 'projects/zen', f: f, attr: :description,
                               classes: 'description form-control'
      = render 'projects/notes/hints'
      .clearfix
      .error-alert
- if can?(current_user, :"admin_#{issuable.to_ability_name}", issuable.project)
  %hr
  .form-group
    .issue-assignee
      = f.label :assignee_id, "Assignee", class: 'control-label'
      .col-sm-10
        = users_select_tag("#{issuable.class.model_name.param_key}[assignee_id]",
            placeholder: 'Select assignee', class: 'custom-form-control', null_user: true,
            selected: issuable.assignee_id, project: @target_project || @project,
            first_user: true, current_user: true, include_blank: true)
        &nbsp;
        = link_to 'Assign to me', '#', class: 'btn assign-to-me-link'
  .form-group
    .issue-milestone
      = f.label :milestone_id, "Milestone", class: 'control-label'
      .col-sm-10
        - if milestone_options(issuable).present?
          = f.select(:milestone_id, milestone_options(issuable),
            { include_blank: true }, { class: 'select2', data: { placeholder: 'Select milestone' } })
        - else
          .prepend-top-10
          %span.light No open milestones available.
        &nbsp;
        - if can? current_user, :admin_milestone, issuable.project
          = link_to 'Create new milestone', new_namespace_project_milestone_path(issuable.project.namespace, issuable.project), target: :blank
  .form-group
    = f.label :label_ids, "Labels", class: 'control-label'
    .col-sm-10
      - if issuable.project.labels.any?
        = f.collection_select :label_ids, issuable.project.labels.all, :id, :name,
          { selected: issuable.label_ids }, multiple: true, class: 'select2', data: { placeholder: "Select labels" }
      - else
        .prepend-top-10
        %span.light No labels yet.
      &nbsp;
      - if can? current_user, :admin_label, issuable.project
        = link_to 'Create new label', new_namespace_project_label_path(issuable.project.namespace, issuable.project), target: :blank

- if issuable.is_a?(MergeRequest)
  %hr
    - if @merge_request.new_record?
      .form-group
        = f.label :source_branch, class: 'control-label'
        .col-sm-10
          = f.select(:source_branch, [@merge_request.source_branch], { }, { class: 'source_branch select2 span2', disabled: true })
  .form-group
    = f.label :target_branch, class: 'control-label'
    .col-sm-10
      = f.select(:target_branch, @merge_request.target_branches, { include_blank: true }, { class: 'target_branch select2 span2', disabled: @merge_request.new_record?, data: {placeholder: "Select branch"} })
      - if @merge_request.new_record?
        %p.help-block
        = link_to 'Change branches', mr_change_branches_path(@merge_request)

- is_footer = !(issuable.is_a?(MergeRequest) && issuable.new_record?)
.gray-content-block{class: (is_footer ? "footer-block" : "middle-block")}
  - if issuable.new_record?
    = f.submit "Submit #{issuable.class.model_name.human.downcase}", class: 'btn btn-create'
  - else
    = f.submit 'Save changes', class: 'btn btn-save'

  - if !issuable.persisted? && !issuable.project.empty_repo? && (guide_url = contribution_guide_path(issuable.project))
    .inline.prepend-left-10
      Please review the
      %strong #{link_to 'contribution guidelines', guide_url}
      for this project.

  - if issuable.new_record?
    - cancel_project = issuable.source_project
  - else
    - cancel_project = issuable.project
  = link_to 'Cancel', [cancel_project.namespace.becomes(Namespace), cancel_project, issuable], class: 'btn btn-cancel'