forked from MapComplete/MapComplete
		
	Fix text-area type, support for newlines in key substitutions (fix #543), small tweaks to etymology-theme (fix #537)
This commit is contained in:
		
							parent
							
								
									7839712deb
								
							
						
					
					
						commit
						fdb769a0fc
					
				
					 6 changed files with 19 additions and 10 deletions
				
			
		| 
						 | 
					@ -48,6 +48,9 @@ export default class TagRenderingConfig {
 | 
				
			||||||
            this.render = null;
 | 
					            this.render = null;
 | 
				
			||||||
            this.question = null;
 | 
					            this.question = null;
 | 
				
			||||||
            this.condition = null;
 | 
					            this.condition = null;
 | 
				
			||||||
 | 
					            this.id = "questions"
 | 
				
			||||||
 | 
					            this.group = ""
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,12 +66,6 @@ export default class WithContextLoader {
 | 
				
			||||||
            if (renderingJson["builtin"] !== undefined) {
 | 
					            if (renderingJson["builtin"] !== undefined) {
 | 
				
			||||||
                const renderingId = renderingJson["builtin"]
 | 
					                const renderingId = renderingJson["builtin"]
 | 
				
			||||||
                if (renderingId === "questions") {
 | 
					                if (renderingId === "questions") {
 | 
				
			||||||
                    if (readOnly) {
 | 
					 | 
				
			||||||
                        throw `A tagrendering has a question, but asking a question does not make sense here: is it a title icon or a geojson-layer? ${context}. The offending tagrendering is ${JSON.stringify(
 | 
					 | 
				
			||||||
                            renderingJson
 | 
					 | 
				
			||||||
                        )}`;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    const tr = new TagRenderingConfig("questions", context);
 | 
					                    const tr = new TagRenderingConfig("questions", context);
 | 
				
			||||||
                    renderings.push(tr)
 | 
					                    renderings.push(tr)
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -196,7 +196,7 @@ export default class ValidatedTextField {
 | 
				
			||||||
            "A basic string"),
 | 
					            "A basic string"),
 | 
				
			||||||
        ValidatedTextField.tp(
 | 
					        ValidatedTextField.tp(
 | 
				
			||||||
            "text",
 | 
					            "text",
 | 
				
			||||||
            "A string, but allows input of longer strings more comfortably (a text area)",
 | 
					            "A string, but allows input of longer strings more comfortably and supports newlines (a text area)",
 | 
				
			||||||
            undefined,
 | 
					            undefined,
 | 
				
			||||||
            undefined,
 | 
					            undefined,
 | 
				
			||||||
            undefined,
 | 
					            undefined,
 | 
				
			||||||
| 
						 | 
					@ -473,6 +473,9 @@ export default class ValidatedTextField {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        options.inputMode = tp.inputmode;
 | 
					        options.inputMode = tp.inputmode;
 | 
				
			||||||
 | 
					        if(tp.inputmode === "text") {
 | 
				
			||||||
 | 
					            options.htmlType = "area"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let input: InputElement<string> = new TextField(options);
 | 
					        let input: InputElement<string> = new TextField(options);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								Utils.ts
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								Utils.ts
									
										
									
									
									
								
							| 
						 | 
					@ -186,7 +186,14 @@ Note that these values can be prepare with javascript in the theme by using a [c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while (match) {
 | 
					        while (match) {
 | 
				
			||||||
            const key = match[1]
 | 
					            const key = match[1]
 | 
				
			||||||
            txt = txt.replace("{" + key + "}", tags[key] ?? "")
 | 
					            let v = tags[key]
 | 
				
			||||||
 | 
					            if(v !== undefined ){
 | 
				
			||||||
 | 
					                if(typeof v !== "string"){
 | 
				
			||||||
 | 
					                    v = ""+v
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                v = v.replace(/\n/g, "<br/>")
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            txt = txt.replace("{" + key + "}", v ?? "")
 | 
				
			||||||
            match = txt.match(regex)
 | 
					            match = txt.match(regex)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,7 @@
 | 
				
			||||||
        "nl": "<a href='https://inventaris.onroerenderfgoed.be/erfgoedobjecten?tekst={name}' target='_blank'>Zoeken op inventaris onroerend erfgoed</a>",
 | 
					        "nl": "<a href='https://inventaris.onroerenderfgoed.be/erfgoedobjecten?tekst={name}' target='_blank'>Zoeken op inventaris onroerend erfgoed</a>",
 | 
				
			||||||
        "en": "<a href='https://inventaris.onroerenderfgoed.be/erfgoedobjecten?tekst={name}' target='_blank'>Search on inventaris onroerend erfgoed</a>"
 | 
					        "en": "<a href='https://inventaris.onroerenderfgoed.be/erfgoedobjecten?tekst={name}' target='_blank'>Search on inventaris onroerend erfgoed</a>"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "conditions": "_country=be"
 | 
					      "condition": "_country=be"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      "id": "simple etymology",
 | 
					      "id": "simple etymology",
 | 
				
			||||||
| 
						 | 
					@ -118,6 +118,7 @@
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "questions",
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      "id": "street-name-sign-image",
 | 
					      "id": "street-name-sign-image",
 | 
				
			||||||
      "render": {
 | 
					      "render": {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -165,7 +165,8 @@
 | 
				
			||||||
        "id": "<i>{inscription}</i>"
 | 
					        "id": "<i>{inscription}</i>"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "freeform": {
 | 
					      "freeform": {
 | 
				
			||||||
        "key": "inscription"
 | 
					        "key": "inscription",
 | 
				
			||||||
 | 
					        "type": "text"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "id": "ghost_bike-inscription"
 | 
					      "id": "ghost_bike-inscription"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue