From d03e58932bfce59bd6b666ed14098a965bb46cc4 Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Fri, 29 Nov 2019 15:16:53 +0000 Subject: [PATCH] Circle edit redirect --- src/page-circle-edit.pug | 1 + src/scripts/index.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/page-circle-edit.pug b/src/page-circle-edit.pug index 3cc10e3..6c07ebb 100644 --- a/src/page-circle-edit.pug +++ b/src/page-circle-edit.pug @@ -58,6 +58,7 @@ div.content-box__info partial='' submit-button='Save' + next='circle-information' ) h2 Members list diff --git a/src/scripts/index.js b/src/scripts/index.js index a49eb8b..b50faf0 100644 --- a/src/scripts/index.js +++ b/src/scripts/index.js @@ -75,6 +75,23 @@ document.addEventListener('DOMContentLoaded', function (event) { }) }); + //- Watch every sib-forms & update data-src of linked sib-display + document.querySelectorAll('sib-form').forEach(function(el) { + el.addEventListener("save", function(event) { + //clear cache on this resource + //NOTE: this is required because the cache is not refreshed after POSTing changes on the resource + if(el.component.resource != null) el.component.resource.clearCache(); + + // if of the edited resource || id of the container of the created resource + const resourceId = event.detail.resource['@id'] || el.dataset.src; + + //update all displays which use this resource + Array.from(document.querySelectorAll('sib-display')) + .filter(sibDisplay => sibDisplay.component.resourceId == resourceId) // keep only elements with resource == edited resource + .forEach(e => e.dataset.src = e.dataset.src); // and update them + }); + }); + document.querySelector('sib-auth').getUser().then(user => { if (user !== null) { // Hide login button if already logged