Commit 60ac508c authored by Matthieu Fesselier's avatar Matthieu Fesselier

feature: redirect to route on click notification

parent 850a2757
Pipeline #2557 passed with stage
in 27 seconds
......@@ -16,6 +16,8 @@
data-automaticSilentRenew="true"
data-loadUserInfo="true"
></script>
<script type="module" src="https://unpkg.com/@startinblox/core@0.5"></script>
<script type="module" src="https://unpkg.com/@startinblox/router"></script>
<style>
:root{
......@@ -26,6 +28,24 @@
<body>
<h1>SIB Notifications - Demo</h1>
<sib-notifications bind-user id-suffix="inbox"></sib-notifications>
<sib-notifications
bind-user
id-suffix="inbox"
extra-context='{"doap": "http://usefulinc.com/ns/doap#"}'
></sib-notifications>
<sib-router default-route="home">
<sib-route name="home"></sib-route>
<sib-route name="project" rdf-type="doap:project"></sib-route>
</sib-router>
<div id="home">
<h1>Home</h1>
</div>
<div id="project">
<h1>Project</h1>
<sib-display bind-resources data-fields="name"></sib-display>
</div>
</body>
</html>
import { SIBTemplateElement, SIBDisplay, store } from 'https://unpkg.com/@startinblox/core@0.5';
import { SIBTemplateElement, store } from 'https://unpkg.com/@startinblox/core@0.5';
import { importCSS } from 'https://cdn.happy-dev.fr/sib-core/helpers.js'
import Favico from 'https://dev.jspm.io/favico.js-slevomat';
......@@ -32,7 +32,8 @@ class SIBNotifications extends SIBTemplateElement {
static get propsDefinition() {
return {
dataSrc: 'data-src',
idSuffix: 'id-suffix'
idSuffix: 'id-suffix',
extraContext: 'extra-context'
}
}
......@@ -65,13 +66,17 @@ class SIBNotifications extends SIBTemplateElement {
}
_onClickNotification(target) {
window.dispatchEvent(new CustomEvent('requestNavigation', {detail: {resource: target.resource.object}})) // TODO : test
store.get(target.resource.object['@id'], JSON.parse(this.props.extraContext)).then((resource) => {
window.dispatchEvent(new CustomEvent('requestNavigation', { detail: { resource: resource } }))
this.querySelector('details').removeAttribute("open")
})
}
_updateUnread(resource) {
let unread = 0
resource['ldp:contains'].forEach(notification => {
if(!notification.read) unread ++
if (!notification.read) unread++
// TODO : read / unread
})
// Update favicon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment