Commit cc66ec2b authored by Phil Hughes's avatar Phil Hughes

Fixed Ruby to be better for performance

Fixed controls not showing in groups which fixes tests
parent 89c22ed5
......@@ -10,20 +10,20 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@project_members = @project.project_members
@project_members = @project_members.non_invite unless can?(current_user, :admin_project, @project)
@group = @project.group
group = @project.group
if @group
@group_members = @group.group_members
@group_members = @group_members.non_invite unless can?(current_user, :admin_group, @group)
if group
group_members = group.group_members.where.not(user_id: @project_members.select(:user_id))
group_members = group_members.non_invite unless can?(current_user, :admin_group, @group)
end
if params[:search].present?
users = @project.users.search(params[:search]).to_a
@project_members = @project_members.where(user_id: users)
user_ids = @project.users.search(params[:search]).select(:id)
@project_members = @project_members.where(user_id: user_ids)
if @group_members
users = @group.users.search(params[:search]).to_a
@group_members = @group_members.where(user_id: users)
if group_members
user_ids = group.users.search(params[:search]).select(:id)
group_members = group_members.where(user_id: user_ids)
end
@group_links = @project.project_group_links.where(group_id: @project.invited_groups.search(params[:search]).select(:id))
......@@ -31,8 +31,8 @@ class Projects::ProjectMembersController < Projects::ApplicationController
members_id = @project_members.pluck(:id)
if @group_members
members_id << @group_members.select{ |member| !@project_members.find_by(user_id: member.user_id) }.select(&:id)
if group_members
members_id << group_members.pluck(:id)
end
@project_members = Member.where(id: members_id.flatten).order(access_level: :desc).page(params[:page])
......
......@@ -12,10 +12,6 @@
= link_to user.name, user_path(user)
%span.cgray= user.to_reference
- if member.real_source_type == 'Group'
&middot;
%span.cblue=member.group.name
- if user == current_user
%span.label.label-success.prepend-left-5 It's you
......@@ -24,8 +20,8 @@
%strong Blocked
- if source.instance_of?(Group) && !@group
= link_to source, class: "member-group-link prepend-left-5" do
= #{source.name}"
&middot;
= link_to source.name, source, class: "member-group-link"
.hidden-xs.cgray
- if member.request?
......@@ -49,7 +45,7 @@
= time_ago_with_tooltip(member.created_at)
- if show_roles
.controls.member-controls
- if show_controls && member.real_source_type == 'Project'
- if show_controls && (member.respond_to?(:group) && @members) || (member.respond_to?(:project) && @project_members)
- if user != current_user
= form_for member, remote: true, html: { class: 'form-horizontal js-edit-member-form' } do |f|
= f.select :access_level, options_for_select(member.class.access_level_roles, member.access_level), {}, class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{member.id}", disabled: !can_admin_member
......
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