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
before_filter :team_member, only: [:edit, :destroy, :update]
def new
@users = User.active
@users = @users.not_in_team(@team) if @team.members.any?
......@@ -17,11 +19,9 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end
def edit
@member = @team.members.find(params[:id])
end
def update
@member = @team.members.find(params[:id])
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
if @team.update_membership(@member, options)
redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.'
......@@ -31,5 +31,16 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end
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
......@@ -3,7 +3,7 @@
%fieldset
%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
%thead
%tr
......
......@@ -68,7 +68,6 @@
%fieldset
%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
%thead
%tr
......@@ -82,11 +81,13 @@
%td
%span= @team.human_max_project_access(project)
%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
%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= select_tag :greatest_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" }
%td= submit_tag 'Add', class: "btn primary", id: :assign_projects_to_team
%td
%td
%td= link_to 'Add projects', new_admin_team_project_path(@team), class: "btn primary", id: :assign_projects_to_team
:javascript
$(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