~fabrixxm/activist

3f2b61f0c52f2921d03361567dc2cf3253ca9224 — fabrixxm a month ago 2f564dc
UI: notification button in mobile footer
M activist/components/notifications/__init__.py => activist/components/notifications/__init__.py +14 -0
@@ 21,6 21,20 @@ def notifications_menu(ctx:dict) -> Result:


@component
def notifications_button(ctx:dict) -> Result:
    if not g.get('user', None):
        abort(401)

    notifications = db.Notification.get_notifications().where(seen = False).count()

    return ctx | {
        'notifications': notifications,
        'hx_trigger': 'notifications'
    }



@component
def notification(ctx:dict, notification:db.NotificationRef):
    if isinstance(notification, (int, str)):
        obj = db.Notification.get(int(notification))

A activist/components/notifications/notifications_button.tpl.j2 => activist/components/notifications/notifications_button.tpl.j2 +4 -0
@@ 0,0 1,4 @@
<a href="{{ url_for('notifications') }}" {{ hx() }}
        class="btn btn-link f-fill {{ class(active = request.endpoint == 'notifications') }}" title="Notifications">
    <i class="icon i-bell {{ class(badge = notifications) }}" {% if notifications %}data-badge="{{ notifications }}"{% endif %}></i>
</a>

M activist/templates/f/footer-mobile.tpl.j2 => activist/templates/f/footer-mobile.tpl.j2 +17 -14
@@ 1,20 1,23 @@
<footer class="navbar mobile show-md">
	<section class="navbar-section">
	{% if g.user %}
    <section class="navbar-section">
    {% if g.user %}
        <a href="{{ url_for('network') }}" class="btn btn-link f-fill {{ class({'active':request.endpoint == 'network'}) }}" title="Newtork">
			<i class="icon i-messages-square"></i>
		</a>
		<a href="{{ url_for('contacts') }}" class="btn btn-link f-fill {{ class({'active':request.endpoint == 'contacts'}) }}" title="Contacts">
			<i class="icon i-users"></i>
		</a>
            <i class="icon i-messages-square"></i>
        </a>

        {{ component('notifications_button') }}

        <a href="{{ url_for('contacts') }}" class="btn btn-link f-fill {{ class({'active':request.endpoint == 'contacts'}) }}" title="Contacts">
            <i class="icon i-users"></i>
        </a>
        
        <a href="{{ url_for('logout') }}" class="btn btn-link" title="Logout">
			<i class="icon i-log-out"></i>
		</a>
	{% else %}
		<a href="#login-modal" class="btn btn-lg btn-link" title="Login">
			<i class="icon i-key-round"></i>
		</a>
	{% endif %}		
            <i class="icon i-log-out"></i>
        </a>
    {% else %}
        <a href="#login-modal" class="btn btn-lg btn-link" title="Login">
            <i class="icon i-key-round"></i>
        </a>
    {% endif %}		
    </section>
</footer>