From cba72ea91580b226d73dcc41d0e8c9228137be43 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 26 Sep 2020 01:43:20 +0200 Subject: [PATCH] Fix country detection, fix phone number formatting, close #103 --- Logic/FilteredLayer.ts | 13 ++++++++----- UI/Input/ValidatedTextField.ts | 6 ++++-- package.json | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Logic/FilteredLayer.ts b/Logic/FilteredLayer.ts index d89764558..c5d37eb5d 100644 --- a/Logic/FilteredLayer.ts +++ b/Logic/FilteredLayer.ts @@ -110,14 +110,17 @@ export class FilteredLayer { if (this.filters.matches(tags)) { const centerPoint = GeoOperations.centerpoint(feature); - feature.properties["_surface"] = ""+GeoOperations.surfaceAreaInSqMeters(feature); - const lat = ""+centerPoint.geometry.coordinates[1]; - const lon = ""+centerPoint.geometry.coordinates[0] - feature.properties["_lon"] = lat; - feature.properties["_lat"] = lon; + feature.properties["_surface"] = "" + GeoOperations.surfaceAreaInSqMeters(feature); + const lat = centerPoint.geometry.coordinates[1]; + const lon = centerPoint.geometry.coordinates[0] + feature.properties["_lon"] = "" + lat; // We expect a string here for lat/lon + feature.properties["_lat"] = "" + lon; + // But the codegrid SHOULD be a number! FilteredLayer.grid.getCode(lat, lon, (error, code) => { if (error === null) { feature.properties["_country"] = code; + } else { + console.warn("Could not determine country for", feature.properties.id, error); } }) diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 9c533735d..9f2c1df82 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -87,11 +87,13 @@ export default class ValidatedTextField { "phone", "A phone number", (str, country: any) => { + if (str === undefined) { + return false; + } return parsePhoneNumberFromString(str, country?.toUpperCase())?.isValid() ?? false }, (str, country: any) => { - console.log("reformatting phone nuber",str, "for locale", country) - return parsePhoneNumberFromString(str, country?.toUpperCase()).formatInternational() + return parsePhoneNumberFromString(str, country?.toUpperCase()).formatInternational() } ) ] diff --git a/package.json b/package.json index ad8941bcc..de139dc6d 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "repository": "https://github.com/pietervdvn/MapComplete", "description": "A small website to edit OSM easily", "main": "index.js", - "disabled:staticFiles": { + "staticFiles": { "staticPath": [ { - "staticPath": "static-assets/tiles", + "staticPath": "tiles/", "staticOutDir": "./tiles/" } ]