From aaa1c94239df831d10489d686d8883b49d601f43 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Thu, 29 Nov 2012 20:14:05 +0300 Subject: [PATCH] Manage team from groups page. Phase 1 --- app/controllers/groups_controller.rb | 7 ++++- app/controllers/team_members_controller.rb | 6 +++- app/views/groups/_new_member.html.haml | 18 +++++++++++ app/views/groups/_people_filter.html.haml | 14 +++++++++ app/views/groups/people.html.haml | 36 ++++++++++++++-------- 5 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 app/views/groups/_new_member.html.haml create mode 100644 app/views/groups/_people_filter.html.haml diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 880092e48e..93c495363d 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -47,7 +47,12 @@ class GroupsController < ApplicationController end def people - @users = group.users + @project = group.projects.find(params[:project_id]) if params[:project_id] + @users = @project ? @project.users : group.users + + if @project + @team_member = @project.users_projects.new + end end protected diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 37ed74b231..311af62b8d 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -21,7 +21,11 @@ class TeamMembersController < ProjectResourceController params[:project_access] ) - redirect_to project_team_index_path(@project) + if params[:redirect_to] + redirect_to params[:redirect_to] + else + redirect_to project_team_index_path(@project) + end end def update diff --git a/app/views/groups/_new_member.html.haml b/app/views/groups/_new_member.html.haml new file mode 100644 index 0000000000..f48c2c23d8 --- /dev/null +++ b/app/views/groups/_new_member.html.haml @@ -0,0 +1,18 @@ += form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f| + %fieldset + %legend= "New Team member(s) for #{@project.name}" + + %h6 1. Choose people you want in the team + .clearfix + = f.label :user_ids, "People" + .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}) + + %h6 2. Set access level for them + .clearfix + = f.label :project_access, "Project Access" + .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select chosen" + + .form-actions + = hidden_field_tag :redirect_to, people_group_path(@group, project_id: @project.id) + = f.submit 'Add', class: "btn save-btn" + diff --git a/app/views/groups/_people_filter.html.haml b/app/views/groups/_people_filter.html.haml new file mode 100644 index 0000000000..79a1b01a5f --- /dev/null +++ b/app/views/groups/_people_filter.html.haml @@ -0,0 +1,14 @@ += form_tag people_group_path(@group), method: 'get' do + %fieldset + %legend Projects: + %ul.nav.nav-pills.nav-stacked + - @projects.each do |project| + %li{class: ("active" if params[:project_id] == project.id.to_s)} + = link_to people_group_path(@group, project_id: project.id) do + = project.name_with_namespace + %small.right= project.users.count + + %fieldset + %hr + = link_to "Reset", people_group_path(@group), class: 'btn right' + diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 0d176e1e23..c43b0d4176 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -1,14 +1,24 @@ -.ui-box - %h5 - People - %small - (#{@users.size}) - %ul.unstyled - - @users.each do |user| - %li.wll - = image_tag gravatar_icon(user.email, 16), class: "avatar s16" - %strong= user.name - %span.cgray= user.email - - if @group.owner == user - %span.btn.btn-small.disabled.right Owner +.row + .span3 + = render 'people_filter' + .span9 + - if @project && can?(current_user, :manage_group, @group) + = render "new_member" + .ui-box + %h5 + Team + %small + (#{@users.size}) + %ul.unstyled + - @users.each do |user| + %li.wll + = image_tag gravatar_icon(user.email, 16), class: "avatar s16" + %strong= user.name + %span.cgray= user.email + - if @project + - if @project.owner == user + %span.btn.btn-small.disabled.right Project Owner + - else + - if @group.owner == user + %span.btn.btn-small.disabled.right Group Owner -- 2.30.9