summaryrefslogtreecommitdiff
path: root/app/views/shared/issuable/_form.html.haml
blob: 07b39c233b10602378fff50421ca47df189a78c3 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
= form_errors(issuable)

- if @conflict
  .alert.alert-danger
    Someone edited the #{issuable.class.model_name.human.downcase} the same time you did.
    Please check out
    = link_to "the #{issuable.class.model_name.human.downcase}", polymorphic_path([@project.namespace.becomes(Namespace), @project, issuable]), target: "_blank"
    and make sure your changes will not unintentionally remove theirs

.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', required: true

    - if issuable.is_a?(MergeRequest)
      %p.help-block
        .js-wip-explanation
          %a.js-toggle-wip{href: "", tabindex: -1}
            Remove the
            %code WIP:
            prefix from the title
          to allow this
          %strong Work In Progress
          merge request to be merged when it's ready.
        .js-no-wip-explanation
          %a.js-toggle-wip{href: "", tabindex: -1}
            Start the title with
            %code WIP:
          to prevent a
          %strong Work In Progress
          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: 'note-textarea',
                               placeholder: "Write a comment or drag your files here..."
      = render 'projects/notes/hints'
      .clearfix
      .error-alert

- if issuable.is_a?(Issue)
  .form-group
    .col-sm-offset-2.col-sm-10
      .checkbox
        = f.label :confidential do
          = f.check_box :confidential
          This issue is confidential and should only be visible to team members with at least Reporter access.

- if can?(current_user, :"admin_#{issuable.to_ability_name}", issuable.project)
  - has_due_date = issuable.has_attribute?(:due_date)
  %hr
  .row
    %div{ class: (has_due_date ? "col-lg-6" : "col-sm-12") }
      .form-group.issue-assignee
        = f.label :assignee_id, "Assignee", class: "control-label #{"col-lg-4" if has_due_date}"
        .col-sm-10{ class: ("col-lg-8" if has_due_date) }
          .issuable-form-select-holder
            - project = @target_project || @project
            - if issuable.assignee_id
              = hidden_field_tag("#{issuable.class.model_name.param_key}[assignee_id]", issuable.assignee_id)
            = dropdown_tag(user_dropdown_label(issuable.assignee_id, "Assignee"), options: { toggle_class: "js-user-search js-issuable-form-dropdown js-assignee-search", title: "Filter by assignee", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee js-filter-submit",
              placeholder: "Search assignee", data: { first_user: (current_user.username if current_user), null_user: true, current_user: true, project_id: (project.id if project), selected: issuable.assignee_id, field_name: "#{issuable.class.model_name.param_key}[assignee_id]", default_label: "Assignee" } })
      .form-group.issue-milestone
        = f.label :milestone_id, "Milestone", class: "control-label #{"col-lg-4" if has_due_date}"
        .col-sm-10{ class: ("col-lg-8" if has_due_date) }
          .issuable-form-select-holder
            = render "shared/issuable/milestone_dropdown", selected: issuable.milestone_id, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false
      .form-group
        - has_labels = issuable.project.labels.any?
        - selected_labels = issuable.label_ids.any? ? issuable.label_ids : nil
        - label_dropdown_toggle = issuable.labels.map { |label| label.title }
        = f.label :label_ids, "Labels", class: "control-label #{"col-lg-4" if has_due_date}"
        .col-sm-10{ class: "#{"col-lg-8" if has_due_date} #{'issuable-form-padding-top' if !has_labels}" }
          .issuable-form-select-holder
            = render "shared/issuable/label_dropdown", classes: ["js-issuable-form-dropdown"], selected: selected_labels, selected_toggle: label_dropdown_toggle, data_options: { field_name: "#{issuable.class.model_name.param_key}[label_ids][]", show_any: "false" }
    - if has_due_date
      .col-lg-6
        .form-group
          = f.label :due_date, "Due date", class: "control-label"
          .col-sm-10
            .issuable-form-select-holder
              = f.text_field :due_date, id: "issuable-due-date", class: "datepicker form-control", placeholder: "Select due date"

- if issuable.can_move?(current_user)
  %hr
  .form-group
    = label_tag :move_to_project_id, 'Move', class: 'control-label'
    .col-sm-10
      .issuable-form-select-holder
        = hidden_field_tag :move_to_project_id, nil, class: 'js-move-dropdown', data: { placeholder: 'Select project', projects_url: autocomplete_projects_path(project_id: @project.id) }
       
      %span{ data: { toggle: 'tooltip', placement: 'auto top' }, style: 'cursor: default',
      title: 'Moving an issue will copy the discussion to a different project and close it here. All participants will be notified of the new location.' }
        = icon('question-circle')

- if issuable.is_a?(MergeRequest)
  %hr
  - if @merge_request.new_record?
    .form-group
      = f.label :source_branch, class: 'control-label'
      .col-sm-10
        .issuable-form-select-holder
          = 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
      .issuable-form-select-holder
        = 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?
         
        = link_to 'Change branches', mr_change_branches_path(@merge_request)
  - if @merge_request.can_remove_source_branch?(current_user)
    .form-group
      .col-sm-10.col-sm-offset-2
        .checkbox
          = label_tag 'merge_request[force_remove_source_branch]' do
            = check_box_tag 'merge_request[force_remove_source_branch]', '1', @merge_request.force_remove_source_branch?
            Remove source branch when merge request is accepted.

- is_footer = !(issuable.is_a?(MergeRequest) && issuable.new_record?)
.row-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?
    = link_to 'Cancel', polymorphic_path([@project.namespace.becomes(Namespace), @project, issuable.class]), class: 'btn btn-cancel'
  - else
    .pull-right
      - if current_user.can?(:"destroy_#{issuable.to_ability_name}", @project)
        = link_to 'Delete', polymorphic_path([@project.namespace.becomes(Namespace), @project, issuable]), data: { confirm: "#{issuable.class.name.titleize} will be removed! Are you sure?" },
                                                                                                  method: :delete, class: 'btn btn-danger btn-grouped'
      = link_to 'Cancel', polymorphic_path([@project.namespace.becomes(Namespace), @project, issuable]), class: 'btn btn-grouped btn-cancel'

= f.hidden_field :lock_version