forked from MapComplete/MapComplete
TagRenderingConfig now automatically chooses an iconsize based on common icon sizes
This commit is contained in:
parent
f9ce1e4db4
commit
4a8a07a10b
1 changed files with 4 additions and 3 deletions
|
@ -177,7 +177,8 @@ export default class TagRenderingConfig {
|
|||
throw "Tagrendering has a 'mappings'-object, but expected a list (" + context + ")"
|
||||
}
|
||||
|
||||
this.mappings = json.mappings.map((m, i) => TagRenderingConfig.ExtractMapping(m, i, translationKey, context, this.multiAnswer, this.question !== undefined));
|
||||
const commonIconSize = Utils.NoNull(json.mappings.map(m => m.icon !== undefined ? m.icon["class"] : undefined))[0] ?? "small"
|
||||
this.mappings = json.mappings.map((m, i) => TagRenderingConfig.ExtractMapping(m, i, translationKey, context, this.multiAnswer, this.question !== undefined, commonIconSize));
|
||||
}
|
||||
|
||||
if (this.question && this.freeform?.key === undefined && this.mappings === undefined) {
|
||||
|
@ -288,7 +289,7 @@ export default class TagRenderingConfig {
|
|||
|
||||
public static ExtractMapping(mapping: MappingConfigJson, i: number, translationKey: string,
|
||||
context: string,
|
||||
multiAnswer?: boolean, isQuestionable?: boolean) {
|
||||
multiAnswer?: boolean, isQuestionable?: boolean, commonSize: string = "small") {
|
||||
|
||||
const ctx = `${translationKey}.mappings.${i}`
|
||||
if (mapping.if === undefined) {
|
||||
|
@ -327,7 +328,7 @@ export default class TagRenderingConfig {
|
|||
}
|
||||
|
||||
let icon = undefined;
|
||||
let iconClass = "small"
|
||||
let iconClass = commonSize
|
||||
if (mapping.icon !== undefined) {
|
||||
if (typeof mapping.icon === "string" && mapping.icon !== "") {
|
||||
icon = mapping.icon
|
||||
|
|
Loading…
Reference in a new issue