2013-01-07 13:48:57 -05:00
|
|
|
module GroupsHelper
|
2015-04-10 09:14:14 -04:00
|
|
|
def remove_user_from_group_message(group, member)
|
|
|
|
if member.user
|
|
|
|
"Are you sure you want to remove \"#{member.user.name}\" from \"#{group.name}\"?"
|
|
|
|
else
|
2015-04-14 06:25:16 -04:00
|
|
|
"Are you sure you want to revoke the invitation for \"#{member.invite_email}\" to join \"#{group.name}\"?"
|
2015-04-10 09:14:14 -04:00
|
|
|
end
|
2014-02-07 11:59:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def leave_group_message(group)
|
|
|
|
"Are you sure you want to leave \"#{group}\" group?"
|
2013-06-17 09:51:43 -04:00
|
|
|
end
|
2014-12-16 09:58:15 -05:00
|
|
|
|
2014-02-13 15:45:51 -05:00
|
|
|
def should_user_see_group_roles?(user, group)
|
|
|
|
if user
|
|
|
|
user.is_admin? || group.members.exists?(user_id: user.id)
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
2013-11-13 03:35:10 -05:00
|
|
|
|
2015-03-12 16:56:53 -04:00
|
|
|
def group_icon(group)
|
|
|
|
if group.is_a?(String)
|
|
|
|
group = Group.find_by(path: group)
|
|
|
|
end
|
|
|
|
|
|
|
|
if group && group.avatar.present?
|
|
|
|
group.avatar.url
|
|
|
|
else
|
2015-09-16 13:52:23 -04:00
|
|
|
'no_group_avatar.png'
|
2015-03-12 16:56:53 -04:00
|
|
|
end
|
|
|
|
end
|
2015-09-07 07:18:11 -04:00
|
|
|
|
2015-09-17 06:16:24 -04:00
|
|
|
def group_title(group, name = nil, url = nil)
|
|
|
|
full_title = link_to(simple_sanitize(group.name), group_path(group))
|
|
|
|
full_title += ' · '.html_safe + link_to(simple_sanitize(name), url) if name
|
|
|
|
|
2015-09-07 07:18:11 -04:00
|
|
|
content_tag :span do
|
2015-09-17 06:16:24 -04:00
|
|
|
full_title
|
2015-09-07 07:18:11 -04:00
|
|
|
end
|
|
|
|
end
|
2013-01-07 13:48:57 -05:00
|
|
|
end
|