mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add helper function for speaker selection
The line '@users = User.all.order(:name)' is replicated a lot of times in EventsController and ProposalsController. So, this commit removes it and adds a helper function 'speaker_selector_input' that generates the field where the @users variable was used. Also, it makes the query more specific. Fix #1455 Other changes: * Include the username in the drop down menu * Add .active scope to User and corresponding tests * Add :disabled trait to User factory
This commit is contained in:
parent
36b8088726
commit
fa56ff7f6d
7 changed files with 25 additions and 9 deletions
|
|
@ -602,4 +602,11 @@ module ApplicationHelper
|
|||
def speaker_links(event)
|
||||
event.speakers.map{ |speaker| link_to speaker.name, admin_user_path(speaker) }.join(', ').html_safe
|
||||
end
|
||||
|
||||
def speaker_selector_input(form)
|
||||
users = User.active.pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].blank? ? user[2] : user[1], user[2], user[3]] }.sort_by { |user| user[1].downcase }
|
||||
form.input :speakers, as: :select,
|
||||
collection: options_for_select(users.map {|user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]]}, @event.speakers.map(&:id)),
|
||||
include_blank: false, label: 'Speakers', input_html: { class: 'select-help-toggle', multiple: 'true' }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue