debian-mirror-gitlab/app/helpers/form_helper.rb

45 lines
1.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
module FormHelper
2018-03-17 18:26:18 +05:30
def form_errors(model, type: 'form')
2016-06-02 11:05:42 +05:30
return unless model.errors.any?
pluralized = 'error'.pluralize(model.errors.count)
2018-03-17 18:26:18 +05:30
headline = "The #{type} contains the following #{pluralized}:"
2016-06-02 11:05:42 +05:30
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
content_tag(:h4, headline) <<
2017-08-17 22:00:37 +05:30
content_tag(:ul) do
2017-09-10 17:25:29 +05:30
model.errors.full_messages
.map { |msg| content_tag(:li, msg) }
.join
.html_safe
2017-08-17 22:00:37 +05:30
end
2016-06-02 11:05:42 +05:30
end
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
def issue_assignees_dropdown_options
{
2017-08-17 22:00:37 +05:30
toggle_class: 'js-user-search js-assignee-search js-multiselect js-save-user-data',
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,
2018-03-27 19:54:05 +05:30
project_id: @project&.id,
2017-09-10 17:25:29 +05:30
field_name: 'issue[assignee_ids][]',
default_label: 'Unassigned',
2017-08-17 22:00:37 +05:30
'max-select': 1,
'dropdown-header': 'Assignee',
multi_select: true,
'input-meta': 'name',
'always-show-selectbox': true,
2018-03-17 18:26:18 +05:30
current_user_info: UserSerializer.new.represent(current_user)
2017-08-17 22:00:37 +05:30
}
}
end
2016-06-02 11:05:42 +05:30
end