2021-01-04 04:06:21 +01:00
|
|
|
import Locale from "../i18n/Locale";
|
|
|
|
import {UIElement} from "../UIElement";
|
|
|
|
import State from "../../State";
|
|
|
|
import Combine from "../Base/Combine";
|
|
|
|
import LanguagePicker from "../LanguagePicker";
|
|
|
|
import Translations from "../i18n/Translations";
|
2021-01-07 04:50:12 +01:00
|
|
|
import {VariableUiElement} from "../Base/VariableUIElement";
|
2021-03-24 01:25:57 +01:00
|
|
|
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
2020-08-17 17:23:15 +02:00
|
|
|
|
2021-01-07 04:50:12 +01:00
|
|
|
export default class ThemeIntroductionPanel extends UIElement {
|
2020-07-31 01:45:54 +02:00
|
|
|
private languagePicker: UIElement;
|
|
|
|
|
2021-01-07 04:50:12 +01:00
|
|
|
private readonly loginStatus: UIElement;
|
2021-03-24 01:25:57 +01:00
|
|
|
private _layout: UIEventSource<LayoutConfig>;
|
2020-07-31 01:45:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(State.state.osmConnection.userDetails);
|
|
|
|
this.ListenTo(Locale.language);
|
2020-11-11 16:23:49 +01:00
|
|
|
this.languagePicker = LanguagePicker.CreateLanguagePicker(State.state.layoutToUse.data.language, Translations.t.general.pickLanguage);
|
2021-03-24 01:25:57 +01:00
|
|
|
this._layout = State.state.layoutToUse;
|
|
|
|
this.ListenTo(State.state.layoutToUse);
|
2020-09-03 16:44:48 +02:00
|
|
|
|
2021-03-24 01:25:57 +01:00
|
|
|
const plzLogIn =
|
2020-11-11 16:23:49 +01:00
|
|
|
Translations.t.general.loginWithOpenStreetMap
|
2020-09-03 16:44:48 +02:00
|
|
|
.onClick(() => {
|
|
|
|
State.state.osmConnection.AttemptLogin()
|
|
|
|
});
|
2021-03-24 01:25:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
const welcomeBack = Translations.t.general.welcomeBack;
|
|
|
|
|
2021-01-07 04:50:12 +01:00
|
|
|
this.loginStatus = new VariableUiElement(
|
|
|
|
State.state.osmConnection.userDetails.map(
|
|
|
|
userdetails => {
|
|
|
|
if (State.state.featureSwitchUserbadge.data) {
|
|
|
|
return "";
|
|
|
|
}
|
2021-03-24 01:25:57 +01:00
|
|
|
return (userdetails.loggedIn ? welcomeBack : plzLogIn).Render();
|
2021-01-07 04:50:12 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
2021-04-12 13:05:30 +02:00
|
|
|
this.SetClass("link-underline")
|
2020-08-27 18:44:16 +02:00
|
|
|
}
|
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
InnerRender(): string {
|
2021-03-24 01:25:57 +01:00
|
|
|
const layout : LayoutConfig = this._layout.data;
|
2020-08-27 18:44:16 +02:00
|
|
|
return new Combine([
|
2021-03-24 01:25:57 +01:00
|
|
|
layout.description,
|
2020-09-05 15:27:35 +02:00
|
|
|
"<br/><br/>",
|
2021-01-07 04:50:12 +01:00
|
|
|
this.loginStatus,
|
2021-03-24 01:25:57 +01:00
|
|
|
layout.descriptionTail,
|
2020-08-27 18:44:16 +02:00
|
|
|
"<br/>",
|
2021-03-24 01:25:57 +01:00
|
|
|
this.languagePicker,
|
|
|
|
...layout.CustomCodeSnippets()
|
2020-08-27 18:44:16 +02:00
|
|
|
]).Render()
|
2020-07-31 01:45:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-24 14:36:43 +01:00
|
|
|
}
|