Chore: housekeeping

This commit is contained in:
Pieter Vander Vennet 2024-06-20 04:21:29 +02:00
parent 8178c5607b
commit cd0d275965
73 changed files with 2105 additions and 2219 deletions

View file

@ -7,12 +7,12 @@ import {
FirstOf,
Fuse,
On,
SetDefault
SetDefault,
} from "./Conversion"
import { LayerConfigJson } from "../Json/LayerConfigJson"
import {
MinimalTagRenderingConfigJson,
TagRenderingConfigJson
TagRenderingConfigJson,
} from "../Json/TagRenderingConfigJson"
import { Utils } from "../../../Utils"
import RewritableConfigJson from "../Json/RewritableConfigJson"
@ -85,17 +85,17 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
}
const options = matchingTr.mappings.map((mapping) => ({
question: mapping.then,
osmTags: mapping.if
osmTags: mapping.if,
}))
options.unshift({
question: {
en: "All types"
en: "All types",
},
osmTags: undefined
osmTags: undefined,
})
newFilters.push({
id: filter,
options
options,
})
continue
}
@ -134,9 +134,9 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
.enter(filter)
.err(
"While searching for predefined filter " +
filter +
": this filter is not found. Perhaps you meant one of: " +
suggestions
filter +
": this filter is not found. Perhaps you meant one of: " +
suggestions
)
}
newFilters.push(found)
@ -149,9 +149,9 @@ class ExpandTagRendering extends Conversion<
| string
| TagRenderingConfigJson
| {
builtin: string | string[]
override: any
},
builtin: string | string[]
override: any
},
TagRenderingConfigJson[]
> {
private readonly _state: DesugaringContext
@ -340,25 +340,25 @@ class ExpandTagRendering extends Conversion<
ctx.warn(
`A literal rendering was detected: ${tr}
Did you perhaps forgot to add a layer name as 'layername.${tr}'? ` +
Array.from(state.sharedLayers.keys()).join(", ")
Array.from(state.sharedLayers.keys()).join(", ")
)
}
if (this._options?.noHardcodedStrings && this._state?.sharedLayers?.size > 0) {
ctx.err(
"Detected an invocation to a builtin tagRendering, but this tagrendering was not found: " +
tr +
" \n Did you perhaps forget to add the layer as prefix, such as `icons." +
tr +
"`? "
tr +
" \n Did you perhaps forget to add the layer as prefix, such as `icons." +
tr +
"`? "
)
}
return [
<any>{
render: tr,
id: tr.replace(/[^a-zA-Z0-9]/g, "")
}
id: tr.replace(/[^a-zA-Z0-9]/g, ""),
},
]
}
return lookup
@ -385,9 +385,9 @@ class ExpandTagRendering extends Conversion<
}
ctx.err(
"An object calling a builtin can only have keys `builtin` or `override`, but a key with name `" +
key +
"` was found. This won't be picked up! The full object is: " +
JSON.stringify(tr)
key +
"` was found. This won't be picked up! The full object is: " +
JSON.stringify(tr)
)
}
@ -411,19 +411,19 @@ class ExpandTagRendering extends Conversion<
if (state.sharedLayers.size === 0) {
ctx.warn(
"BOOTSTRAPPING. Rerun generate layeroverview. While reusing tagrendering: " +
name +
": layer " +
layerName +
" not found for now, but ignoring as this is a bootstrapping run. "
name +
": layer " +
layerName +
" not found for now, but ignoring as this is a bootstrapping run. "
)
} else {
ctx.err(
": While reusing tagrendering: " +
name +
": layer " +
layerName +
" not found. Maybe you meant one of " +
candidates.slice(0, 3).join(", ")
name +
": layer " +
layerName +
" not found. Maybe you meant one of " +
candidates.slice(0, 3).join(", ")
)
}
continue
@ -435,10 +435,10 @@ class ExpandTagRendering extends Conversion<
candidates = Utils.sortedByLevenshteinDistance(name, candidates, (i) => i)
ctx.err(
"The tagRendering with identifier " +
name +
" was not found.\n\tDid you mean one of " +
candidates.join(", ") +
"?\n(Hint: did you add a new label and are you trying to use this label at the same time? Run 'reset:layeroverview' first"
name +
" was not found.\n\tDid you mean one of " +
candidates.join(", ") +
"?\n(Hint: did you add a new label and are you trying to use this label at the same time? Run 'reset:layeroverview' first"
)
continue
}
@ -492,7 +492,7 @@ class DetectInline extends DesugaringStep<QuestionableTagRenderingConfigJson> {
if (json.freeform.inline === true) {
context.err(
"'inline' is set, but the rendering contains a special visualisation...\n " +
spec[key]
spec[key]
)
}
json = JSON.parse(JSON.stringify(json))
@ -578,20 +578,20 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
if (blacklisted?.length > 0 && used?.length > 0) {
context.err(
"The {questions()}-special rendering only supports either a blacklist OR a whitelist, but not both." +
"\n Whitelisted: " +
used.join(", ") +
"\n Blacklisted: " +
blacklisted.join(", ")
"\n Whitelisted: " +
used.join(", ") +
"\n Blacklisted: " +
blacklisted.join(", ")
)
}
for (const usedLabel of used) {
if (!allLabels.has(usedLabel)) {
context.err(
"This layers specifies a special question element for label `" +
usedLabel +
"`, but this label doesn't exist.\n" +
" Available labels are " +
Array.from(allLabels).join(", ")
usedLabel +
"`, but this label doesn't exist.\n" +
" Available labels are " +
Array.from(allLabels).join(", ")
)
}
seen.add(usedLabel)
@ -605,8 +605,8 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
const question: QuestionableTagRenderingConfigJson = {
id: "leftover-questions",
render: {
"*": `{questions( ,${Array.from(seen).join(";")})}`
}
"*": `{questions( ,${Array.from(seen).join(";")})}`,
},
}
json.tagRenderings.push(question)
}
@ -626,11 +626,11 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
"all_tags",
"qr_code",
"nearby_images",
"linked_open_data"
"linked_open_data",
]
private readonly _desugaring: DesugaringContext
private readonly _addedByDefaultAtTop : QuestionableTagRenderingConfigJson[]
private readonly _addedByDefaultAtTop: QuestionableTagRenderingConfigJson[]
private readonly _addedByDefault: QuestionableTagRenderingConfigJson[]
constructor(desugaring: DesugaringContext) {
super(
@ -643,17 +643,14 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
const builtinQuestions = Array.from(this._desugaring.tagRenderings?.values() ?? [])
function getAddedByDefaultIds(key: string): QuestionableTagRenderingConfigJson[] {
const addByDefault = builtinQuestions.filter(tr => tr.labels?.indexOf(key) >= 0)
const ids = new Set(addByDefault.map(tr => tr.id))
const idsInOrder = desugaring.tagRenderingOrder?.filter(id => ids.has(id)) ?? []
return Utils.NoNull(idsInOrder.map(id => desugaring.tagRenderings.get(id)))
const addByDefault = builtinQuestions.filter((tr) => tr.labels?.indexOf(key) >= 0)
const ids = new Set(addByDefault.map((tr) => tr.id))
const idsInOrder = desugaring.tagRenderingOrder?.filter((id) => ids.has(id)) ?? []
return Utils.NoNull(idsInOrder.map((id) => desugaring.tagRenderings.get(id)))
}
this._addedByDefaultAtTop = getAddedByDefaultIds("added_by_default_top")
this._addedByDefault = getAddedByDefaultIds("added_by_default")
}
convert(json: LayerConfigJson, _: ConversionContext): LayerConfigJson {
@ -681,7 +678,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
/***** ADD TO TOP ****/
json.tagRenderings.unshift(...this._addedByDefaultAtTop.filter(tr => !allIds.has(tr.id)))
json.tagRenderings.unshift(...this._addedByDefaultAtTop.filter((tr) => !allIds.has(tr.id)))
/***** ADD TO BOTTOM ****/
@ -689,10 +686,11 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
json.tagRenderings.push(this._desugaring.tagRenderings.get("minimap"))
}
if(usedSpecialFunctions.has("image_upload") &&
!usedSpecialFunctions.has("nearby_images")){
if (
usedSpecialFunctions.has("image_upload") &&
!usedSpecialFunctions.has("nearby_images")
) {
json.tagRenderings.push(this._desugaring.tagRenderings.get("nearby_images"))
}
if (json.allowSplit && !usedSpecialFunctions.has("split_button")) {
@ -703,18 +701,17 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
if (json.allowMove && !usedSpecialFunctions.has("move_button")) {
json.tagRenderings.push({
id: "move-button",
render: { "*": "{move_button()}" }
render: { "*": "{move_button()}" },
})
}
if (json.deletion && !usedSpecialFunctions.has("delete_button")) {
json.tagRenderings.push({
id: "delete-button",
render: { "*": "{delete_button()}" }
render: { "*": "{delete_button()}" },
})
}
json.tagRenderings.push(...this._addedByDefault.filter(tr => !allIds.has(tr.id)))
json.tagRenderings.push(...this._addedByDefault.filter((tr) => !allIds.has(tr.id)))
if (!usedSpecialFunctions.has("all_tags")) {
const trc: QuestionableTagRenderingConfigJson = {
@ -725,9 +722,9 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
or: [
"__featureSwitchIsDebugging=true",
"mapcomplete-show_tags=full",
"mapcomplete-show_debug=yes"
]
}
"mapcomplete-show_debug=yes",
],
},
}
json.tagRenderings?.push(trc)
}
@ -749,9 +746,9 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
}
private static escapeStr(v: string, context: ConversionContext): string {
if(typeof v !== "string"){
context.err("Detected a non-string value where one expected a string: "+v)
return RewriteSpecial.escapeStr(""+v, context)
if (typeof v !== "string") {
context.err("Detected a non-string value where one expected a string: " + v)
return RewriteSpecial.escapeStr("" + v, context)
}
return v
.replace(/,/g, "&COMMA")
@ -835,10 +832,10 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
private static convertIfNeeded(
input:
| (object & {
special: {
type: string
}
})
special: {
type: string
}
})
| any,
context: ConversionContext
): any {
@ -924,7 +921,6 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
const after = Translations.T(input.after)
const clss: string = input.class !== undefined ? ":" + input.class : ""
for (const ln of Object.keys(before?.translations ?? {})) {
foundLanguages.add(ln)
}
@ -937,7 +933,7 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
.map((nm) => RewriteSpecial.escapeStr(special[nm] ?? "", context))
.join(",")
return {
"*": `{${type}(${args})${clss}}`
"*": `{${type}(${args})${clss}}`,
}
}
@ -962,7 +958,9 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
}
const beforeText = before?.textFor(ln) ?? ""
const afterText = after?.textFor(ln) ?? ""
result[ln] = `${beforeText}{${type}(${args.map((a) => a).join(",")})${clss}}${afterText}`
result[ln] = `${beforeText}{${type}(${args
.map((a) => a)
.join(",")})${clss}}${afterText}`
}
return result
}
@ -1049,7 +1047,7 @@ class ExpandIconBadges extends DesugaringStep<PointRenderingConfigJson> {
iconBadges.push(
...expanded.map((resolved) => ({
if: iconBadge.if,
then: <MinimalTagRenderingConfigJson>resolved
then: <MinimalTagRenderingConfigJson>resolved,
}))
)
}
@ -1186,7 +1184,7 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
const specialVis: Exclude<RenderingSpecification, string>[] = <
Exclude<RenderingSpecification, string>[]
>ValidationUtils.getAllSpecialVisualisations(<any>json.tagRenderings).filter(
>ValidationUtils.getAllSpecialVisualisations(<any>json.tagRenderings).filter(
(rs) => typeof rs !== "string"
)
const funcs = new Set<string>(specialVis.map((rs) => rs.func.funcName))
@ -1222,7 +1220,7 @@ export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> {
}
return <TagRenderingConfigJson>{
id: "title_icon_auto_" + tr.id,
mappings
mappings,
}
}
@ -1267,8 +1265,8 @@ export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> {
.enters("titleIcons", i)
.warn(
"TagRendering with id " +
trId +
" does not have any icons, not generating an icon for this"
trId +
" does not have any icons, not generating an icon for this"
)
continue
}
@ -1292,7 +1290,7 @@ export class PrepareLayer extends Fuse<LayerConfigJson> {
(layer) =>
new Concat(
new ExpandTagRendering(state, layer, {
addToContext: options?.addTagRenderingsToContext ?? false
addToContext: options?.addTagRenderingsToContext ?? false,
})
)
),

View file

@ -278,8 +278,7 @@ export default class LayerConfig extends WithContextLoader {
)
}
this.units = (json.units ?? []).flatMap((unitJson, i) =>
Unit.fromJson(unitJson, this.tagRenderings, `${context}.unit[${i}]`)
Unit.fromJson(unitJson, this.tagRenderings, `${context}.unit[${i}]`)
)
if (

View file

@ -205,7 +205,7 @@ export default class PointRenderingConfig extends WithContextLoader {
marker: this.marker,
rotation: this.rotation,
tags,
emojiHeight: iconH
emojiHeight: iconH,
}).SetClass("w-full h-full")
: undefined
let badges = undefined

View file

@ -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 + "`",
]
}
@ -829,14 +829,18 @@ export default class TagRenderingConfig {
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'>"
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, {})
icon +
" " +
"*" +
m.then.txt +
"* corresponds with " +
m.if.asHumanString(true, false, {}),
]
if (m.hideInAnswer === true) {
@ -845,7 +849,7 @@ export default class TagRenderingConfig {
if (m.ifnot !== undefined) {
msgs.push(
"Unselecting this answer will add " +
m.ifnot.asHumanString(true, false, {})
m.ifnot.asHumanString(true, false, {})
)
}
return msgs
@ -869,7 +873,7 @@ 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")
}
@ -882,7 +886,7 @@ export default class TagRenderingConfig {
withRender.join("\n"),
mappings,
condition,
labels
labels,
].join("\n")
}
@ -942,7 +946,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

View file

@ -5,7 +5,7 @@ import { Store, UIEventSource } from "../Logic/UIEventSource"
import {
FeatureSource,
IndexedFeatureSource,
WritableFeatureSource
WritableFeatureSource,
} from "../Logic/FeatureSource/FeatureSource"
import { OsmConnection } from "../Logic/Osm/OsmConnection"
import { ExportableMap, MapProperties } from "./MapProperties"
@ -51,7 +51,7 @@ import SaveFeatureSourceToLocalStorage from "../Logic/FeatureSource/Actors/SaveF
import BBoxFeatureSource from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource"
import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor"
import NoElementsInViewDetector, {
FeatureViewState
FeatureViewState,
} from "../Logic/Actors/NoElementsInViewDetector"
import FilteredLayer from "./FilteredLayer"
import { PreferredRasterLayerSelector } from "../Logic/Actors/PreferredRasterLayerSelector"
@ -64,7 +64,7 @@ import { GeolocationControlState } from "../UI/BigComponents/GeolocationControl"
import Zoomcontrol from "../UI/Zoomcontrol"
import {
SummaryTileSource,
SummaryTileSourceRewriter
SummaryTileSourceRewriter,
} from "../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
import summaryLayer from "../assets/generated/layers/summary.json"
import last_click_layerconfig from "../assets/generated/layers/last_click.json"
@ -165,7 +165,6 @@ export default class ThemeViewState implements SpecialVisualizationState {
const initial = new InitialMapPositioning(layout, geolocationState)
this.mapProperties = new MapLibreAdaptor(this.map, initial)
this.featureSwitchIsTesting = this.featureSwitches.featureSwitchIsTesting
this.featureSwitchUserbadge = this.featureSwitches.featureSwitchEnableLogin
@ -176,7 +175,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
"oauth_token",
undefined,
"Used to complete the login"
)
),
})
this.userRelatedState = new UserRelatedState(
this.osmConnection,
@ -251,8 +250,8 @@ export default class ThemeViewState implements SpecialVisualizationState {
bbox.asGeoJson({
zoom: this.mapProperties.zoom.data,
...this.mapProperties.location.data,
id: "current_view_" + currentViewIndex
})
id: "current_view_" + currentViewIndex,
}),
]
})
)
@ -269,7 +268,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
featurePropertiesStore: this.featureProperties,
osmConnection: this.osmConnection,
historicalUserLocations: this.geolocation.historicalUserLocations,
featureSwitches: this.featureSwitches
featureSwitches: this.featureSwitches,
},
layout?.isLeftRightSensitive() ?? false
)
@ -296,7 +295,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
"leftover features, such as",
features[0].properties
)
}
},
}
)
this.perLayer = perLayer.perLayer
@ -334,7 +333,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
return sorted
})
this.lastClickObject = new LastClickFeatureSource(this.layout, this.mapProperties.lastClickLocation)
this.lastClickObject = new LastClickFeatureSource(
this.layout,
this.mapProperties.lastClickLocation
)
this.osmObjectDownloader = new OsmObjectDownloader(
this.osmConnection.Backend(),
@ -348,7 +350,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
{
currentZoom: this.mapProperties.zoom,
layerState: this.layerState,
bounds: this.visualFeedbackViewportBounds
bounds: this.visualFeedbackViewportBounds,
}
)
this.hasDataInView = new NoElementsInViewDetector(this).hasFeatureInView
@ -440,7 +442,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
doShowLayer,
metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement,
fetchStore: (id) => this.featureProperties.getStore(id)
fetchStore: (id) => this.featureProperties.getStore(id),
})
})
return filteringFeatureSource
@ -464,7 +466,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
doShowLayer: flayerGps.isDisplayed,
layer: flayerGps.layerDef,
metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement
selectedElement: this.selectedElement,
})
}
@ -556,7 +558,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey(
{
nomod: " ",
onUp: true
onUp: true,
},
docs.selectItem,
() => {
@ -586,7 +588,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey(
{
nomod: "" + i,
onUp: true
onUp: true,
},
doc,
() => this.selectClosestAtCenter(i - 1)
@ -599,7 +601,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
}
Hotkeys.RegisterHotkey(
{
nomod: "b"
nomod: "b",
},
docs.openLayersPanel,
() => {
@ -610,7 +612,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
)
Hotkeys.RegisterHotkey(
{
nomod: "s"
nomod: "s",
},
Translations.t.hotkeyDocumentation.openFilterPanel,
() => {
@ -668,7 +670,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey(
{
shift: "T"
shift: "T",
},
Translations.t.hotkeyDocumentation.translationMode,
() => {
@ -700,7 +702,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.mapProperties.zoom.map((z) => Math.max(Math.floor(z), 0)),
this.mapProperties,
{
isActive: this.mapProperties.zoom.map((z) => z <= maxzoom)
isActive: this.mapProperties.zoom.map((z) => z <= maxzoom),
}
)
return new SummaryTileSourceRewriter(summaryTileSource, this.layerState.filteredLayers)
@ -715,10 +717,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
/**
* A listing which maps the layerId onto the featureSource
*/
const specialLayers: Record<
AddedByDefaultTypes | "current_view",
FeatureSource
> = {
const specialLayers: Record<AddedByDefaultTypes | "current_view", FeatureSource> = {
home_location: this.userRelatedState.homeLocation,
gps_location: this.geolocation.currentUserLocation,
gps_location_history: this.geolocation.historicalUserLocations,
@ -734,7 +733,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
current_view: this.currentView,
favourite: this.favourites,
summary: this.featureSummary,
last_click: this.lastClickObject
last_click: this.lastClickObject,
}
this.closestFeatures.registerSource(specialLayers.favourite, "favourite")
@ -789,7 +788,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
doShowLayer: flayer.isDisplayed,
layer: flayer.layerDef,
metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement
selectedElement: this.selectedElement,
})
})
@ -797,23 +796,29 @@ export default class ThemeViewState implements SpecialVisualizationState {
features: specialLayers.summary,
layer: new LayerConfig(<LayerConfigJson>summaryLayer, "summaryLayer"),
// doShowLayer: this.mapProperties.zoom.map((z) => z < maxzoom),
selectedElement: this.selectedElement
selectedElement: this.selectedElement,
})
const lastClickLayerConfig = new LayerConfig(<LayerConfigJson>last_click_layerconfig, "last_click")
const lastClickLayerConfig = new LayerConfig(
<LayerConfigJson>last_click_layerconfig,
"last_click"
)
const lastClickFiltered =
lastClickLayerConfig.isShown === undefined ? specialLayers.last_click :
specialLayers.last_click.features.mapD(fs =>
fs.filter(
f => {
const matches = lastClickLayerConfig.isShown.matchesProperties(f.properties)
console.log("LastClick ",f,"matches",matches)
return matches
}))
lastClickLayerConfig.isShown === undefined
? specialLayers.last_click
: specialLayers.last_click.features.mapD((fs) =>
fs.filter((f) => {
const matches = lastClickLayerConfig.isShown.matchesProperties(
f.properties
)
console.log("LastClick ", f, "matches", matches)
return matches
})
)
new ShowDataLayer(this.map, {
features: new StaticFeatureSource(lastClickFiltered),
layer: lastClickLayerConfig,
onClick: feature => {
onClick: (feature) => {
console.log("Last click was clicked", feature)
if (this.mapProperties.zoom.data >= Constants.minZoomLevelToAddNewPoint) {
this.selectedElement.setData(feature)
@ -821,9 +826,9 @@ export default class ThemeViewState implements SpecialVisualizationState {
}
this.map.data.flyTo({
zoom: Constants.minZoomLevelToAddNewPoint,
center: GeoOperations.centerpointCoordinates(feature)
center: GeoOperations.centerpointCoordinates(feature),
})
}
},
})
}

View file

@ -27,9 +27,19 @@ export class Unit {
) {
this.quantity = quantity
this._validator = validator
if(!inverted && ["string","text","key","icon","translation","fediverse","id"].indexOf(validator.name) >= 0){
if (
!inverted &&
["string", "text", "key", "icon", "translation", "fediverse", "id"].indexOf(
validator.name
) >= 0
) {
console.trace("Unit error")
throw "Invalid unit configuration. The validator is of a forbidden type: "+validator.name+"; set a (number) type to your freeform key or set inverted. Hint: this unit is applied onto keys: "+appliesToKeys.join("; ")
throw (
"Invalid unit configuration. The validator is of a forbidden type: " +
validator.name +
"; set a (number) type to your freeform key or set inverted. Hint: this unit is applied onto keys: " +
appliesToKeys.join("; ")
)
}
this.inverted = inverted
this.appliesToKeys = new Set(appliesToKeys)