Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bdcaf21e
Commit
bdcaf21e
authored
Mar 13, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow single/multiple user select
parent
7316055a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
7 deletions
+12
-7
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+1
-1
app/controllers/teams/members_controller.rb
app/controllers/teams/members_controller.rb
+1
-1
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+4
-2
app/models/user_team.rb
app/models/user_team.rb
+3
-0
app/views/team_members/_form.html.haml
app/views/team_members/_form.html.haml
+1
-2
app/views/teams/members/new.html.haml
app/views/teams/members/new.html.haml
+2
-1
No files found.
app/assets/javascripts/users_select.js.coffee
View file @
bdcaf21e
...
...
@@ -16,7 +16,7 @@ $ ->
$
(
'.ajax-users-select'
).
select2
placeholder
:
"Search for a user"
multiple
:
true
multiple
:
$
(
'.ajax-users-select'
).
hasClass
(
'multiselect'
)
minimumInputLength
:
0
ajax
:
# instead of writing the function to execute the request we use Select2's convenient helper
url
:
"/api/v3/users.json"
...
...
app/controllers/teams/members_controller.rb
View file @
bdcaf21e
...
...
@@ -13,7 +13,7 @@ class Teams::MembersController < Teams::ApplicationController
def
create
unless
params
[
:user_ids
].
blank?
user_ids
=
params
[
:user_ids
]
user_ids
=
params
[
:user_ids
]
.
split
(
','
)
access
=
params
[
:default_project_access
]
is_admin
=
params
[
:group_admin
]
user_team
.
add_members
(
user_ids
,
access
,
is_admin
)
...
...
app/helpers/application_helper.rb
View file @
bdcaf21e
...
...
@@ -170,7 +170,9 @@ module ApplicationHelper
alias_method
:url_to_image
,
:image_url
def
users_select_tag
(
id
)
hidden_field_tag
(
id
,
''
,
class:
"ajax-users-select"
)
def
users_select_tag
(
id
,
opts
=
{})
css_class
=
"ajax-users-select"
css_class
<<
" multiselect"
if
opts
[
:multiple
]
hidden_field_tag
(
id
,
''
,
class:
css_class
)
end
end
app/models/user_team.rb
View file @
bdcaf21e
...
...
@@ -69,6 +69,9 @@ class UserTeam < ActiveRecord::Base
end
def
add_members
(
users
,
access
,
group_admin
)
# reject existing users
users
.
reject!
{
|
id
|
member_ids
.
include?
(
id
.
to_i
)
}
users
.
each
do
|
user
|
add_member
(
user
,
access
,
group_admin
)
end
...
...
app/views/team_members/_form.html.haml
View file @
bdcaf21e
...
...
@@ -12,8 +12,7 @@
.clearfix
=
f
.
label
:user_ids
,
"People"
.input
=
users_select_tag
(
:user_ids
)
-#= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).alphabetically, :id, :name_with_username), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true})
=
users_select_tag
(
:user_ids
,
multiple:
true
)
%h6
2. Set access level for them
.clearfix
...
...
app/views/teams/members/new.html.haml
View file @
bdcaf21e
...
...
@@ -20,7 +20,8 @@
%td
=
@team
.
admin?
(
member
)
?
"Admin"
:
"Member"
%td
%tr
%td
=
select_tag
:user_ids
,
options_from_collection_for_select
(
@users
,
:id
,
:name_with_username
),
multiple:
true
,
data:
{
placeholder:
'Select users'
},
class:
'chosen span5'
%td
=
users_select_tag
(
:user_ids
,
multiple:
true
)
%td
=
select_tag
:default_project_access
,
options_for_select
(
Project
.
access_options
),
{
class:
"project-access-select chosen span3"
}
%td
%span
=
check_box_tag
:group_admin
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment