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