| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  | import {UIElement} from "./UIElement"; | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  | import Locale from "../UI/i18n/Locale"; | 
					
						
							| 
									
										
										
										
											2020-10-02 19:00:24 +02:00
										 |  |  | import State from "../State"; | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  | import Translations from "./i18n/Translations"; | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  | import Combine from "./Base/Combine"; | 
					
						
							| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  | import {InitUiElements} from "../InitUiElements"; | 
					
						
							| 
									
										
										
										
											2020-08-17 17:23:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export class WelcomeMessage extends UIElement { | 
					
						
							|  |  |  |     private languagePicker: UIElement; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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-31 02:59:47 +02:00
										 |  |  |         this.languagePicker = InitUiElements.CreateLanguagePicker(Translations.t.general.pickLanguage); | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |         const layout = State.state.layoutToUse.data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.description =Translations.W(layout.welcomeMessage); | 
					
						
							|  |  |  |         this.plzLogIn = | 
					
						
							|  |  |  |             Translations.W(layout.gettingStartedPlzLogin) | 
					
						
							|  |  |  |                 .onClick(() => { | 
					
						
							|  |  |  |                     State.state.osmConnection.AttemptLogin() | 
					
						
							|  |  |  |                 }); | 
					
						
							|  |  |  |         this.welcomeBack = Translations.W(layout.welcomeBackMessage); | 
					
						
							|  |  |  |         this.tail = Translations.W(layout.welcomeTail); | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |     InnerRender(): string { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |         let loginStatus = undefined; | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |         if (State.state.featureSwitchUserbadge.data) { | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |             loginStatus = (State.state.osmConnection.userDetails.data.loggedIn ? this.welcomeBack :  | 
					
						
							|  |  |  |                 this.plzLogIn); | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |         return new Combine([ | 
					
						
							|  |  |  |             this.description, | 
					
						
							| 
									
										
										
										
											2020-09-05 15:27:35 +02:00
										 |  |  |             "<br/><br/>", | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |             loginStatus, | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |             this.tail, | 
					
						
							|  |  |  |             "<br/>", | 
					
						
							|  |  |  |             this.languagePicker | 
					
						
							|  |  |  |         ]).Render() | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |