Skip to content
Snippets Groups Projects
Commit 175c34b9 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Implement support for value updates

parent bed82677
No related branches found
No related tags found
No related merge requests found
...@@ -40,30 +40,39 @@ class VPUKnowledgeBaseWebPageElementView extends VPULitElement { ...@@ -40,30 +40,39 @@ class VPUKnowledgeBaseWebPageElementView extends VPULitElement {
// encodeURIComponent(commonUtils.base64EncodeUnicode(encodeURIComponent(that.value))); // encodeURIComponent(commonUtils.base64EncodeUnicode(encodeURIComponent(that.value)));
// }); // });
window.addEventListener("vpu-auth-init", () => that.loadWebPageElement());
}
/**
* Loads the data from the web page element
*/
loadWebPageElement() {
// sadly there there is no entity url without "collectionOperations" in entity KnowledgeBaseWebPageElement! // sadly there there is no entity url without "collectionOperations" in entity KnowledgeBaseWebPageElement!
const apiUrl = this.apiUrl + "/web_page_elements/knowledge_base_web_page_elements/" + const apiUrl = this.apiUrl + "/web_page_elements/knowledge_base_web_page_elements/" +
encodeURIComponent(commonUtils.base64EncodeUnicode(encodeURIComponent(that.value))) + encodeURIComponent(commonUtils.base64EncodeUnicode(encodeURIComponent(this.value))) +
"?lang=" + encodeURIComponent(that.lang); "?lang=" + encodeURIComponent(this.lang);
window.addEventListener("vpu-auth-init", function(e) fetch(apiUrl, {
{ headers: {
fetch(apiUrl, { 'Content-Type': 'application/ld+json',
headers: { 'Authorization': 'Bearer ' + window.VPUAuthToken,
'Content-Type': 'application/ld+json', },
'Authorization': 'Bearer ' + window.VPUAuthToken, })
}, .then(res => res.json())
.then(webPageElement => {
if (webPageElement !== undefined && webPageElement.text !== undefined) {
this.html = webPageElement.text;
}
}) })
.then(res => res.json()) // catch e.g. 404 errors
.then(webPageElement => { .catch();
if (webPageElement !== undefined && webPageElement.text !== undefined) { }
that.html = webPageElement.text;
}
})
// catch e.g. 404 errors
.catch();
});
this.updateComplete.then(()=>{ updated(changedProperties) {
changedProperties.forEach((oldValue, propName) => {
if (propName === "value") {
this.loadWebPageElement();
}
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment