Repair members management of teams
This commit is contained in:
parent
b7470440ff
commit
a7667ffc14
|
@ -1,4 +1,6 @@
|
||||||
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
|
||||||
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
|
||||||
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 @@
|
||||||
|
|
||||||
%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,25 +68,26 @@
|
||||||
|
|
||||||
%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
|
|
||||||
%th Project name
|
|
||||||
%th Max access
|
|
||||||
%th.cred Danger Zone!
|
|
||||||
- @team.projects.each do |project|
|
|
||||||
%tr.project
|
|
||||||
%td
|
|
||||||
= link_to project.name_with_namespace, [:admin, project]
|
|
||||||
%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"
|
|
||||||
%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'
|
%th Project name
|
||||||
%td= select_tag :greatest_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" }
|
%th Max access
|
||||||
%td= submit_tag 'Add', class: "btn primary", id: :assign_projects_to_team
|
%th.cred Danger Zone!
|
||||||
|
- @team.projects.each do |project|
|
||||||
|
%tr.project
|
||||||
|
%td
|
||||||
|
= link_to project.name_with_namespace, [:admin, project]
|
||||||
|
%td
|
||||||
|
%span= @team.human_max_project_access(project)
|
||||||
|
%td.bgred
|
||||||
|
= link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small"
|
||||||
|
|
||||||
|
= 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
|
||||||
|
%td
|
||||||
|
%td= link_to 'Add projects', new_admin_team_project_path(@team), class: "btn primary", id: :assign_projects_to_team
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
Loading…
Reference in a new issue