Skip to content
Snippets Groups Projects
Commit cbd8fe28 authored by Neuber, Eugen Ramon's avatar Neuber, Eugen Ramon :speech_balloon:
Browse files

Add language selector to demo

(update attribute only if value changed)
parent 9ac3c01a
No related branches found
No related tags found
1 merge request!28Observer test
Pipeline #15673 passed
......@@ -5,6 +5,8 @@ import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles';
import {Provider} from '@dbp-toolkit/provider';
import {LanguageSelect} from '@dbp-toolkit/language-select';
class ProviderDemo extends ScopedElementsMixin(LitElement) {
......@@ -18,6 +20,7 @@ class ProviderDemo extends ScopedElementsMixin(LitElement) {
return {
'dbp-auth-keycloak': AuthKeycloak,
'dbp-login-button': LoginButton,
'dbp-language-select': LanguageSelect,
'dbp-provider': Provider,
'dbp-consumer': DemoConsumer,
};
......@@ -51,6 +54,7 @@ class ProviderDemo extends ScopedElementsMixin(LitElement) {
<dbp-provider id="root"
blah="777"
availability="global"
lang="de"
><section class="section">
<p>Provider <em>"root"</em> is the top most in hierarchy:</p>
<pre>
......@@ -62,6 +66,7 @@ class ProviderDemo extends ScopedElementsMixin(LitElement) {
<div class="container">
<dbp-auth-keycloak lang="${this.lang}" url="https://auth-dev.tugraz.at/auth" realm="tugraz" client-id="auth-dev-mw-frontend-local" load-person try-login></dbp-auth-keycloak>
<dbp-login-button lang="${this.lang}" show-image></dbp-login-button>
<dbp-language-select></dbp-language-select>
</div>
<dbp-provider id="demo"
bc="blue"
......
......@@ -75,13 +75,16 @@ export class Provider extends HTMLElement {
for(const mutation of mutationsList) {
if (mutation.type === 'attributes') {
const name = mutation.attributeName;
console.log('Provider (' + that.id() + ') observed attribute "' + name + '" changed');
that[name] = that.getAttribute(name);
that.callbackStore.forEach(item => {
if (item.name === name) {
item.callback(value);
}
});
const value = that.getAttribute(name);
if (that[name] !== value) {
console.log('Provider (' + that.id() + ') observed attribute "' + name + '" changed');
that[name] = value;
that.callbackStore.forEach(item => {
if (item.name === name) {
item.callback(value);
}
});
}
}
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment