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