Newer
Older
import {createInstance} from './i18n.js';
import {css, html, LitElement} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles';
class AppShellWelcome extends ScopedElementsMixin(LitElement) {
this._i18n = createInstance();
this.lang = this._i18n.language;

Reiter, Christoph
committed
this._onVisibilityChanged = this._onVisibilityChanged.bind(this);
}
static get properties() {
return {
lang: { type: String },
};
}
static set app(app) {
this._app = app;
}
update(changedProperties) {
changedProperties.forEach((oldValue, propName) => {
if (propName === "lang") {
this._i18n.changeLanguage(this.lang);
}
});
super.update(changedProperties);
}
static get styles() {
// language=css
return css`
${commonStyles.getThemeCSS()}
${commonStyles.getGeneralCSS()}
p { line-height: 1.8em }
.item {padding-top: 0.5em;}
.description {
padding-left: 2em;
font-style: italic;
margin-top: -1px;
line-height: initial;
h2 a:hover {
color: #E4154B;
}

Reiter, Christoph
committed
_onVisibilityChanged() {
this.requestUpdate();
}
connectedCallback() {
super.connectedCallback();
const app = AppShellWelcome._app;
app.addEventListener('visibility-changed', this._onVisibilityChanged);
}
disconnectedCallback() {
const app = AppShellWelcome._app;
app.removeEventListener('visibility-changed', this._onVisibilityChanged);
super.disconnectedCallback();
}
const app = AppShellWelcome._app;
let itemTemplates = [];
const switchActivity = (e, data) => {
e.preventDefault();
app.switchComponent(data.routing_name);
};

Reiter, Christoph
committed
for (let routeName of app.visibleRoutes) {
let data = app.metadata[routeName];

Reiter, Christoph
committed
if (routeName !== "welcome") {
itemTemplates.push(html`
<div class="item">
<h2><a href="#" @click=${(e) => {switchActivity(e, data);}}>${data.name[this.lang]}</a></h2>
<p class="description">${data.description[this.lang]}</p>
<p>${i18n.t('welcome.headline', {appname: app.topic.name[this.lang]})}
${app.topic.description[this.lang] }</p>
${itemTemplates}
`;
}
}
export const appWelcomeMeta = {
"element": "dbp-app-shell-welcome",
"module_src": "",
"routing_name": "welcome",
"name": {
"de": "Willkommen",
"en": "Welcome"
},
"short_name": {
"de": "Willkommen",
"en": "Welcome"
},
"description": {
"de": "Willkommen",
"en": "Welcome"
visible: true,
required_roles: [],
commonUtils.defineCustomElement('dbp-app-shell-welcome', AppShellWelcome);