2020-07-31 01:45:54 +02:00
|
|
|
import {UIElement} from "../UI/UIElement";
|
|
|
|
import {OsmConnection, UserDetails} from "../Logic/Osm/OsmConnection";
|
|
|
|
import Locale from "../UI/i18n/Locale";
|
|
|
|
import {State} from "../State";
|
|
|
|
import {Layout} from "../Customizations/Layout";
|
|
|
|
import Translations from "./i18n/Translations";
|
|
|
|
import {VariableUiElement} from "./Base/VariableUIElement";
|
2020-07-31 04:58:58 +02:00
|
|
|
import {Utils} from "../Utils";
|
2020-08-17 17:23:15 +02:00
|
|
|
import {UIEventSource} from "../Logic/UIEventSource";
|
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
|
|
|
|
export class WelcomeMessage extends UIElement {
|
|
|
|
private readonly layout: Layout;
|
|
|
|
private languagePicker: UIElement;
|
|
|
|
private osmConnection: OsmConnection;
|
|
|
|
|
|
|
|
private readonly description: UIElement;
|
|
|
|
private readonly plzLogIn: UIElement;
|
|
|
|
private readonly welcomeBack: UIElement;
|
|
|
|
private readonly tail: UIElement;
|
|
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(State.state.osmConnection.userDetails);
|
|
|
|
this.ListenTo(Locale.language);
|
2020-08-26 15:36:04 +02:00
|
|
|
this.languagePicker = Utils.CreateLanguagePicker(Translations.t.general.pickLanguage);
|
2020-07-31 01:45:54 +02:00
|
|
|
|
|
|
|
function fromLayout(f: (layout: Layout) => (string | UIElement)): UIElement {
|
2020-08-26 15:36:04 +02:00
|
|
|
return Translations.W(f(State.state.layoutToUse.data));
|
2020-07-31 01:45:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.description = fromLayout((layout) => layout.welcomeMessage);
|
2020-07-31 18:48:37 +02:00
|
|
|
this.plzLogIn = fromLayout((layout) => layout.gettingStartedPlzLogin);
|
|
|
|
this.plzLogIn.onClick(()=> State.state.osmConnection.AttemptLogin());
|
2020-07-31 01:45:54 +02:00
|
|
|
this.welcomeBack = fromLayout((layout) => layout.welcomeBackMessage);
|
|
|
|
this.tail = fromLayout((layout) => layout.welcomeTail);
|
|
|
|
}
|
|
|
|
|
|
|
|
InnerRender(): string {
|
|
|
|
|
|
|
|
let loginStatus = "";
|
|
|
|
if (State.state.featureSwitchUserbadge.data) {
|
|
|
|
loginStatus = (State.state.osmConnection.userDetails.data.loggedIn ? this.welcomeBack : this.plzLogIn).Render();
|
|
|
|
loginStatus = loginStatus + "<br/>"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "<span>" +
|
|
|
|
this.description.Render() +
|
2020-08-25 00:10:48 +02:00
|
|
|
"<br/></br>" +
|
2020-07-31 01:45:54 +02:00
|
|
|
loginStatus +
|
|
|
|
this.tail.Render() +
|
|
|
|
"<br/>" +
|
|
|
|
this.languagePicker.Render() +
|
|
|
|
"</span>";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|