Commit aaa1c94239df831d10489d686d8883b49d601f43
1 parent
08fded3f
Exists in
master
and in
4 other branches
Manage team from groups page. Phase 1
Showing
5 changed files
with
66 additions
and
15 deletions
Show diff stats
app/controllers/groups_controller.rb
| @@ -47,7 +47,12 @@ class GroupsController < ApplicationController | @@ -47,7 +47,12 @@ class GroupsController < ApplicationController | ||
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | def people | 49 | def people |
| 50 | - @users = group.users | 50 | + @project = group.projects.find(params[:project_id]) if params[:project_id] |
| 51 | + @users = @project ? @project.users : group.users | ||
| 52 | + | ||
| 53 | + if @project | ||
| 54 | + @team_member = @project.users_projects.new | ||
| 55 | + end | ||
| 51 | end | 56 | end |
| 52 | 57 | ||
| 53 | protected | 58 | protected |
app/controllers/team_members_controller.rb
| @@ -21,7 +21,11 @@ class TeamMembersController < ProjectResourceController | @@ -21,7 +21,11 @@ class TeamMembersController < ProjectResourceController | ||
| 21 | params[:project_access] | 21 | params[:project_access] |
| 22 | ) | 22 | ) |
| 23 | 23 | ||
| 24 | - redirect_to project_team_index_path(@project) | 24 | + if params[:redirect_to] |
| 25 | + redirect_to params[:redirect_to] | ||
| 26 | + else | ||
| 27 | + redirect_to project_team_index_path(@project) | ||
| 28 | + end | ||
| 25 | end | 29 | end |
| 26 | 30 | ||
| 27 | def update | 31 | def update |
| @@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
| 1 | += form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f| | ||
| 2 | + %fieldset | ||
| 3 | + %legend= "New Team member(s) for #{@project.name}" | ||
| 4 | + | ||
| 5 | + %h6 1. Choose people you want in the team | ||
| 6 | + .clearfix | ||
| 7 | + = f.label :user_ids, "People" | ||
| 8 | + .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).all, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) | ||
| 9 | + | ||
| 10 | + %h6 2. Set access level for them | ||
| 11 | + .clearfix | ||
| 12 | + = f.label :project_access, "Project Access" | ||
| 13 | + .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select chosen" | ||
| 14 | + | ||
| 15 | + .form-actions | ||
| 16 | + = hidden_field_tag :redirect_to, people_group_path(@group, project_id: @project.id) | ||
| 17 | + = f.submit 'Add', class: "btn save-btn" | ||
| 18 | + |
| @@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
| 1 | += form_tag people_group_path(@group), method: 'get' do | ||
| 2 | + %fieldset | ||
| 3 | + %legend Projects: | ||
| 4 | + %ul.nav.nav-pills.nav-stacked | ||
| 5 | + - @projects.each do |project| | ||
| 6 | + %li{class: ("active" if params[:project_id] == project.id.to_s)} | ||
| 7 | + = link_to people_group_path(@group, project_id: project.id) do | ||
| 8 | + = project.name_with_namespace | ||
| 9 | + %small.right= project.users.count | ||
| 10 | + | ||
| 11 | + %fieldset | ||
| 12 | + %hr | ||
| 13 | + = link_to "Reset", people_group_path(@group), class: 'btn right' | ||
| 14 | + |
app/views/groups/people.html.haml
| 1 | -.ui-box | ||
| 2 | - %h5 | ||
| 3 | - People | ||
| 4 | - %small | ||
| 5 | - (#{@users.size}) | ||
| 6 | - %ul.unstyled | ||
| 7 | - - @users.each do |user| | ||
| 8 | - %li.wll | ||
| 9 | - = image_tag gravatar_icon(user.email, 16), class: "avatar s16" | ||
| 10 | - %strong= user.name | ||
| 11 | - %span.cgray= user.email | ||
| 12 | - - if @group.owner == user | ||
| 13 | - %span.btn.btn-small.disabled.right Owner | 1 | +.row |
| 2 | + .span3 | ||
| 3 | + = render 'people_filter' | ||
| 4 | + .span9 | ||
| 5 | + - if @project && can?(current_user, :manage_group, @group) | ||
| 6 | + = render "new_member" | ||
| 7 | + .ui-box | ||
| 8 | + %h5 | ||
| 9 | + Team | ||
| 10 | + %small | ||
| 11 | + (#{@users.size}) | ||
| 12 | + %ul.unstyled | ||
| 13 | + - @users.each do |user| | ||
| 14 | + %li.wll | ||
| 15 | + = image_tag gravatar_icon(user.email, 16), class: "avatar s16" | ||
| 16 | + %strong= user.name | ||
| 17 | + %span.cgray= user.email | ||
| 18 | + - if @project | ||
| 19 | + - if @project.owner == user | ||
| 20 | + %span.btn.btn-small.disabled.right Project Owner | ||
| 21 | + - else | ||
| 22 | + - if @group.owner == user | ||
| 23 | + %span.btn.btn-small.disabled.right Group Owner | ||
| 14 | 24 |