Commit a7667ffc authored by Andrey Kumanyaev's avatar Andrey Kumanyaev Committed by Dmitriy Zaporozhets

Repair members management of teams

parent b7470440
class Admin::Teams::MembersController < Admin::Teams::ApplicationController class Admin::Teams::MembersController < Admin::Teams::ApplicationController
before_filter :team_member, only: [:edit, :destroy, :update]
def new def new
@users = User.active @users = User.active
@users = @users.not_in_team(@team) if @team.members.any? @users = @users.not_in_team(@team) if @team.members.any?
...@@ -17,11 +19,9 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController ...@@ -17,11 +19,9 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end end
def edit def edit
@member = @team.members.find(params[:id])
end end
def update def update
@member = @team.members.find(params[:id])
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]} options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
if @team.update_membership(@member, options) if @team.update_membership(@member, options)
redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.' redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.'
...@@ -31,5 +31,16 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController ...@@ -31,5 +31,16 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end end
def destroy def destroy
if @team.remove_member(@member)
redirect_to admin_team_path(@team), notice: "Member was successfully removed from team."
else
redirect_to admin_team_members(@team), notice: "Something wrong."
end
end
private
def team_member
@member = @team.members.find(params[:id])
end end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
%fieldset %fieldset
%legend Members (#{@team.members.count}) %legend Members (#{@team.members.count})
= form_tag add_members_admin_team_path(@team), id: "team_members", class: "bulk_import", method: :post do = form_tag admin_team_members_path(@team), id: "team_members", class: "bulk_import", method: :post do
%table#members_list %table#members_list
%thead %thead
%tr %tr
......
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
%fieldset %fieldset
%legend Projects (#{@team.projects.count}) %legend Projects (#{@team.projects.count})
= form_tag delegate_projects_admin_team_path(@team), id: "assign_projects", class: "bulk_import", method: :post do
%table#projects_list %table#projects_list
%thead %thead
%tr %tr
...@@ -82,11 +81,13 @@ ...@@ -82,11 +81,13 @@
%td %td
%span= @team.human_max_project_access(project) %span= @team.human_max_project_access(project)
%td.bgred %td.bgred
= link_to 'Relegate', relegate_project_admin_team_path(@team, project_id: project.id), confirm: 'Remove project from team and move to global namespace. Are you sure?', method: :delete, class: "btn danger small" = link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small"
&nbsp;
= link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn danger small"
%tr %tr
%td= select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5' %td
%td= select_tag :greatest_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" } %td
%td= submit_tag 'Add', class: "btn primary", id: :assign_projects_to_team %td= link_to 'Add projects', new_admin_team_project_path(@team), class: "btn primary", id: :assign_projects_to_team
:javascript :javascript
$(function(){ $(function(){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment