Commit 6c086c32 authored by Matthieu Fesselier's avatar Matthieu Fesselier

WIP: core 0.7 to 0.8

parent 0864a99b
Pipeline #4327 passed with stage
in 27 seconds
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
</sib-auth-provider> </sib-auth-provider>
</sib-auth> </sib-auth>
<script type="module" src="https://unpkg.com/@startinblox/core@0.7"></script>
<style> <style>
:root{ :root{
--sib-badge-theme: #ffd759; --sib-badge-theme: #ffd759;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</sib-auth-provider> </sib-auth-provider>
</sib-auth> </sib-auth>
<script type="module" src="https://unpkg.com/@startinblox/core@0.7"></script> <script type="module" src="https://unpkg.com/@startinblox/core@beta"></script>
<script type="module" src="https://unpkg.com/@startinblox/router"></script> <script type="module" src="https://unpkg.com/@startinblox/router"></script>
<style> <style>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</sib-auth-provider> </sib-auth-provider>
</sib-auth> </sib-auth>
<script type="module" src="https://unpkg.com/@startinblox/core@0.7"></script> <script type="module" src="https://unpkg.com/@startinblox/core@beta"></script>
<script type="module" src="https://unpkg.com/@startinblox/router"></script> <script type="module" src="https://unpkg.com/@startinblox/router"></script>
<style> <style>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<div id="project"> <div id="project">
<h1>Project</h1> <h1>Project</h1>
<sib-display bind-resources data-fields="name"></sib-display> <sib-display bind-resources fields="name"></sib-display>
</div> </div>
</body> </body>
</html> </html>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</sib-auth-provider> </sib-auth-provider>
</sib-auth> </sib-auth>
<script type="module" src="https://unpkg.com/@startinblox/core@0.7"></script> <script type="module" src="https://unpkg.com/@startinblox/core@beta"></script>
<script type="module" src="https://unpkg.com/@startinblox/router"></script> <script type="module" src="https://unpkg.com/@startinblox/router"></script>
<style> <style>
......
import { SIBTemplateElement, Helpers } from 'https://unpkg.com/@startinblox/core@0.7'; import { SIBTemplateElement, Helpers } from 'https://unpkg.com/@startinblox/core@beta';
const base_url = import.meta.url.replace(/\/[^\/]*$/, ''); const base_url = import.meta.url.replace(/\/[^\/]*$/, '');
Helpers.importCSS(`${base_url}/css/badge.css`) Helpers.importCSS(`${base_url}/css/badge.css`)
...@@ -34,8 +34,8 @@ class SIBBadge extends SIBTemplateElement { ...@@ -34,8 +34,8 @@ class SIBBadge extends SIBTemplateElement {
return ` return `
<sib-display <sib-display
bind-user bind-user
id-suffix="inbox" nested-field="inbox"
data-fields fields="none"
search-fields="unread, object" search-fields="unread, object"
search-value-unread="true" search-value-unread="true"
search-value-object="${this.resourceId}" search-value-object="${this.resourceId}"
......
import { SIBTemplateElement, store, Helpers } from 'https://unpkg.com/@startinblox/core@0.7'; import { SIBTemplateElement, store, Helpers } from 'https://unpkg.com/@startinblox/core@beta';
import Favico from 'https://dev.jspm.io/favico.js-slevomat'; import Favico from 'https://dev.jspm.io/favico.js-slevomat';
const base_url = import.meta.url.replace(/\/[^\/]*$/, ''); const base_url = import.meta.url.replace(/\/[^\/]*$/, '');
...@@ -27,7 +27,7 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -27,7 +27,7 @@ class SIBNotifications extends SIBTemplateElement {
if (unreadButton) { if (unreadButton) {
window.dispatchEvent(new CustomEvent('read', { window.dispatchEvent(new CustomEvent('read', {
detail: { detail: {
resource: unreadButton.closest('sib-display').resource // get resource from sib display resource: unreadButton.closest('sib-display').component.resource // get resource from sib display
} }
})); }));
unreadButton.disabled = true unreadButton.disabled = true
...@@ -104,8 +104,8 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -104,8 +104,8 @@ class SIBNotifications extends SIBTemplateElement {
if (this.props.extraContext) { if (this.props.extraContext) {
extraContext = JSON.parse(this.props.extraContext) extraContext = JSON.parse(this.props.extraContext)
} }
const context = { ...target.context, ...extraContext } const context = { ...target.component.context, ...extraContext }
store.get(target.resource.object, context).then((resource) => { store.get(target.component.resource.object, context).then((resource) => {
if (!resource) return; if (!resource) return;
window.dispatchEvent(new CustomEvent('requestNavigation', { detail: { resource: resource } })) window.dispatchEvent(new CustomEvent('requestNavigation', { detail: { resource: resource } }))
this.querySelector('details').removeAttribute("open") this.querySelector('details').removeAttribute("open")
...@@ -113,23 +113,20 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -113,23 +113,20 @@ class SIBNotifications extends SIBTemplateElement {
} }
_updateUnread() { _updateUnread() {
let unread = Number(document.querySelector('#badge-unread').innerText) let unread = Number(this.querySelector('#badge-unread').innerText)
this.favicon.badge(unread) this.favicon.badge(unread)
} }
_updateUI() { _updateUI() {
const notifications = this.querySelectorAll('#notifications-list sib-display') const notifications = this.querySelectorAll('#notifications-list sib-display')
notifications.forEach(notif => { notifications.forEach(notif => {
if (!notif.resource.unread) notif.setAttribute('data-read', 'true') // opacity unread if (!notif.component.resource.unread) notif.setAttribute('data-read', 'true') // opacity unread
}); });
} }
_getNotificationsList() { _getNotificationsList() {
const notificationsList = this.querySelector('#notifications-list'); const notificationsList = this.querySelector('#notifications-list');
if (!notificationsList) return null; return notificationsList ? notificationsList.component.resources : null;
if (Array.isArray(notificationsList.resource['ldp:contains']))
return notificationsList.resource['ldp:contains'];
return [notificationsList.resource['ldp:contains']];
} }
_printError(error) { _printError(error) {
...@@ -158,7 +155,7 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -158,7 +155,7 @@ class SIBNotifications extends SIBTemplateElement {
<sib-display <sib-display
id="unread-filter" id="unread-filter"
data-src="${this.resourceId}" data-src="${this.resourceId}"
data-fields="none" fields="none"
search-fields="unread" search-fields="unread"
search-value-unread="true" search-value-unread="true"
search-widget-unread="sib-form-hidden" search-widget-unread="sib-form-hidden"
...@@ -171,15 +168,12 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -171,15 +168,12 @@ class SIBNotifications extends SIBTemplateElement {
id="notifications-list" id="notifications-list"
class="sib-notifications__items" class="sib-notifications__items"
data-src="${this.resourceId}" data-src="${this.resourceId}"
fields="unread, content(author.avatar, wrapper(author.username, source(type, object.name), date))"
widget-unread="read-badge" widget-unread="read-badge"
set-source="type, object.name"
widget-object.name="sib-display-labelled-div" widget-object.name="sib-display-labelled-div"
label-object.name="·"
set-wrapper="author.username, source, date"
set-content="author.avatar, wrapper"
data-fields="unread, content"
widget-author.avatar="sib-display-img" widget-author.avatar="sib-display-img"
widget-date="custom-date" widget-date="custom-date"
label-object.name="·"
paginate-by="10"></sib-display> paginate-by="10"></sib-display>
</div> </div>
</details> </details>
......
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