2016-04-04 21:25:38 -04:00
|
|
|
module FormHelper
|
2017-08-28 16:33:35 -04:00
|
|
|
def form_errors(model, type: 'form')
|
2016-04-04 21:25:38 -04:00
|
|
|
return unless model.errors.any?
|
|
|
|
|
|
|
|
pluralized = 'error'.pluralize(model.errors.count)
|
2017-08-28 16:33:35 -04:00
|
|
|
headline = "The #{type} contains the following #{pluralized}:"
|
2016-04-04 21:25:38 -04:00
|
|
|
|
|
|
|
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
|
|
|
|
content_tag(:h4, headline) <<
|
2016-12-15 17:14:20 -05:00
|
|
|
content_tag(:ul) do
|
2017-06-21 09:48:12 -04:00
|
|
|
model.errors.full_messages
|
|
|
|
.map { |msg| content_tag(:li, msg) }
|
|
|
|
.join
|
|
|
|
.html_safe
|
2016-12-15 17:14:20 -05:00
|
|
|
end
|
2016-04-04 21:25:38 -04:00
|
|
|
end
|
|
|
|
end
|
2017-05-04 08:11:15 -04:00
|
|
|
|
2017-05-31 09:59:01 -04:00
|
|
|
def issue_assignees_dropdown_options
|
|
|
|
{
|
2017-05-04 16:55:36 -04:00
|
|
|
toggle_class: 'js-user-search js-assignee-search js-multiselect js-save-user-data',
|
2017-05-04 08:11:15 -04:00
|
|
|
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,
|
|
|
|
null_user: true,
|
|
|
|
current_user: true,
|
2017-05-31 09:59:01 -04:00
|
|
|
project_id: @project.id,
|
|
|
|
field_name: 'issue[assignee_ids][]',
|
2017-06-11 12:38:10 -04:00
|
|
|
default_label: 'Unassigned',
|
2017-05-04 08:11:15 -04:00
|
|
|
'max-select': 1,
|
|
|
|
'dropdown-header': 'Assignee',
|
2017-05-04 16:55:36 -04:00
|
|
|
multi_select: true,
|
|
|
|
'input-meta': 'name',
|
|
|
|
'always-show-selectbox': true,
|
2017-09-19 14:22:43 -04:00
|
|
|
current_user_info: UserSerializer.new.represent(current_user)
|
2017-05-04 08:11:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2016-04-04 21:25:38 -04:00
|
|
|
end
|