forked from MapComplete/MapComplete
		
	Fix(studio): add check for incorrect suggestions, fix incorrect suggestion which breaks setting a 'marker'
This commit is contained in:
		
							parent
							
								
									3bfdc1838c
								
							
						
					
					
						commit
						143dd70973
					
				
					 2 changed files with 19 additions and 4 deletions
				
			
		| 
						 | 
					@ -208,13 +208,27 @@ function extractHintsFrom(
 | 
				
			||||||
            validators: Validators,
 | 
					            validators: Validators,
 | 
				
			||||||
            Constants: Constants,
 | 
					            Constants: Constants,
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        if (hints["suggestions"]?.indexOf(null) >= 0) {
 | 
					        const evaluatedSuggestions = hints["suggestions"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (evaluatedSuggestions?.indexOf(null) >= 0) {
 | 
				
			||||||
            throw (
 | 
					            throw (
 | 
				
			||||||
                "A suggestion generated 'null' for " +
 | 
					                "A suggestion generated 'null' for " +
 | 
				
			||||||
                path.join(".") +
 | 
					                path.join(".") +
 | 
				
			||||||
                ". Check the docstring, specifically 'suggestions'. Pay attention to double commas"
 | 
					                ". Check the docstring, specifically 'suggestions'. Pay attention to double commas"
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        console.log(evaluatedSuggestions)
 | 
				
			||||||
 | 
					        for (const hintElement of evaluatedSuggestions ?? []) {
 | 
				
			||||||
 | 
					            if (typeof hintElement === "string") {
 | 
				
			||||||
 | 
					                throw (
 | 
				
			||||||
 | 
					                    "A suggestion generated a string for " +
 | 
				
			||||||
 | 
					                    path.join(".") +
 | 
				
			||||||
 | 
					                    ". Remember that you should use {'if': 'value=[actual_value]', 'then': '[some explanation]'}"
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return hints
 | 
					    return hints
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,14 +13,15 @@ export interface IconConfigJson {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * types: <span class="text-lg font-bold">Use a different icon depending on the value of some attributes</span> ; icon
 | 
					     * types: <span class="text-lg font-bold">Use a different icon depending on the value of some attributes</span> ; icon
 | 
				
			||||||
     * suggestions: return [ "nsi_brand.icon", "nsi_operator.icon", "id_presets.shop_rendering", ...Constants.defaultPinIcons.map(i => ({if: "value="+i, then: i, icon: i}))]
 | 
					     * suggestions: return [ {"if":"value=nsi_brand.icon", "then": "Use icons for brand from the Name Suggestion Index"}, {"if":"value=nsi_operator.icon", "then": "Use icons for operator from the Name Suggestion Index"}, {"if":"value=id_presets.shop_rendering", "then": "Use shop preset icons from iD"}, ...Constants.defaultPinIcons.map(i => ({if: "value="+i, then: i, icon: i}))]
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    icon: string | MinimalTagRenderingConfigJson | { builtin: string; override: any }
 | 
					    icon: string | MinimalTagRenderingConfigJson | { builtin: string; override: any }
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * question: What colour should the icon be?
 | 
					     * question: What colour should the icon be?
 | 
				
			||||||
     * This will only work for the default icons such as `pin`,`circle`,...
 | 
					 | 
				
			||||||
     * types: <span class="text-lg font-bold">Use a different color depending on the value of some attributes</span> ; color
 | 
					 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
					     * This will only work for the default icons such as `pin`,`circle`,...
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * types: <span class="text-lg font-bold">Use a different color depending on the value of some attributes</span> ; color
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    color?: string | MinimalTagRenderingConfigJson | { builtin: string; override: any }
 | 
					    color?: string | MinimalTagRenderingConfigJson | { builtin: string; override: any }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue