2016-04-18 12:53:32 -04:00
|
|
|
module MembersHelper
|
2016-06-02 12:05:06 -04:00
|
|
|
# Returns a `<action>_<source>_member` association, e.g.:
|
|
|
|
# - admin_project_member, update_project_member, destroy_project_member
|
|
|
|
# - admin_group_member, update_group_member, destroy_group_member
|
2016-04-18 12:53:32 -04:00
|
|
|
def action_member_permission(action, member)
|
2016-06-02 12:05:06 -04:00
|
|
|
"#{action}_#{member.type.underscore}".to_sym
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
def remove_member_message(member, user: nil)
|
|
|
|
user = current_user if defined?(current_user)
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
text = 'Are you sure you want to '
|
|
|
|
action =
|
|
|
|
if member.request?
|
|
|
|
if member.user == user
|
|
|
|
'withdraw your access request for'
|
|
|
|
else
|
|
|
|
"deny #{member.user.name}'s request to join"
|
|
|
|
end
|
|
|
|
elsif member.invite?
|
|
|
|
"revoke the invitation for #{member.invite_email} to join"
|
|
|
|
else
|
|
|
|
"remove #{member.user.name} from"
|
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
text << action << " the #{member.source.human_name} #{member.real_source_type.humanize(capitalize: false)}?"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def remove_member_title(member)
|
2016-06-02 12:05:06 -04:00
|
|
|
text = " from #{member.real_source_type.humanize(capitalize: false)}"
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
text.prepend(member.request? ? 'Deny access request' : 'Remove user')
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
def leave_confirmation_message(member_source)
|
|
|
|
"Are you sure you want to leave the " \
|
|
|
|
"\"#{member_source.human_name}\" #{member_source.class.to_s.humanize(capitalize: false)}?"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
end
|