BigW Consortium Gitlab

form_helper.rb 1.26 KB
Newer Older
1 2 3 4 5 6 7 8 9
module FormHelper
  def form_errors(model)
    return unless model.errors.any?

    pluralized = 'error'.pluralize(model.errors.count)
    headline   = "The form contains the following #{pluralized}:"

    content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
      content_tag(:h4, headline) <<
10
        content_tag(:ul) do
11 12 13 14
          model.errors.full_messages
            .map { |msg| content_tag(:li, msg) }
            .join
            .html_safe
15
        end
16 17
    end
  end
18

19 20
  def issue_assignees_dropdown_options
    {
Clement Ho committed
21
      toggle_class: 'js-user-search js-assignee-search js-multiselect js-save-user-data',
22 23 24 25 26 27 28 29
      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,
30 31
        project_id: @project.id,
        field_name: 'issue[assignee_ids][]',
32
        default_label: 'Unassigned',
33 34
        'max-select': 1,
        'dropdown-header': 'Assignee',
Clement Ho committed
35 36 37 38
        multi_select: true,
        'input-meta': 'name',
        'always-show-selectbox': true,
        current_user_info: current_user.to_json(only: [:id, :name])
39 40 41
      }
    }
  end
42
end