forked from MapComplete/MapComplete
Chore: housekeeping, linting
This commit is contained in:
parent
f942529755
commit
30d00eb06d
74 changed files with 998 additions and 623 deletions
|
@ -1,6 +1,18 @@
|
|||
import { Concat, DesugaringContext, DesugaringStep, Each, FirstOf, Fuse, On, SetDefault } from "./Conversion"
|
||||
import {
|
||||
Concat,
|
||||
DesugaringContext,
|
||||
DesugaringStep,
|
||||
Each,
|
||||
FirstOf,
|
||||
Fuse,
|
||||
On,
|
||||
SetDefault,
|
||||
} from "./Conversion"
|
||||
import { LayerConfigJson } from "../Json/LayerConfigJson"
|
||||
import { MinimalTagRenderingConfigJson, TagRenderingConfigJson } from "../Json/TagRenderingConfigJson"
|
||||
import {
|
||||
MinimalTagRenderingConfigJson,
|
||||
TagRenderingConfigJson,
|
||||
} from "../Json/TagRenderingConfigJson"
|
||||
import { Utils } from "../../../Utils"
|
||||
import RewritableConfigJson from "../Json/RewritableConfigJson"
|
||||
import SpecialVisualizations from "../../../UI/SpecialVisualizations"
|
||||
|
@ -25,7 +37,7 @@ class AddFiltersFromTagRenderings extends DesugaringStep<LayerConfigJson> {
|
|||
constructor() {
|
||||
super(
|
||||
"AddFiltersFromTagRenderings",
|
||||
'Inspects all the tagRenderings. If some tagRenderings have the `filter` attribute set, introduce those filters. This step might introduce shorthand filter names, thus \'ExpandFilter\' should be run afterwards. Can be disabled with "#filter":"no-auto"',
|
||||
'Inspects all the tagRenderings. If some tagRenderings have the `filter` attribute set, introduce those filters. This step might introduce shorthand filter names, thus \'ExpandFilter\' should be run afterwards. Can be disabled with "#filter":"no-auto"'
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -96,7 +108,7 @@ class DetectInline extends DesugaringStep<QuestionableTagRenderingConfigJson> {
|
|||
constructor() {
|
||||
super(
|
||||
"DetectInline",
|
||||
"If no 'inline' is set on the freeform key, it will be automatically added. If no special renderings are used, it'll be set to true",
|
||||
"If no 'inline' is set on the freeform key, it will be automatically added. If no special renderings are used, it'll be set to true"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -158,10 +170,7 @@ class DetectInline extends DesugaringStep<QuestionableTagRenderingConfigJson> {
|
|||
|
||||
export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"AddQuestionBox",
|
||||
"Adds a 'questions'-object if no question element is added yet",
|
||||
)
|
||||
super("AddQuestionBox", "Adds a 'questions'-object if no question element is added yet")
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -373,7 +382,7 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
|
|||
constructor() {
|
||||
super(
|
||||
"RewriteSpecial",
|
||||
"Converts a 'special' translation into a regular translation which uses parameters",
|
||||
"Converts a 'special' translation into a regular translation which uses parameters"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -748,10 +757,7 @@ class PreparePointRendering extends Fuse<PointRenderingConfigJson> {
|
|||
|
||||
class SetFullNodeDatabase extends DesugaringStep<LayerConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"SetFullNodeDatabase",
|
||||
"sets the fullNodeDatabase-bit if needed",
|
||||
)
|
||||
super("SetFullNodeDatabase", "sets the fullNodeDatabase-bit if needed")
|
||||
}
|
||||
|
||||
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
|
||||
|
@ -776,10 +782,7 @@ class ExpandMarkerRenderings extends DesugaringStep<IconConfigJson> {
|
|||
private readonly _state: DesugaringContext
|
||||
|
||||
constructor(state: DesugaringContext, layer: LayerConfigJson) {
|
||||
super(
|
||||
"ExpandMarkerRenderings",
|
||||
"Expands tagRenderings in the icons, if needed",
|
||||
)
|
||||
super("ExpandMarkerRenderings", "Expands tagRenderings in the icons, if needed")
|
||||
this._layer = layer
|
||||
this._state = state
|
||||
}
|
||||
|
@ -811,7 +814,7 @@ class AddFavouriteBadges extends DesugaringStep<LayerConfigJson> {
|
|||
constructor() {
|
||||
super(
|
||||
"AddFavouriteBadges",
|
||||
"Adds the favourite heart to the title and the rendering badges",
|
||||
"Adds the favourite heart to the title and the rendering badges"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -835,7 +838,7 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
|
|||
constructor() {
|
||||
super(
|
||||
"AddRatingBadge",
|
||||
"Adds the 'rating'-element if a reviews-element is used in the tagRenderings",
|
||||
"Adds the 'rating'-element if a reviews-element is used in the tagRenderings"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -870,7 +873,7 @@ export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> {
|
|||
constructor() {
|
||||
super(
|
||||
"AutoTitleIcon",
|
||||
"The auto-icon creates a (non-clickable) title icon based on a tagRendering which has icons",
|
||||
"The auto-icon creates a (non-clickable) title icon based on a tagRendering which has icons"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -946,34 +949,35 @@ export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> {
|
|||
}
|
||||
|
||||
class MoveUnitConfigs extends DesugaringStep<LayerConfigJson> {
|
||||
|
||||
constructor() {
|
||||
super("MoveUnitConfigs", "Looks into all the tagRenderings for a 'unitConfig', moves them to the layer level")
|
||||
super(
|
||||
"MoveUnitConfigs",
|
||||
"Looks into all the tagRenderings for a 'unitConfig', moves them to the layer level"
|
||||
)
|
||||
}
|
||||
|
||||
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
|
||||
json = { ...json, units: [...(json.units ?? [])] }
|
||||
for (const tr of json.tagRenderings ?? []) {
|
||||
const qtr = (<QuestionableTagRenderingConfigJson>tr)
|
||||
const qtr = <QuestionableTagRenderingConfigJson>tr
|
||||
const unitConfig = qtr?.freeform?.unit
|
||||
if (!unitConfig) {
|
||||
continue
|
||||
}
|
||||
json.units.push({
|
||||
[qtr.freeform.key]: unitConfig
|
||||
[qtr.freeform.key]: unitConfig,
|
||||
})
|
||||
// Note: we do not delete the config - this way, if the tagRendering is imported in another layer, the unit comes along
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DeriveSource extends DesugaringStep<LayerConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"DeriveSource",
|
||||
"If no source is given, automatically derives the osmTags by 'or'-ing all the preset tags",
|
||||
"If no source is given, automatically derives the osmTags by 'or'-ing all the preset tags"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue