forked from MapComplete/MapComplete
Add error suppression
This commit is contained in:
parent
798556f6d3
commit
4580ba0ce0
2 changed files with 15 additions and 3 deletions
|
@ -289,22 +289,33 @@ export class DetectMappingsWithImages extends DesugaringStep<TagRenderingConfigJ
|
|||
super("Checks that 'then'clauses in mappings don't have images, but use 'icon' instead", [], "DetectMappingsWithImages");
|
||||
}
|
||||
|
||||
convert(json: TagRenderingConfigJson, context: string): { result: TagRenderingConfigJson; errors?: string[]; warnings?: string[] } {
|
||||
convert(json: TagRenderingConfigJson, context: string): { result: TagRenderingConfigJson; errors?: string[]; warnings?: string[], information?: string[] } {
|
||||
const errors = []
|
||||
const warnings = []
|
||||
const information = []
|
||||
if (json.mappings === undefined || json.mappings.length === 0) {
|
||||
return {result: json}
|
||||
}
|
||||
const ignoreToken = "ignore-image-in-then"
|
||||
for (let i = 0; i < json.mappings.length; i++) {
|
||||
|
||||
const mapping = json.mappings[i]
|
||||
const ignore = mapping["#"]?.indexOf(ignoreToken) >=0
|
||||
const images = Utils.Dedup(Translations.T(mapping.then).ExtractImages())
|
||||
const ctx = `${context}.mappings[${i}]`
|
||||
if (images.length > 0) {
|
||||
warnings.push(context + ".mappings[" + i + "]: A mapping has an image in the 'then'-clause. Remove the image there and use `\"icon\": <your-image>` instead. The images found are "+images.join(", "))
|
||||
if(!ignore){
|
||||
errors.push(`${ctx}: A mapping has an image in the 'then'-clause. Remove the image there and use \`"icon": <your-image>\` instead. The images found are ${images.join(", ")}. (Ignore this warning by adding "#": "${ignoreToken}" to the mapping`)
|
||||
}else{
|
||||
information.push(`${ctx}: Ignored images in then`)
|
||||
}
|
||||
}else if (ignore){
|
||||
warnings.push(`${ctx}: unused '${ignoreToken}' - please remove this`)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
warnings,
|
||||
errors,warnings,information,
|
||||
result: json
|
||||
};
|
||||
}
|
||||
|
|
|
@ -239,6 +239,7 @@
|
|||
},
|
||||
"mappings": [
|
||||
{
|
||||
"#": "ignore-image-in-then",
|
||||
"if": "addr:substreet~*",
|
||||
"then": "<div>The envelope below shows the address that we have recorded. You can change this by answering any remaining questions above, or by clicking the pencil icons below. We do not need you to provide a recipient's name or any of the parts shown in <span style='color: #4e7ce8'>[blue]</span>.</div><div style='background: #f1d592; min-height: 270px; border-radius: 2px; padding: 1rem 1rem 2rem 7rem; margin: 1rem; box-shadow: 0 2px 5px 0px rgba(0,0,0,.6)' class='flex flex-col'><img src='./assets/themes/uk_addresses/stamp-outline.png' class='self-end w-16'/><div>{addr:unit} {addr:housename}</div><div>{addr:housenumber} {addr:substreet}</div><div>{addr:street}</div><div>{addr:parentstreet}</div><div style='color: #4e7ce8'>[Suburb]</div><div style='color: #4e7ce8'>[Town]</div><div style='color: #4e7ce8'>[Postal code]</div></div>"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue