forked from MapComplete/MapComplete
		
	Update themes to use new language_chooser
This commit is contained in:
		
							parent
							
								
									84eee064b2
								
							
						
					
					
						commit
						112b9cd25d
					
				
					 10 changed files with 11077 additions and 40761 deletions
				
			
		|  | @ -1,13 +1,15 @@ | |||
| import {UIEventSource} from "../Logic/UIEventSource"; | ||||
| import BaseUIElement from "./BaseUIElement"; | ||||
| import FeaturePipelineState from "../Logic/State/FeaturePipelineState"; | ||||
| import {DefaultGuiState} from "./DefaultGuiState"; | ||||
| 
 | ||||
| export interface SpecialVisualization { | ||||
|     funcName: string | ||||
|     constr: ( | ||||
|         state: any, /*FeaturePipelineState*/ | ||||
|         state: FeaturePipelineState, | ||||
|         tagSource: UIEventSource<any>, | ||||
|         argument: string[], | ||||
|         guistate: any /*DefaultGuiState*/ | ||||
|         guistate: DefaultGuiState | ||||
|     ) => BaseUIElement | ||||
|     docs: string | BaseUIElement | ||||
|     example?: string | ||||
|  |  | |||
|  | @ -51,6 +51,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig"; | |||
| import {GeoOperations} from "../Logic/GeoOperations"; | ||||
| import StatisticsPanel from "./BigComponents/StatisticsPanel"; | ||||
| import AutoApplyButton from "./Popup/AutoApplyButton"; | ||||
| import {LanguageElement} from "./Popup/LanguageElement"; | ||||
| 
 | ||||
| export default class SpecialVisualizations { | ||||
|     public static specialVisualizations: SpecialVisualization[]  = SpecialVisualizations.initList(); | ||||
|  | @ -74,6 +75,7 @@ export default class SpecialVisualizations { | |||
|             new CloseNoteButton(), | ||||
|             new NearbyImageVis(), | ||||
|             new MapillaryLinkVis(), | ||||
|             new LanguageElement(), | ||||
|             { | ||||
|                 funcName: "all_tags", | ||||
|                 docs: "Prints all key-value pairs of the object - used for debugging", | ||||
|  |  | |||
|  | @ -16,11 +16,11 @@ export default class WikidataUtils { | |||
|      * @param remapLanguages | ||||
|      */ | ||||
|     public static extractLanguageData( | ||||
|         data: { lang: { value: string }; code: { value: string }; label: { value: string } }[], | ||||
|         data: { lang: { value: string }; code: { value: string }; label: { value: string }; directionalityLabel?: { value?: string } }[], | ||||
|         remapLanguages: Record<string, string> | ||||
|     ): Map<string, Map<string, string>> { | ||||
|     ): Map<string, { translations: Map<string, string>, directionality?: string[] }> { | ||||
|         console.log("Got " + data.length + " entries") | ||||
|         const perId = new Map<string, Map<string, string>>() | ||||
|         const perId = new Map<string, { translations: Map<string, string>, directionality?: string[] }>() | ||||
|         for (const element of data) { | ||||
|             let id = element.code.value | ||||
|             id = remapLanguages[id] ?? id | ||||
|  | @ -28,9 +28,16 @@ export default class WikidataUtils { | |||
|             labelLang = remapLanguages[labelLang] ?? labelLang | ||||
|             const value = element.label.value | ||||
|             if (!perId.has(id)) { | ||||
|                 perId.set(id, new Map<string, string>()) | ||||
|                 perId.set(id, {translations: new Map<string, string>(), directionality: []}) | ||||
|             } | ||||
|             const entry = perId.get(id) | ||||
|             entry.translations.set(labelLang, value) | ||||
|             const dir = element.directionalityLabel?.value | ||||
|             if (dir) { | ||||
|                 if(entry.directionality.indexOf(dir) < 0) { | ||||
|                     entry.directionality.push(dir) | ||||
|                 } | ||||
|             } | ||||
|             perId.get(id).set(labelLang, value) | ||||
|         } | ||||
| 
 | ||||
|         console.log("Got " + perId.size + " languages") | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| { | ||||
|   "ca": "català", | ||||
|   "cs": "čeština", | ||||
|   "da": "dansk", | ||||
|   "de": "Deutsch", | ||||
|   "en": "English", | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -135,14 +135,21 @@ | |||
|       } | ||||
|     }, | ||||
|     "induction-loop", | ||||
|     { | ||||
|       "builtin": "wikidata.tactile_writing-braille", | ||||
|       "override": { | ||||
|     {"render": { | ||||
|       "id": "tactile_writing_language", | ||||
|       "special": { | ||||
|         "type": "language_chooser", | ||||
|         "question": { | ||||
|           "en": "In which languages does this elevator have tactile writing (braille)?" | ||||
|         }, | ||||
|         "render_list_item": { | ||||
|           "en": "This elevator has tactile writing in {language():font-bold}" | ||||
|         }, | ||||
|         "render_single_language": { | ||||
|           "en": "This elevator has tactile writing in {language():font-bold}" | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     }} | ||||
|   ], | ||||
|   "mapRendering": [ | ||||
|     { | ||||
|  | @ -218,4 +225,4 @@ | |||
|       ] | ||||
|     } | ||||
|   ] | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -296,28 +296,31 @@ | |||
|     "phone", | ||||
|     "email", | ||||
|     { | ||||
|       "builtin": "wikidata.school-language", | ||||
|       "override": { | ||||
|         "+mappings": [ | ||||
|           { | ||||
|             "if": "school:language=", | ||||
|             "hideInAnswer": true, | ||||
|             "then": { | ||||
|               "en": "The main language of this school is unknown", | ||||
|               "nl": "De voertaal van deze school is niet gekend", | ||||
|               "de": "Die Unterrichtssprache der Schule ist unbekannt", | ||||
|               "fr": "La langue principale de cette école est inconnue" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|       "id": "school-language", | ||||
|       "render": { | ||||
|       "special": { | ||||
|         "type": "language_chooser", | ||||
|         "key": "language", | ||||
|         "render_all": { | ||||
|           "en": "The following languages are used in this school:{list()}" | ||||
|         }, | ||||
|         "render_single_language": { | ||||
|           "en": "{language():font-bold} is the main language of this school" | ||||
|         }, | ||||
|         "question": { | ||||
|           "en": "What is the main language of this school?<div class='subtle'>What language is spoken with the students in non-language related courses and with the administration?</div>", | ||||
|           "nl": "Wat is de voertaal van deze school?<div class='subtle'>Welke taal wordt met de studenten gesproken in niet-taal-gerelateerde vakken en met de administratie?</div>", | ||||
|           "de": "Was ist die Hauptsprache dieser Schule?<div class='subtle'>Welche Sprache wird mit den Schülern in den nicht sprachbezogenen Kursen und mit der Verwaltung gesprochen?</div>", | ||||
|           "fr": "Quelle est la langue principale de cette école ?<div class='subtle'>Quelle langue est parlée avec les élèves des cours non linguistiques et avec l'administration ?</div>" | ||||
|         }, | ||||
|         "no_known_languages": { | ||||
|           "en": "The main language of this school is unknown", | ||||
|           "nl": "De voertaal van deze school is niet gekend", | ||||
|           "de": "Die Unterrichtssprache der Schule ist unbekannt", | ||||
|           "fr": "La langue principale de cette école est inconnue" | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     }} | ||||
|   ], | ||||
|   "presets": [ | ||||
|     { | ||||
|  | @ -360,4 +363,4 @@ | |||
|       "width": 1 | ||||
|     } | ||||
|   ] | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -50,6 +50,74 @@ | |||
|         } | ||||
|       ] | ||||
|     }, | ||||
| 
 | ||||
|     { | ||||
|       "id": "tactile_writing", | ||||
|       "condition": "handrail=yes", | ||||
|       "question": { | ||||
|         "en": "Do these stairs have tactile writing on the handrail?" | ||||
|       }, | ||||
|       "mappings": [ | ||||
|         { | ||||
|           "if": "tactile_writing=yes", | ||||
|           "then": { | ||||
|             "en": "There is tactile writing on the handrail" | ||||
|           } | ||||
|         }, | ||||
|         { | ||||
|           "if": "tactile_writing=no", | ||||
|           "then": { | ||||
|             "en": "There is no tactile writing on the handrail" | ||||
|           } | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "id": "tactile_writing_language", | ||||
|       "condition": "tactile_writing:braille:language=yes", | ||||
|       "render": { | ||||
|         "special": { | ||||
|           "type": "language_chooser", | ||||
|           "key": "tactile_writing:braille:language", | ||||
|           "question": { | ||||
|             "en": "In which languages is there tactile writing (braille) for navigation? <img src='./assets/layers/stairs/Braille_stairs.jpg' style='height: 300px; width: auto; display: block;' />" | ||||
|           }, | ||||
|           "render_list_item": { | ||||
|             "en": "These stairs have tactile writing in {language():font-bold}" | ||||
|           }, | ||||
|           "render_single_language": { | ||||
|             "en": "These stairs have tactile writing in {language():font-bold}" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       "id": "conveying", | ||||
|       "mappings": [ | ||||
|         { | ||||
|           "if": "conveying=yes", | ||||
|           "then": { | ||||
|             "en": "This is an escalator", | ||||
|             "nl": "Dit is een roltrap" | ||||
|           } | ||||
|         }, | ||||
|         { | ||||
|           "if": "conveying=no", | ||||
|           "then": { | ||||
|             "en": "This is not an escalator", | ||||
|             "nl": "Dit is geen roltrap" | ||||
|           } | ||||
|         }, | ||||
|         { | ||||
|           "if": "conveying=", | ||||
|           "then": { | ||||
|             "en": "This is not an escalator", | ||||
|             "nl": "Dit is geen roltrap" | ||||
|           }, | ||||
|           "hideInAnswer": true | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "id": "ramp", | ||||
|       "question": { | ||||
|  | @ -93,33 +161,6 @@ | |||
|           } | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "builtin": "wikidata.tactile_writing-braille", | ||||
|       "override": { | ||||
|         "question": { | ||||
|           "en": "In which languages is there tactile writing (braille) for navigation? <img src='./assets/layers/stairs/Braille_stairs.jpg' style='height: 300px; width: auto; display: block;' />" | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       "id": "conveying", | ||||
|       "mappings": [ | ||||
|         { | ||||
|           "if": "conveying=yes", | ||||
|           "then": { | ||||
|             "en": "This is an escalator", | ||||
|             "nl": "Dit is een roltrap" | ||||
|           } | ||||
|         }, | ||||
|         { | ||||
|           "if": "conveying=no", | ||||
|           "then": { | ||||
|             "en": "This is not an escalator", | ||||
|             "nl": "Dit is geen roltrap" | ||||
|           } | ||||
|         } | ||||
|       ] | ||||
|     } | ||||
|   ], | ||||
|   "mapRendering": [ | ||||
|  | @ -129,4 +170,4 @@ | |||
|       "dashArray": "2 2" | ||||
|     } | ||||
|   ] | ||||
| } | ||||
| } | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										24
									
								
								test.ts
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								test.ts
									
										
									
									
									
								
							|  | @ -0,0 +1,24 @@ | |||
| import {LanguageElement} from "./UI/Popup/LanguageElement"; | ||||
| import {ImmutableStore, UIEventSource} from "./Logic/UIEventSource"; | ||||
| import {VariableUiElement} from "./UI/Base/VariableUIElement"; | ||||
| import Locale from "./UI/i18n/Locale"; | ||||
| import {OsmConnection} from "./Logic/Osm/OsmConnection"; | ||||
| 
 | ||||
| const tgs = new UIEventSource({ | ||||
|     "name": "xyz", | ||||
|     "id": "node/1234", | ||||
|     "_country" : "BE", | ||||
| }) | ||||
| Locale.language.setData("nl") | ||||
| console.log(tgs) | ||||
| console.log("Locale", Locale.language) | ||||
| const conn = new OsmConnection({}) | ||||
| new LanguageElement().constr(<any> {osmConnection: conn, featureSwitchIsTesting: new ImmutableStore(true)}, tgs, [ | ||||
|     "language", | ||||
|     "What languages are spoken here?", | ||||
|     "{language()} is spoken here", | ||||
|     "{language()} is the only language spoken here", | ||||
|     "The following languages are spoken here: {list()}" | ||||
| ]).AttachTo("maindiv") | ||||
| 
 | ||||
| new VariableUiElement(tgs.map(JSON.stringify)).AttachTo("extradiv") | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue