Skip to content

Commit

Permalink
general: improve account menu entry visibility
Browse files Browse the repository at this point in the history
Updates the account menu entry by using the full patron name instead of
initials (limited to 30 characters).

Closes rero#1332

Co-Authored-by: Renaud Michotte <[email protected]>
  • Loading branch information
zannkukai committed Nov 24, 2020
1 parent 5d9ba23 commit 5c0a20b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rero_ils/templates/rero_ils/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{%- for item in current_menu.submenu('main').children|sort(attribute='order') if item.visible %}
{%- if item.children %}
<li class="nav-item{{ ' active' if item.active else ''}}">
<a class="nav-link collapsed" data-toggle="collapse" role="button"
<a class="nav-link collapsed {{ item.cssClass }}" data-toggle="collapse" role="button"
aria-controls="collapseExample" aria-expanded="false"
href="#{{ item.name }}"
{{ "id={}".format(item.id) if item.id }}
Expand Down
22 changes: 13 additions & 9 deletions rero_ils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,29 @@ def init_menu_profile():
"""Create the profile header menu."""
item = current_menu.submenu('main.profile')
if current_patron:
session['user_initials'] = current_patron.initial
session['user_name'] = current_patron.formatted_name
else:
try:
session['user_initials'] = current_user.email
session['user_name'] = current_user.email
# AnonymousUser
except AttributeError:
session.pop('user_initials', None)
account = session.get('user_initials', _('My Account'))
session.pop('user_name', None)
account = session.get('user_name', _('My Account'))
if len(account) > 30:
account = account[:30] + '…'

rero_register(
item,
endpoint=None,
text='{icon} <span class="{visible}">{account}</span>'.format(
icon='<i class="fa fa-user"></i>',
visible='visible-md-inline visible-lg-inline',
account=account
),
text='<span class="btn btn-sm btn-success">{icon} '
'<span class="{visible}">{account}</span><span>'.format(
icon='<i class="fa fa-user"></i>',
visible='visible-md-inline visible-lg-inline',
account=account
),
order=1,
id='my-account-menu',
cssClass='py-1'
)

item = current_menu.submenu('main.profile.login')
Expand Down

0 comments on commit 5c0a20b

Please sign in to comment.