Skip to content
Snippets Groups Projects
Unverified Commit db948ce9 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Implement "set-property" handling in dbp-provider and use it in...

Implement "set-property" handling in dbp-provider and use it in dbp-language-select (dbp/apps/library#77)
parent 7e2a057e
No related branches found
No related tags found
No related merge requests found
Pipeline #15634 passed
......@@ -53,13 +53,21 @@ export class LanguageSelect extends LitElement {
this.requestUpdate('next', oldNext);
if (oldValue !== value) {
const event = new CustomEvent("dbp-language-changed", {
let event = new CustomEvent("dbp-language-changed", {
bubbles: true,
composed: true,
detail: {'lang': value}
});
this.dispatchEvent(event);
// tell a dbp-provider to update the "lang" property
event = new CustomEvent("set-property", {
bubbles: true,
composed: true,
detail: {'name': 'lang', 'value': value}
});
this.dispatchEvent(event);
// Unlike other cases we use the next language for the translations so that
// users not knowing the current language can understand it.
// In case of more than two this doesn't make that much sense, but for now..
......
......@@ -78,6 +78,25 @@ export class Provider extends HTMLElement {
e.stopPropagation();
}
}, false);
// listen to property changes
this.addEventListener('set-property', function (e) {
const name = e.detail.name;
const value = e.detail.value;
if (that[name]) {
console.log('Provider(' + that.id() + ') eventListener("set-property",..) name "' + name + '" found.');
that[name] = value;
that.callbackStore.forEach(item => {
if (item.name === name) {
item.callback(value);
}
});
e.stopPropagation();
}
}, false);
}
id() {
......
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