Commit 7316055ac8bc8cca651430c37cbe20dcd79e23cd
1 parent
bf17d976
Exists in
master
and in
4 other branches
multiselect for ajax-users-select2
Showing
2 changed files
with
5 additions
and
2 deletions
Show diff stats
app/assets/javascripts/users_select.js.coffee
@@ -11,9 +11,12 @@ $ -> | @@ -11,9 +11,12 @@ $ -> | ||
11 | markup += "</div>" | 11 | markup += "</div>" |
12 | markup | 12 | markup |
13 | 13 | ||
14 | + userFormatSelection = (user) -> | ||
15 | + user.name | ||
14 | 16 | ||
15 | $('.ajax-users-select').select2 | 17 | $('.ajax-users-select').select2 |
16 | placeholder: "Search for a user" | 18 | placeholder: "Search for a user" |
19 | + multiple: true | ||
17 | minimumInputLength: 0 | 20 | minimumInputLength: 0 |
18 | ajax: # instead of writing the function to execute the request we use Select2's convenient helper | 21 | ajax: # instead of writing the function to execute the request we use Select2's convenient helper |
19 | url: "/api/v3/users.json" | 22 | url: "/api/v3/users.json" |
@@ -40,7 +43,7 @@ $ -> | @@ -40,7 +43,7 @@ $ -> | ||
40 | 43 | ||
41 | 44 | ||
42 | formatResult: userFormatResult # omitted for brevity, see the source of this page | 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 | dropdownCssClass: "ajax-users-dropdown" # apply css that makes the dropdown taller | 47 | dropdownCssClass: "ajax-users-dropdown" # apply css that makes the dropdown taller |
45 | escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results | 48 | escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results |
46 | m | 49 | m |
app/controllers/team_members_controller.rb
@@ -16,7 +16,7 @@ class TeamMembersController < ProjectResourceController | @@ -16,7 +16,7 @@ class TeamMembersController < ProjectResourceController | ||
16 | end | 16 | end |
17 | 17 | ||
18 | def create | 18 | def create |
19 | - users = User.where(id: params[:user_ids]) | 19 | + users = User.where(id: params[:user_ids].split(',')) |
20 | 20 | ||
21 | @project.team << [users, params[:project_access]] | 21 | @project.team << [users, params[:project_access]] |
22 | 22 |