Module: ProjectHelper
- Defined in:
- app/helpers/project_helper.rb
Overview
Helper methods for projects
Instance Method Summary collapse
- #all_users_list_json ⇒ Object
- #manager_list_json ⇒ Object
-
#pre_populate_data_sponsor ⇒ Object
For a new project form, pre-populate the data sponsor field with the current user’s netid.
-
#sponsor_list_json ⇒ Object
rubocop:enable Rails/OutputSafety.
-
#user_list_json(users) ⇒ Object
Returns a string with JSON representation of a list of users The JSON can be used to feed the jQuery Autocomplete plug-in rubocop:disable Rails/OutputSafety.
Instance Method Details
#all_users_list_json ⇒ Object
34 35 36 |
# File 'app/helpers/project_helper.rb', line 34 def all_users_list_json user_list_json(User.all) end |
#manager_list_json ⇒ Object
30 31 32 |
# File 'app/helpers/project_helper.rb', line 30 def manager_list_json user_list_json(User.manager_users) end |
#pre_populate_data_sponsor ⇒ Object
For a new project form, pre-populate the data sponsor field with the current user’s netid. For an existing project form, pre-populate the data sponsor field with the current value.
6 7 8 9 10 11 12 |
# File 'app/helpers/project_helper.rb', line 6 def pre_populate_data_sponsor if @project.[:data_sponsor].nil? current_user.uid else @project.[:data_sponsor] end end |
#sponsor_list_json ⇒ Object
rubocop:enable Rails/OutputSafety
26 27 28 |
# File 'app/helpers/project_helper.rb', line 26 def sponsor_list_json user_list_json(User.sponsor_users) end |
#user_list_json(users) ⇒ Object
Returns a string with JSON representation of a list of users The JSON can be used to feed the jQuery Autocomplete plug-in rubocop:disable Rails/OutputSafety
17 18 19 20 21 22 23 |
# File 'app/helpers/project_helper.rb', line 17 def user_list_json(users) json_elements = users.map do |user| { data: user.uid, value: "#{user.display_name_safe} (#{user.uid})" }.to_json end json_elements.join(",").html_safe end |