diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.json index 7772c9691..c3608b448 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.json @@ -565,6 +565,10 @@ "if": "theme=rainbow_crossings", "then": "./assets/themes/rainbow_crossings/logo.svg" }, + { + "if": "theme=sauna", + "then": "./assets/layers/sauna/sauna.svg" + }, { "if": "theme=scouting", "then": "./assets/layers/scouting_group/scouting.svg" diff --git a/src/Logic/DetermineTheme.ts b/src/Logic/DetermineTheme.ts index fed03a7ce..9da701591 100644 --- a/src/Logic/DetermineTheme.ts +++ b/src/Logic/DetermineTheme.ts @@ -108,8 +108,7 @@ export default class DetermineTheme { if (themeInfo === undefined) { const alternatives = Utils.sortedByLevenshteinDistance( id, - themes.map((th) => th.id), - (i) => i + themes.map((th) => th.id) ).slice(0, 3) const msg = `No builtin map theme with name ${layoutId} exists. Perhaps you meant one of ${alternatives.join( ", " diff --git a/src/Models/MenuState.ts b/src/Models/MenuState.ts index 9a616f015..e313899d3 100644 --- a/src/Models/MenuState.ts +++ b/src/Models/MenuState.ts @@ -111,8 +111,7 @@ export class MenuState { "No tagRendering with id '" + highlightTagRendering + "'; maybe you meant:", Utils.sortedByLevenshteinDistance( highlightTagRendering, - UserRelatedState.availableUserSettingsIds, - (x) => x + UserRelatedState.availableUserSettingsIds ) ) } diff --git a/src/Models/ThemeConfig/Conversion/ExpandFilter.ts b/src/Models/ThemeConfig/Conversion/ExpandFilter.ts index cb74004e8..1674fcabf 100644 --- a/src/Models/ThemeConfig/Conversion/ExpandFilter.ts +++ b/src/Models/ThemeConfig/Conversion/ExpandFilter.ts @@ -259,8 +259,7 @@ export class ExpandFilter extends DesugaringStep { if (found === undefined) { const suggestions = Utils.sortedByLevenshteinDistance( filter, - Array.from(ExpandFilter.predefinedFilters.keys()), - (t) => t + Array.from(ExpandFilter.predefinedFilters.keys()) ) context .enter(filter) diff --git a/src/Models/ThemeConfig/Conversion/ExpandTagRendering.ts b/src/Models/ThemeConfig/Conversion/ExpandTagRendering.ts index d9fa5a35a..3af5888c2 100644 --- a/src/Models/ThemeConfig/Conversion/ExpandTagRendering.ts +++ b/src/Models/ThemeConfig/Conversion/ExpandTagRendering.ts @@ -387,8 +387,7 @@ export class ExpandTagRendering extends Conversion< if (layer === undefined) { const candidates = Utils.sortedByLevenshteinDistance( layerName, - Utils.NoNull(Array.from(state.sharedLayers.keys())), - (s) => s + Utils.NoNull(Array.from(state.sharedLayers.keys())) ) if (candidates.length === 0) { ctx.err( @@ -419,7 +418,7 @@ export class ExpandTagRendering extends Conversion< ) } - candidates = Utils.sortedByLevenshteinDistance(name, candidates, (i) => i) + candidates = Utils.sortedByLevenshteinDistance(name, candidates) ctx.err( "The tagRendering with identifier " + name + diff --git a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts index e156b5f9b..bbf154fc9 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts @@ -71,7 +71,8 @@ class SubstituteLayer extends Conversion { ) const available = new Set(knownIds) if (!isCategory && !available.has(backgroundId)) { - const nearby = Utils.sortedByLevenshteinDistance(backgroundId, knownIds, (t) => t) + const nearby = Utils.sortedByLevenshteinDistance(backgroundId, knownIds) context .enter("defaultBackgroundId") .err( diff --git a/src/Models/ThemeConfig/FilterConfig.ts b/src/Models/ThemeConfig/FilterConfig.ts index 62eaa9453..ad6088bf7 100644 --- a/src/Models/ThemeConfig/FilterConfig.ts +++ b/src/Models/ThemeConfig/FilterConfig.ts @@ -65,8 +65,7 @@ export default class FilterConfig { if (Validators.availableTypes.indexOf(type) < 0) { throw `Invalid filter: type is not a valid validator. Did you mean one of ${Utils.sortedByLevenshteinDistance( type, - >Validators.availableTypes, - (x) => x + >Validators.availableTypes ).slice(0, 3)}` } // Type is validated against 'ValidatedTextField' in Validation.ts, in ValidateFilterConfig diff --git a/src/Models/ThemeConfig/TagRenderingConfig.ts b/src/Models/ThemeConfig/TagRenderingConfig.ts index 3387c4426..75ae17a90 100644 --- a/src/Models/ThemeConfig/TagRenderingConfig.ts +++ b/src/Models/ThemeConfig/TagRenderingConfig.ts @@ -212,8 +212,7 @@ export default class TagRenderingConfig { json.freeform.type }, perhaps you meant ${Utils.sortedByLevenshteinDistance( json.freeform.key, - Validators.availableTypes, - (s) => s + Validators.availableTypes )}. See https://source.mapcomplete.org/MapComplete/MapComplete/src/branch/develop/Docs/SpecialInputElements.md for more information` } const type: ValidatorType = json.freeform.type ?? "string" diff --git a/src/UI/InputElement/ValidatedInput.svelte b/src/UI/InputElement/ValidatedInput.svelte index 1c9ccd4f8..a91cde102 100644 --- a/src/UI/InputElement/ValidatedInput.svelte +++ b/src/UI/InputElement/ValidatedInput.svelte @@ -166,8 +166,7 @@ "'; did you perhaps mean one of: " + Utils.sortedByLevenshteinDistance( type, - Validators.AllValidators.map((v) => v.name), - (v) => v + Validators.AllValidators.map((v) => v.name) ) .slice(0, 5) .join(", ") diff --git a/src/UI/InputElement/Validators/DistanceValidator.ts b/src/UI/InputElement/Validators/DistanceValidator.ts index ddf7c10f9..b51130159 100644 --- a/src/UI/InputElement/Validators/DistanceValidator.ts +++ b/src/UI/InputElement/Validators/DistanceValidator.ts @@ -47,7 +47,7 @@ export default class DistanceValidator extends Validator { if (bg && eliCategory.indexOf(bg) < 0) { return ( "The given background layer is not a recognized ELI-type. Perhaps you meant one of " + - Utils.sortedByLevenshteinDistance(bg, eliCategory, (x) => x).slice(0, 5) + Utils.sortedByLevenshteinDistance(bg, eliCategory).slice(0, 5) ) } if (typeof args["zoom"] !== "number") { diff --git a/src/UI/SpecialVisualisations/SettingsVisualisations.ts b/src/UI/SpecialVisualisations/SettingsVisualisations.ts index b74264289..a6f2c7af0 100644 --- a/src/UI/SpecialVisualisations/SettingsVisualisations.ts +++ b/src/UI/SpecialVisualisations/SettingsVisualisations.ts @@ -198,7 +198,7 @@ class QrLogin extends SpecialVisualizationSvelte { class Logout extends SpecialVisualizationSvelte { funcName = "logout" args = [] - needsUrls = [Constants.osmAuthConfig.url] + needsUrls = [Constants.osmAuthConfig] docs = "Shows a button where the user can log out" group = "settings" diff --git a/src/Utils.ts b/src/Utils.ts index d65a7e6fd..bfe46f1f7 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1259,11 +1259,21 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be } } + public static sortedByLevenshteinDistance( + reference: string, + ts: ReadonlyArray + ): string[] public static sortedByLevenshteinDistance( reference: string, ts: ReadonlyArray, getName: (t: T) => string + ): string[] + public static sortedByLevenshteinDistance( + reference: string, + ts: ReadonlyArray, + getName?: (t: T) => string ): T[] { + getName ??= (str) => str; const withDistance: [T, number][] = ts.map((t) => [ t, Utils.levenshteinDistance(getName(t), reference),