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|
|
new_text = text.gsub(sa_user) do |el|
|
||||||
match = el.match(sa_user)
|
match = el.match(sa_user)
|
||||||
user = User.find_by_id(match[2].base62_decode)
|
user = User.find_by_id(match[2].base62_decode)
|
||||||
|
next unless user
|
||||||
team ||= current_team
|
team ||= current_team
|
||||||
popover_for_user_name(user, team)
|
popover_for_user_name(user, team)
|
||||||
end
|
end
|
||||||
|
@ -192,13 +193,8 @@ module ApplicationHelper
|
||||||
|
|
||||||
# Generate smart annotation link for one user object
|
# Generate smart annotation link for one user object
|
||||||
def popover_for_user_name(user, team = nil)
|
def popover_for_user_name(user, team = nil)
|
||||||
if user &&
|
user_still_in_team = user.teams.include?(team)
|
||||||
team &&
|
|
||||||
UserTeam.user_in_team(user, team).any?
|
|
||||||
user_t = user.user_teams
|
|
||||||
.where('user_teams.team_id = ?', team)
|
|
||||||
.first
|
|
||||||
end
|
|
||||||
user_description = %(<div class='col-xs-4'>
|
user_description = %(<div class='col-xs-4'>
|
||||||
<img src='#{user_avatar_absolute_url(user, :thumb)}'
|
<img src='#{user_avatar_absolute_url(user, :thumb)}'
|
||||||
alt='thumb'></div><div class='col-xs-8'>
|
alt='thumb'></div><div class='col-xs-8'>
|
||||||
|
@ -207,9 +203,12 @@ module ApplicationHelper
|
||||||
<span class='glyphicon glyphicon-remove' aria-hidden='true'></span>
|
<span class='glyphicon glyphicon-remove' aria-hidden='true'></span>
|
||||||
</div></div><div class='row'><div class='col-xs-12'>
|
</div></div><div class='row'><div class='col-xs-12'>
|
||||||
<p class='silver'>#{user.email}</p>)
|
<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>
|
user_description += %(<p>
|
||||||
#{I18n.t('atwho.popover_html',
|
#{I18n.t('atwho.users.popover_html',
|
||||||
role: user_t.role.capitalize,
|
role: user_t.role.capitalize,
|
||||||
team: user_t.team.name,
|
team: user_t.team.name,
|
||||||
time: user_t.created_at.strftime('%B %Y'))}
|
time: user_t.created_at.strftime('%B %Y'))}
|
||||||
|
@ -218,13 +217,16 @@ module ApplicationHelper
|
||||||
user_description += %(<p></p></div></div></div>)
|
user_description += %(<p></p></div></div></div>)
|
||||||
end
|
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)}'" \
|
raw("<img src='#{user_avatar_absolute_url(user, :icon_small)}'" \
|
||||||
"alt='avatar' class='atwho-user-img-popover'>") +
|
"alt='avatar' class='atwho-user-img-popover'>") +
|
||||||
raw('<a onClick="$(this).popover(\'show\')" ' \
|
raw('<a onClick="$(this).popover(\'show\')" ' \
|
||||||
'class="atwho-user-popover" data-container="body" ' \
|
'class="atwho-user-popover" data-container="body" ' \
|
||||||
'data-html="true" tabindex="0" data-trigger="focus" ' \
|
'data-html="true" tabindex="0" data-trigger="focus" ' \
|
||||||
'data-placement="top" data-toggle="popover" data-content="') +
|
'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
|
end
|
||||||
|
|
||||||
def user_avatar_absolute_url(user, style)
|
def user_avatar_absolute_url(user, style)
|
||||||
|
|
|
@ -1575,10 +1575,11 @@ en:
|
||||||
confirm_2: "to confirm"
|
confirm_2: "to confirm"
|
||||||
dismiss_1: "esc"
|
dismiss_1: "esc"
|
||||||
dismiss_2: "to dismiss"
|
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:
|
res:
|
||||||
archived: "(archived)"
|
archived: "(archived)"
|
||||||
|
removed: "(removed)"
|
||||||
deleted: "(deleted)"
|
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:
|
zip_export:
|
||||||
notification_title: 'Your package is ready to be exported!'
|
notification_title: 'Your package is ready to be exported!'
|
||||||
|
|
Loading…
Reference in a new issue