forked from MapComplete/MapComplete
Add images to documentations for mappings which have a simple icon
This commit is contained in:
parent
8bcbad5628
commit
515b481188
1 changed files with 27 additions and 21 deletions
|
@ -8,7 +8,7 @@ import { Tag } from "../../Logic/Tags/Tag"
|
|||
import Link from "../../UI/Base/Link"
|
||||
import {
|
||||
MappingConfigJson,
|
||||
QuestionableTagRenderingConfigJson,
|
||||
QuestionableTagRenderingConfigJson
|
||||
} from "./Json/QuestionableTagRenderingConfigJson"
|
||||
import Validators, { ValidatorType } from "../../UI/InputElement/Validators"
|
||||
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
|
||||
|
@ -202,7 +202,7 @@ export default class TagRenderingConfig {
|
|||
) ?? [],
|
||||
inline: json.freeform.inline ?? false,
|
||||
default: json.freeform.default,
|
||||
postfixDistinguished: json.freeform.postfixDistinguished?.trim(),
|
||||
postfixDistinguished: json.freeform.postfixDistinguished?.trim()
|
||||
}
|
||||
if (json.freeform["extraTags"] !== undefined) {
|
||||
throw `Freeform.extraTags is defined. This should probably be 'freeform.addExtraTag' (at ${context})`
|
||||
|
@ -414,7 +414,7 @@ export default class TagRenderingConfig {
|
|||
iconClass,
|
||||
addExtraTags,
|
||||
searchTerms: mapping.searchTerms,
|
||||
priorityIf: prioritySearch,
|
||||
priorityIf: prioritySearch
|
||||
}
|
||||
if (isQuestionable) {
|
||||
if (hideInAnswer !== true && mp.if !== undefined && !mp.if.isUsableAsAnswer()) {
|
||||
|
@ -515,7 +515,7 @@ export default class TagRenderingConfig {
|
|||
then: new TypedTranslation<object>(
|
||||
this.render.replace("{" + this.freeform.key + "}", leftover).translations,
|
||||
this.render.context
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ export default class TagRenderingConfig {
|
|||
return {
|
||||
then: this.render.PartialSubs({ [this.freeform.key]: v.trim() }),
|
||||
icon: this.renderIcon,
|
||||
iconClass: this.renderIconClass,
|
||||
iconClass: this.renderIconClass
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ export default class TagRenderingConfig {
|
|||
key: commonKey,
|
||||
values: Utils.NoNull(
|
||||
values.map((arr) => arr.filter((item) => item.k === commonKey)[0]?.v)
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,7 +635,7 @@ export default class TagRenderingConfig {
|
|||
return {
|
||||
key,
|
||||
type: this.freeform.type,
|
||||
values,
|
||||
values
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Could not create FreeformValues for tagrendering", this.id)
|
||||
|
@ -741,7 +741,7 @@ export default class TagRenderingConfig {
|
|||
// Either no mappings, or this is a radio-button selected freeform value
|
||||
const tag = new And([
|
||||
new Tag(this.freeform.key, freeformValue),
|
||||
...(this.freeform.addExtraTags ?? []),
|
||||
...(this.freeform.addExtraTags ?? [])
|
||||
])
|
||||
const newProperties = tag.applyOn(currentProperties)
|
||||
if (this.invalidValues?.matchesProperties(newProperties)) {
|
||||
|
@ -765,7 +765,7 @@ export default class TagRenderingConfig {
|
|||
selectedMappings.push(
|
||||
new And([
|
||||
new Tag(this.freeform.key, freeformValue),
|
||||
...(this.freeform.addExtraTags ?? []),
|
||||
...(this.freeform.addExtraTags ?? [])
|
||||
])
|
||||
)
|
||||
}
|
||||
|
@ -793,12 +793,12 @@ export default class TagRenderingConfig {
|
|||
if (useFreeform) {
|
||||
return new And([
|
||||
new Tag(this.freeform.key, freeformValue),
|
||||
...(this.freeform.addExtraTags ?? []),
|
||||
...(this.freeform.addExtraTags ?? [])
|
||||
])
|
||||
} else if (singleSelectedMapping !== undefined) {
|
||||
return new And([
|
||||
this.mappings[singleSelectedMapping].if,
|
||||
...(this.mappings[singleSelectedMapping].addExtraTags ?? []),
|
||||
...(this.mappings[singleSelectedMapping].addExtraTags ?? [])
|
||||
])
|
||||
} else {
|
||||
console.error("TagRenderingConfig.ConstructSpecification has a weird fallback for", {
|
||||
|
@ -806,7 +806,7 @@ export default class TagRenderingConfig {
|
|||
singleSelectedMapping,
|
||||
multiSelectedMapping,
|
||||
currentProperties,
|
||||
useFreeform,
|
||||
useFreeform
|
||||
})
|
||||
|
||||
return undefined
|
||||
|
@ -819,7 +819,7 @@ export default class TagRenderingConfig {
|
|||
withRender = [
|
||||
`This rendering asks information about the property `,
|
||||
Link.OsmWiki(this.freeform.key).AsMarkdown(),
|
||||
"This is rendered with `" + this.render.txt + "`",
|
||||
"This is rendered with `" + this.render.txt + "`"
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -827,19 +827,25 @@ export default class TagRenderingConfig {
|
|||
if (this.mappings !== undefined) {
|
||||
mappings = MarkdownUtils.list(
|
||||
this.mappings.flatMap((m) => {
|
||||
let icon = ""
|
||||
if (m.icon?.indexOf(";") < 0) {
|
||||
icon = "<img src='https://raw.githubusercontent.com/pietervdvn/MapComplete/develop/" + m.icon + "' style='width: 3rem; height: 3rem'>"
|
||||
}
|
||||
const msgs: string[] = [
|
||||
icon + " " +
|
||||
"*" +
|
||||
m.then.txt +
|
||||
"* corresponds with " +
|
||||
m.if.asHumanString(true, false, {}),
|
||||
m.then.txt +
|
||||
"* corresponds with " +
|
||||
m.if.asHumanString(true, false, {})
|
||||
]
|
||||
|
||||
if (m.hideInAnswer === true) {
|
||||
msgs.push("_This option cannot be chosen as answer_")
|
||||
}
|
||||
if (m.ifnot !== undefined) {
|
||||
msgs.push(
|
||||
"Unselecting this answer will add " +
|
||||
m.ifnot.asHumanString(true, false, {})
|
||||
m.ifnot.asHumanString(true, false, {})
|
||||
)
|
||||
}
|
||||
return msgs
|
||||
|
@ -863,12 +869,12 @@ export default class TagRenderingConfig {
|
|||
if (this.labels?.length > 0) {
|
||||
labels = [
|
||||
"This tagrendering has labels ",
|
||||
...this.labels.map((label) => "`" + label + "`"),
|
||||
...this.labels.map((label) => "`" + label + "`")
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
return [
|
||||
"### "+this.id,
|
||||
"### " + this.id,
|
||||
this.description,
|
||||
this.question !== undefined
|
||||
? "The question is `" + this.question.txt + "`"
|
||||
|
@ -876,7 +882,7 @@ export default class TagRenderingConfig {
|
|||
withRender.join("\n"),
|
||||
mappings,
|
||||
condition,
|
||||
labels,
|
||||
labels
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
|
@ -936,7 +942,7 @@ export class TagRenderingConfigUtils {
|
|||
const oldMappingsCloned =
|
||||
clone.mappings?.map((m) => ({
|
||||
...m,
|
||||
priorityIf: m.priorityIf ?? TagUtils.Tag("id~*"),
|
||||
priorityIf: m.priorityIf ?? TagUtils.Tag("id~*")
|
||||
})) ?? []
|
||||
clone.mappings = [...oldMappingsCloned, ...extraMappings]
|
||||
return clone
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue