Commit 6865c46c authored by Phil Hughes's avatar Phil Hughes

Changed how collections are rendered

Used variables in haml for replicated checks
Fixed broken conflict
parent 996e8024
......@@ -98,21 +98,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController
notice: notice)
end
def options
users = User.all
users = users.search(params[:search]) if params[:search].present?
users = users.page(1)
groups = Group.all
groups = groups.search(params[:search]) if params[:search].present?
groups = groups.page(1)
render json: {
Groups: groups.as_json(only: [:id, :name], methods: [:avatar_url]),
Users: users.as_json(only: [:id, :name, :username], methods: [:avatar_url]),
}
end
protected
def member_params
......
:plain
var $listItem = $('#{escape_javascript(render('shared/members/group', group_link: @group_link, group: @group_link.group))}');
var $listItem = $('#{escape_javascript(render('shared/members/group', group_link: @group_link))}');
$("#group_member_#{@group_link.id} .list-item-name").replaceWith($listItem.find('.list-item-name'));
......@@ -4,6 +4,4 @@
%strong #{@project.name}
%span.badge= group_links.size
%ul.content-list
- group_links.each do |group_link|
- group = group_link.group
= render 'shared/members/group', group_link: group_link, group: group
= render partial: 'shared/members/group', collection: group_links, as: :group_link
......@@ -4,5 +4,4 @@
%strong #{@project.name}
%span.badge= @project_members.total_count
%ul.content-list
- members.each do |member|
= render 'shared/members/member', member: member
= render partial: 'shared/members/member', collection: members, as: :member
......@@ -21,7 +21,7 @@
= search_field_tag :search, params[:search], { placeholder: 'Find existing members by name', class: 'form-control', spellcheck: false }
%button.member-search-btn{ type: "submit", "aria-label" => "Submit search" }
= icon("search")
- if @group_links.size > 0
- if @group_links.any?
= render 'groups', group_links: @group_links
= render 'team', members: @project_members
......
- group = local_assigns[:group]
- group_link = local_assigns[:group_link]
- group = group_link.group
- can_admin_member = can?(current_user, :admin_project_member, @project)
%li.member.group_member{ id: "group_member_#{group_link.id}" }
%span{ class: "list-item-name" }
= image_tag group_icon(group), class: "avatar s40", alt: ''
......@@ -13,11 +14,11 @@
Expires in #{distance_of_time_in_words_to_now(group_link.expires_at)}
.controls.member-controls
= form_tag namespace_project_group_link_path(@project.namespace, @project, group_link), method: :put, remote: true, class: 'form-horizontal js-edit-member-form' do
= select_tag 'group_link[group_access]', options_for_select(ProjectGroupLink.access_options, group_link.group_access), class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{group.id}", disabled: !can?(current_user, :admin_project_member, @project)
= select_tag 'group_link[group_access]', options_for_select(ProjectGroupLink.access_options, group_link.group_access), class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{group.id}", disabled: !can_admin_member
.prepend-left-5.clearable-input.member-form-control
= text_field_tag 'group_link[expires_at]', group_link.expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{group.id}", disabled: !can?(current_user, :admin_project_member, @project)
= text_field_tag 'group_link[expires_at]', group_link.expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{group.id}", disabled: !can_admin_member
%i.clear-icon.js-clear-input
- if can?(current_user, :admin_project_member, @project)
- if can_admin_member
= link_to namespace_project_group_link_path(@project.namespace, @project, group_link),
remote: true,
method: :delete,
......
......@@ -2,6 +2,7 @@
- show_controls = local_assigns.fetch(:show_controls, true)
- user = local_assigns.fetch(:user, member.user)
- source = member.source
- can_admin_member = can?(current_user, action_member_permission(:update, member), member)
%li.member{ class: dom_class(member), id: dom_id(member) }
%span.list-item-name
......@@ -47,18 +48,19 @@
- if show_controls
- 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?(current_user, action_member_permission(:update, member), 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
.prepend-left-5.clearable-input.member-form-control
= f.text_field :expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{member.id}", disabled: !can?(current_user, action_member_permission(:update, member), member)
= f.text_field :expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{member.id}", disabled: !can_admin_member
%i.clear-icon.js-clear-input
- else
%span.member-access-text= member.human_access
- if !user && can?(current_user, action_member_permission(:admin, member), member.source)
- if member.invite? && can?(current_user, action_member_permission(:admin, member), member.source)
= link_to 'Resend invite', polymorphic_path([:resend_invite, member]),
method: :post,
class: 'btn btn-default prepend-left-10'
- if member.request? && can?(current_user, action_member_permission(:update, member), member)
- elsif member.request? && can_admin_member
= link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]),
method: :post,
class: 'btn btn-success prepend-left-10',
......
This diff is collapsed.
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