forked from MapComplete/MapComplete
		
	Add custom javascript snippets to calculate tags
This commit is contained in:
		
							parent
							
								
									3e130ebe80
								
							
						
					
					
						commit
						f124d9ded7
					
				
					 17 changed files with 799 additions and 14649 deletions
				
			
		|  | @ -5,52 +5,54 @@ import Combine from "../Base/Combine"; | |||
| import LanguagePicker from "../LanguagePicker"; | ||||
| import Translations from "../i18n/Translations"; | ||||
| import {VariableUiElement} from "../Base/VariableUIElement"; | ||||
| import LayoutConfig from "../../Customizations/JSON/LayoutConfig"; | ||||
| import {UIEventSource} from "../../Logic/UIEventSource"; | ||||
| 
 | ||||
| export default class ThemeIntroductionPanel extends UIElement { | ||||
|     private languagePicker: UIElement; | ||||
| 
 | ||||
|     private readonly description: UIElement; | ||||
|     private readonly plzLogIn: UIElement; | ||||
|     private readonly welcomeBack: UIElement; | ||||
|     private readonly tail: UIElement; | ||||
|     private readonly loginStatus: UIElement; | ||||
|     private _layout: UIEventSource<LayoutConfig>; | ||||
| 
 | ||||
| 
 | ||||
|     constructor() { | ||||
|         super(State.state.osmConnection.userDetails); | ||||
|         this.ListenTo(Locale.language); | ||||
|         this.languagePicker = LanguagePicker.CreateLanguagePicker(State.state.layoutToUse.data.language, Translations.t.general.pickLanguage); | ||||
|         const layout = State.state.layoutToUse.data; | ||||
|         this._layout = State.state.layoutToUse; | ||||
|         this.ListenTo(State.state.layoutToUse); | ||||
| 
 | ||||
|         this.description = layout.description | ||||
|         this.plzLogIn = | ||||
|         const plzLogIn = | ||||
|             Translations.t.general.loginWithOpenStreetMap | ||||
|                 .onClick(() => { | ||||
|                     State.state.osmConnection.AttemptLogin() | ||||
|                 }); | ||||
|         this.welcomeBack = Translations.t.general.welcomeBack; | ||||
|         this.tail = layout.descriptionTail; | ||||
|          | ||||
|          | ||||
|         const welcomeBack = Translations.t.general.welcomeBack; | ||||
|          | ||||
|         this.loginStatus = new VariableUiElement( | ||||
|             State.state.osmConnection.userDetails.map( | ||||
|                 userdetails => { | ||||
|                     if (State.state.featureSwitchUserbadge.data) { | ||||
|                         return ""; | ||||
|                     } | ||||
|                     return (userdetails.loggedIn ? this.welcomeBack : this.plzLogIn).Render(); | ||||
|                     return (userdetails.loggedIn ? welcomeBack : plzLogIn).Render(); | ||||
|                 } | ||||
|             ) | ||||
|              | ||||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     InnerRender(): string { | ||||
|         const layout : LayoutConfig = this._layout.data; | ||||
|         return new Combine([ | ||||
|             this.description, | ||||
|             layout.description, | ||||
|             "<br/><br/>", | ||||
|             this.loginStatus, | ||||
|             this.tail, | ||||
|             layout.descriptionTail, | ||||
|             "<br/>", | ||||
|             this.languagePicker | ||||
|             this.languagePicker, | ||||
|             ...layout.CustomCodeSnippets() | ||||
|         ]).Render() | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue