Commit 97622a82 authored by Clement Ho's avatar Clement Ho

[skip ci] Refactor into issue_dropdown_options

parent 9aa21e8b
...@@ -15,4 +15,37 @@ module FormHelper ...@@ -15,4 +15,37 @@ module FormHelper
end end
end end
end end
def issue_dropdown_options(issuable, has_multiple_assignees = true)
options = {
toggle_class: 'js-user-search js-assignee-search',
title: 'Select assignee',
filter: true,
dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee',
placeholder: 'Search users',
data: {
first_user: (current_user.username if current_user),
null_user: true,
current_user: true,
project_id: issuable.project.try(:id),
field_name: "#{issuable.class.model_name.param_key}[assignee_ids][]",
default_label: 'Assignee',
'max-select': 1,
'dropdown-header': 'Assignee',
}
}
if has_multiple_assignees
options[:toggle_class] += ' js-multiselect js-save-user-data'
options[:title] = 'Select assignee(s)'
options[:data][:multi_select] = true
options[:data][:'input-meta'] = 'name'
options[:data][:'always-show-selectbox'] = true
options[:data][:current_user_info] = current_user.to_json(only: [:id, :name])
options[:data][:'dropdown-header'] = 'Assignee(s)'
options[:data].delete(:'max-select')
end
options
end
end end
...@@ -17,18 +17,7 @@ ...@@ -17,18 +17,7 @@
- issuable.assignees.each do |assignee| - issuable.assignees.each do |assignee|
= hidden_field_tag "#{issuable.to_ability_name}[assignee_ids][]", assignee.id, id: nil, data: { meta: assignee.name } = hidden_field_tag "#{issuable.to_ability_name}[assignee_ids][]", assignee.id, id: nil, data: { meta: assignee.name }
- options = { toggle_class: "js-user-search js-assignee-search", title: 'Select assignee', filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee", = dropdown_tag(users_dropdown_label(issuable.assignees), options: issue_dropdown_options(issuable, true))
placeholder: "Search users", data: { first_user: (current_user.username if current_user), null_user: true, current_user: true, project_id: issuable.project.try(:id), field_name: "#{issuable.class.model_name.param_key}[assignee_ids][]", default_label: "Assignee"} }
- options[:toggle_class] += ' js-multiselect js-save-user-data'
- options[:title] = 'Select assignee(s)'
- options[:data][:multi_select] = true
- options[:data]['input-meta'] = 'name'
- options[:data]['dropdown-header'] = 'Assignee(s)'
- options[:data]['always-show-selectbox'] = true
- options[:data][:current_user_info] = current_user.to_json(only: [:id, :name])
= dropdown_tag(users_dropdown_label(issuable.assignees), options: options)
= link_to 'Assign to me', '#', class: "assign-to-me-link #{'hide' if issuable.assignees.include?(current_user)}" = link_to 'Assign to me', '#', class: "assign-to-me-link #{'hide' if issuable.assignees.include?(current_user)}"
- else - else
= form.label :assignee_id, "Assignee", class: "control-label #{"col-lg-4" if has_due_date}" = form.label :assignee_id, "Assignee", class: "control-label #{"col-lg-4" if has_due_date}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment