83 lines
2.0 KiB
Ruby
83 lines
2.0 KiB
Ruby
class OrgMemberController < ApplicationController
|
|
|
|
def org_member_autocomplete
|
|
@org = Organization.find(params[:org])
|
|
@flag = params[:flag] || false
|
|
respond_to do |format|
|
|
format.js
|
|
end
|
|
end
|
|
|
|
# 组织子成员,及其分页
|
|
def org_member_paging
|
|
@organization = Organization.find(params[:org])
|
|
|
|
if User.current.admin? || User.current.admin_of_org?(@organization)
|
|
@members = OrgMember.where(:organization_id => @organization.id).all.sort
|
|
@members = paginateHelper @members, 20
|
|
respond_to do |format|
|
|
format.js
|
|
end
|
|
end
|
|
end
|
|
|
|
def create
|
|
@organization = Organization.find(params[:org])
|
|
if params[:membership].nil?
|
|
@fail_hint = l(:label_blank_user_lists_for_org)
|
|
else
|
|
member_ids = params[:membership][:user_ids]
|
|
role_id = params[:orgRole]
|
|
member_ids.each do |user_id|
|
|
member = OrgMember.create(:user_id => user_id, :created_at => Time.now)
|
|
@organization.org_members << member
|
|
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
|
|
end
|
|
@members = (@organization.org_members).sort
|
|
@members = paginateHelper @members, 20
|
|
end
|
|
respond_to do |format|
|
|
format.js
|
|
end
|
|
end
|
|
|
|
def update
|
|
@member = OrgMember.find(params[:id])
|
|
#@member.change_role params[:org_member][:role_ids]
|
|
@member_role = @member.org_member_roles[0]
|
|
@member_role.role_id = params[:org_member][:role_ids][0]
|
|
@member_role.save
|
|
@organization = @member.organization
|
|
# 成员编辑角色后分页
|
|
@members = (@organization.org_members).sort
|
|
@members = paginateHelper @members, 20
|
|
|
|
respond_to do |format|
|
|
format.js
|
|
end
|
|
end
|
|
|
|
def new
|
|
|
|
end
|
|
|
|
def destroy
|
|
member = OrgMember.find(params[:id])
|
|
@organization = member.organization
|
|
member.destroy
|
|
@members = (@organization.org_members).sort
|
|
@members = paginateHelper @members, 20
|
|
respond_to do |format|
|
|
format.js
|
|
end
|
|
end
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
def deleteOrgMember
|
|
destroy
|
|
end
|
|
end
|