Commit 7316055ac8bc8cca651430c37cbe20dcd79e23cd

Authored by Dmitriy Zaporozhets
1 parent bf17d976

multiselect for ajax-users-select2

app/assets/javascripts/users_select.js.coffee
... ... @@ -11,9 +11,12 @@ $ ->
11 11 markup += "</div>"
12 12 markup
13 13  
  14 + userFormatSelection = (user) ->
  15 + user.name
14 16  
15 17 $('.ajax-users-select').select2
16 18 placeholder: "Search for a user"
  19 + multiple: true
17 20 minimumInputLength: 0
18 21 ajax: # instead of writing the function to execute the request we use Select2's convenient helper
19 22 url: "/api/v3/users.json"
... ... @@ -40,7 +43,7 @@ $ -&gt;
40 43  
41 44  
42 45 formatResult: userFormatResult # omitted for brevity, see the source of this page
43   - #formatSelection: userFormatSelection # omitted for brevity, see the source of this page
  46 + formatSelection: userFormatSelection # omitted for brevity, see the source of this page
44 47 dropdownCssClass: "ajax-users-dropdown" # apply css that makes the dropdown taller
45 48 escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results
46 49 m
... ...
app/controllers/team_members_controller.rb
... ... @@ -16,7 +16,7 @@ class TeamMembersController &lt; ProjectResourceController
16 16 end
17 17  
18 18 def create
19   - users = User.where(id: params[:user_ids])
  19 + users = User.where(id: params[:user_ids].split(','))
20 20  
21 21 @project.team << [users, params[:project_access]]
22 22  
... ...