mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 12:43:06 +08:00
Merge pull request #643 from mz3944/mz-SCI-1305
Handled user removal from the team for user smart annotation [fixes SCI-1305]
This commit is contained in:
commit
689587c4fc
2 changed files with 19 additions and 16 deletions
|
@ -184,6 +184,7 @@ module ApplicationHelper
|
|||
new_text = text.gsub(sa_user) do |el|
|
||||
match = el.match(sa_user)
|
||||
user = User.find_by_id(match[2].base62_decode)
|
||||
next unless user
|
||||
team ||= current_team
|
||||
popover_for_user_name(user, team)
|
||||
end
|
||||
|
@ -192,13 +193,8 @@ module ApplicationHelper
|
|||
|
||||
# Generate smart annotation link for one user object
|
||||
def popover_for_user_name(user, team = nil)
|
||||
if user &&
|
||||
team &&
|
||||
UserTeam.user_in_team(user, team).any?
|
||||
user_t = user.user_teams
|
||||
.where('user_teams.team_id = ?', team)
|
||||
.first
|
||||
end
|
||||
user_still_in_team = user.teams.include?(team)
|
||||
|
||||
user_description = %(<div class='col-xs-4'>
|
||||
<img src='#{user_avatar_absolute_url(user, :thumb)}'
|
||||
alt='thumb'></div><div class='col-xs-8'>
|
||||
|
@ -207,9 +203,12 @@ module ApplicationHelper
|
|||
<span class='glyphicon glyphicon-remove' aria-hidden='true'></span>
|
||||
</div></div><div class='row'><div class='col-xs-12'>
|
||||
<p class='silver'>#{user.email}</p>)
|
||||
if team.present?
|
||||
if user_still_in_team
|
||||
user_t = user.user_teams
|
||||
.where('user_teams.team_id = ?', team)
|
||||
.first
|
||||
user_description += %(<p>
|
||||
#{I18n.t('atwho.popover_html',
|
||||
#{I18n.t('atwho.users.popover_html',
|
||||
role: user_t.role.capitalize,
|
||||
team: user_t.team.name,
|
||||
time: user_t.created_at.strftime('%B %Y'))}
|
||||
|
@ -218,13 +217,16 @@ module ApplicationHelper
|
|||
user_description += %(<p></p></div></div></div>)
|
||||
end
|
||||
|
||||
user_name = user.full_name
|
||||
user_name << ' ' + I18n.t('atwho.res.removed') if !user_still_in_team
|
||||
|
||||
raw("<img src='#{user_avatar_absolute_url(user, :icon_small)}'" \
|
||||
"alt='avatar' class='atwho-user-img-popover'>") +
|
||||
raw('<a onClick="$(this).popover(\'show\')" ' \
|
||||
'class="atwho-user-popover" data-container="body" ' \
|
||||
'data-html="true" tabindex="0" data-trigger="focus" ' \
|
||||
'data-placement="top" data-toggle="popover" data-content="') +
|
||||
raw(user_description) + raw('" >') + user.full_name + raw('</a>')
|
||||
raw(user_description) + raw('" >') + user_name + raw('</a>')
|
||||
end
|
||||
|
||||
def user_avatar_absolute_url(user, style)
|
||||
|
|
|
@ -1575,10 +1575,11 @@ en:
|
|||
confirm_2: "to confirm"
|
||||
dismiss_1: "esc"
|
||||
dismiss_2: "to dismiss"
|
||||
popover_html: "<span class='silver'>Team:</span> %{team} <br> <span class='silver'>Role:</span> %{role} <br> <span class='silver'>Joined:</span> %{time}"
|
||||
res:
|
||||
archived: "(archived)"
|
||||
removed: "(removed)"
|
||||
deleted: "(deleted)"
|
||||
popover_html: "<span class='silver'>Team:</span> %{team} <br> <span class='silver'>Role:</span> %{role} <br> <span class='silver'>Joined:</span> %{time}"
|
||||
|
||||
zip_export:
|
||||
notification_title: 'Your package is ready to be exported!'
|
||||
|
|
Loading…
Reference in a new issue