forked from mirrors/bookwyrm
Link notification block to its main path
This commit is contained in:
parent
2a9f8f8122
commit
b9632039f9
11 changed files with 62 additions and 2 deletions
22
bookwyrm/static/js/block_href.js
Normal file
22
bookwyrm/static/js/block_href.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* exported BlockHref */
|
||||
/* globals BookWyrm */
|
||||
|
||||
let BlockHref = new class {
|
||||
constructor() {
|
||||
document.querySelectorAll('[data-href]')
|
||||
.forEach(t => t.addEventListener('click', this.followLink.bind(this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow a fake link
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
followLink(event) {
|
||||
const url = event.currentTarget.dataset.href;
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
}();
|
||||
|
|
@ -3,6 +3,14 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{% if notification.related_list_item.approved %}
|
||||
{{ notification.related_list_item.book_list.local_path }}
|
||||
{% else %}
|
||||
{% url 'list-curate' notification.related_list_item.book_list.id %}
|
||||
{% endif %}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-plus"></span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{{ notification.related_status.local_path }}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-boost"></span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{{ notification.related_status.local_path }}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-heart"></span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{{ notification.related_user.local_path }}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-local"></span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{% extends 'notifications/items/item_layout.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{% url 'import-status' notification.related_import.id %}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-list"></span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% load humanize %}
|
||||
{% load bookwyrm_tags %}
|
||||
{% related_status notification as related_status %}
|
||||
<div class="notification {% if notification.id in unread %} is-primary{% endif %}">
|
||||
<div class="notification is-clickable {% if notification.id in unread %} is-primary{% endif %}" data-href="{% block primary_link %}{% endblock %}">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-narrow is-size-3 {% if notification.id in unread%}has-text-white{% else %}has-text-grey{% endif %}">
|
||||
{% block icon %}{% endblock %}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{{ notification.related_status.local_path }}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-comment"></span>
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{{ notification.related_status.local_path }}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-comments"></span>
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
{% load i18n %}
|
||||
|
||||
{% block primary_link %}{% spaceless %}
|
||||
{% url 'settings-report' notification.related_report.id %}
|
||||
{% endspaceless %}{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
<span class="icon icon-warning"></span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{% trans "Notifications" %}{% endblock %}
|
||||
|
||||
|
@ -45,3 +46,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static "js/block_href.js" %}?v={{ js_cache }}"></script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue