From 79f8940898585e65b43d729b286a04a97aa42434 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 31 Jul 2020 17:38:03 +0200 Subject: [PATCH] Fix build --- Customizations/AllKnownLayouts.ts | 17 +- Customizations/LayerDefinition.ts | 2 +- Customizations/Layers/Artwork.ts | 2 +- Customizations/Layers/BikeOtherShops.ts | 2 +- Customizations/Layers/BikeShops.ts | 2 +- Customizations/Layers/BikeStations.ts | 2 +- Customizations/Layers/Birdhide.ts | 2 +- Customizations/Layers/Bookcases.ts | 2 +- Customizations/Layers/DrinkingWater.ts | 2 +- Customizations/Layers/GhostBike.ts | 2 +- Customizations/Layers/GrbToFix.ts | 2 +- Customizations/Layers/InformationBoard.ts | 2 +- Customizations/Layers/Map.ts | 2 +- Customizations/Layers/NatureReserves.ts | 17 +- Customizations/Layers/Park.ts | 2 +- Customizations/Layers/Viewpoint.ts | 2 +- Customizations/Layers/Widths.ts | 2 +- Customizations/Layouts/Smoothness.ts | 4 +- Customizations/Questions/AccessTag.ts | 2 +- .../Questions/DescriptionQuestion.ts | 2 +- Customizations/Questions/EmailQuestion.ts | 2 +- Customizations/Questions/FixedText.ts | 2 +- Customizations/Questions/NameInline.ts | 2 +- Customizations/Questions/NameQuestion.ts | 2 +- Customizations/Questions/OperatorTag.ts | 2 +- Customizations/Questions/OsmLink.ts | 2 +- .../Questions/PhoneNumberQuestion.ts | 2 +- Customizations/Questions/Website.ts | 2 +- Customizations/Questions/WikipediaLink.ts | 2 +- Customizations/Questions/bike/CafeDiy.ts | 2 +- Customizations/Questions/bike/CafeName.ts | 2 +- Customizations/Questions/bike/CafePump.ts | 2 +- Customizations/Questions/bike/CafeRepair.ts | 2 +- .../Questions/bike/ParkingAccessCargo.ts | 2 +- .../Questions/bike/ParkingCapacity.ts | 2 +- .../Questions/bike/ParkingCapacityCargo.ts | 2 +- .../Questions/bike/ParkingCovered.ts | 2 +- .../Questions/bike/ParkingOperator.ts | 2 +- Customizations/Questions/bike/ParkingType.ts | 2 +- .../Questions/bike/PumpManometer.ts | 2 +- Customizations/Questions/bike/PumpManual.ts | 2 +- .../Questions/bike/PumpOperational.ts | 2 +- Customizations/Questions/bike/PumpValves.ts | 2 +- Customizations/Questions/bike/ShopDiy.ts | 2 +- Customizations/Questions/bike/ShopName.ts | 2 +- Customizations/Questions/bike/ShopPump.ts | 2 +- Customizations/Questions/bike/ShopRental.ts | 2 +- Customizations/Questions/bike/ShopRepair.ts | 2 +- Customizations/Questions/bike/ShopRetail.ts | 2 +- .../Questions/bike/ShopSecondHand.ts | 2 +- Customizations/Questions/bike/StationBrand.ts | 2 +- Customizations/Questions/bike/StationChain.ts | 2 +- .../Questions/bike/StationOperator.ts | 2 +- .../Questions/bike/StationPumpTools.ts | 2 +- Customizations/Questions/bike/StationStand.ts | 2 +- Customizations/TagRendering.ts | 158 ++---------------- Customizations/TagRenderingOptions.ts | 146 ++++++++++++++++ Customizations/UIElementConstructor.ts | 1 - InitUiElements.ts | 22 +++ State.ts | 21 +-- UI/FeatureInfoBox.ts | 2 +- UI/i18n/Translations.ts | 4 +- createLayouts.ts | 29 +++- index.ts | 1 + 64 files changed, 277 insertions(+), 249 deletions(-) create mode 100644 Customizations/TagRenderingOptions.ts diff --git a/Customizations/AllKnownLayouts.ts b/Customizations/AllKnownLayouts.ts index 4da0610d9..38d889148 100644 --- a/Customizations/AllKnownLayouts.ts +++ b/Customizations/AllKnownLayouts.ts @@ -1,17 +1,17 @@ -import {All} from "./Layouts/All"; -import {StreetWidth} from "./Layouts/StreetWidth"; import {LayerDefinition} from "./LayerDefinition"; -import {ClimbingTrees} from "./Layouts/ClimbingTrees"; -import {Smoothness} from "./Layouts/Smoothness"; -import {Natuurpunt} from "./Layouts/Natuurpunt"; +import {Layout} from "./Layout"; +import {All} from "./Layouts/All"; +import {CustomLayout} from "../Logic/CustomLayers"; import {Groen} from "./Layouts/Groen"; import Cyclofix from "./Layouts/Cyclofix"; -import {Layout} from "./Layout"; -import {CustomLayout} from "../Logic/CustomLayers"; +import {StreetWidth} from "./Layouts/StreetWidth"; import {GRB} from "./Layouts/GRB"; import {Artworks} from "./Layouts/Artworks"; +import {ClimbingTrees} from "./Layouts/ClimbingTrees"; import {WalkByBrussels} from "./Layouts/WalkByBrussels"; +import {Smoothness} from "./Layouts/Smoothness"; import {MetaMap} from "./Layouts/MetaMap"; +import {Natuurpunt} from "./Layouts/Natuurpunt"; import {Bookcases} from "./Layouts/Bookcases"; export class AllKnownLayouts { @@ -31,7 +31,8 @@ export class AllKnownLayouts { new ClimbingTrees(), new Artworks(), new Smoothness(), - /*new Toilets(), + /* + new Toilets(), */ ]; diff --git a/Customizations/LayerDefinition.ts b/Customizations/LayerDefinition.ts index aed16ff20..55a5bbb33 100644 --- a/Customizations/LayerDefinition.ts +++ b/Customizations/LayerDefinition.ts @@ -1,7 +1,7 @@ import {Tag, TagsFilter} from "../Logic/TagsFilter"; import {UIElement} from "../UI/UIElement"; -import {TagRenderingOptions} from "./TagRendering"; import {TagDependantUIElementConstructor} from "./UIElementConstructor"; +import {TagRenderingOptions} from "./TagRenderingOptions"; export interface Preset { tags: Tag[], diff --git a/Customizations/Layers/Artwork.ts b/Customizations/Layers/Artwork.ts index bb9351874..a48ea0332 100644 --- a/Customizations/Layers/Artwork.ts +++ b/Customizations/Layers/Artwork.ts @@ -3,9 +3,9 @@ import {Tag} from "../../Logic/TagsFilter"; import L from "leaflet"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; import Translations from "../../UI/i18n/Translations"; -import {TagRenderingOptions} from "../TagRendering"; import Website from "../Questions/Website"; import FixedText from "../Questions/FixedText"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Artwork extends LayerDefinition { diff --git a/Customizations/Layers/BikeOtherShops.ts b/Customizations/Layers/BikeOtherShops.ts index ffd27e923..1565dd4e4 100644 --- a/Customizations/Layers/BikeOtherShops.ts +++ b/Customizations/Layers/BikeOtherShops.ts @@ -9,9 +9,9 @@ import ShopRepair from "../Questions/bike/ShopRepair"; import ShopDiy from "../Questions/bike/ShopDiy"; import ShopName from "../Questions/bike/ShopName"; import ShopSecondHand from "../Questions/bike/ShopSecondHand"; -import { TagRenderingOptions } from "../TagRendering"; import { PhoneNumberQuestion } from "../Questions/PhoneNumberQuestion"; import Website from "../Questions/Website"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export default class BikeOtherShops extends LayerDefinition { diff --git a/Customizations/Layers/BikeShops.ts b/Customizations/Layers/BikeShops.ts index a56991f6a..ef52f1dce 100644 --- a/Customizations/Layers/BikeShops.ts +++ b/Customizations/Layers/BikeShops.ts @@ -10,10 +10,10 @@ import ShopRepair from "../Questions/bike/ShopRepair"; import ShopDiy from "../Questions/bike/ShopDiy"; import ShopName from "../Questions/bike/ShopName"; import ShopSecondHand from "../Questions/bike/ShopSecondHand"; -import { TagRenderingOptions } from "../TagRendering"; import {PhoneNumberQuestion} from "../Questions/PhoneNumberQuestion"; import Website from "../Questions/Website"; import {EmailQuestion} from "../Questions/EmailQuestion"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export default class BikeShops extends LayerDefinition { diff --git a/Customizations/Layers/BikeStations.ts b/Customizations/Layers/BikeStations.ts index 251b19869..3b2158d07 100644 --- a/Customizations/Layers/BikeStations.ts +++ b/Customizations/Layers/BikeStations.ts @@ -12,7 +12,7 @@ import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWi import PumpOperational from "../Questions/bike/PumpOperational"; import PumpValves from "../Questions/bike/PumpValves"; import Translations from "../../UI/i18n/Translations"; -import { TagRenderingOptions } from "../TagRendering"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export default class BikeStations extends LayerDefinition { diff --git a/Customizations/Layers/Birdhide.ts b/Customizations/Layers/Birdhide.ts index 8d65152ec..c7dc52782 100644 --- a/Customizations/Layers/Birdhide.ts +++ b/Customizations/Layers/Birdhide.ts @@ -1,8 +1,8 @@ import {LayerDefinition} from "../LayerDefinition"; import {And, Or, Tag} from "../../Logic/TagsFilter"; -import {TagRenderingOptions} from "../TagRendering"; import FixedText from "../Questions/FixedText"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Birdhide extends LayerDefinition { diff --git a/Customizations/Layers/Bookcases.ts b/Customizations/Layers/Bookcases.ts index ff21817e6..0252a0cb9 100644 --- a/Customizations/Layers/Bookcases.ts +++ b/Customizations/Layers/Bookcases.ts @@ -1,10 +1,10 @@ import {LayerDefinition} from "../LayerDefinition"; import {And, Or, Tag} from "../../Logic/TagsFilter"; -import {TagRenderingOptions} from "../TagRendering"; import {NameInline} from "../Questions/NameInline"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; import Translations from "../../UI/i18n/Translations"; import T from "../../UI/i18n/Translation"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Bookcases extends LayerDefinition { diff --git a/Customizations/Layers/DrinkingWater.ts b/Customizations/Layers/DrinkingWater.ts index f9791304f..6266b97cf 100644 --- a/Customizations/Layers/DrinkingWater.ts +++ b/Customizations/Layers/DrinkingWater.ts @@ -3,9 +3,9 @@ import {And, Or, Tag} from "../../Logic/TagsFilter"; import {OperatorTag} from "../Questions/OperatorTag"; import * as L from "leaflet"; import FixedText from "../Questions/FixedText"; -import {TagRenderingOptions} from "../TagRendering"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; import Translations from "../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class DrinkingWater extends LayerDefinition { diff --git a/Customizations/Layers/GhostBike.ts b/Customizations/Layers/GhostBike.ts index d70a7f07b..8bf40d868 100644 --- a/Customizations/Layers/GhostBike.ts +++ b/Customizations/Layers/GhostBike.ts @@ -1,10 +1,10 @@ import {LayerDefinition} from "../LayerDefinition"; import {Tag} from "../../Logic/TagsFilter"; import {FixedUiElement} from "../../UI/Base/FixedUiElement"; -import {TagRenderingOptions} from "../TagRendering"; import FixedText from "../Questions/FixedText"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; import L from "leaflet"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class GhostBike extends LayerDefinition { constructor() { diff --git a/Customizations/Layers/GrbToFix.ts b/Customizations/Layers/GrbToFix.ts index 2b616ca1e..ccbf2fd57 100644 --- a/Customizations/Layers/GrbToFix.ts +++ b/Customizations/Layers/GrbToFix.ts @@ -1,6 +1,6 @@ import {LayerDefinition} from "../LayerDefinition"; import {And, Regex, Tag} from "../../Logic/TagsFilter"; -import {TagRenderingOptions} from "../TagRendering"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class GrbToFix extends LayerDefinition { diff --git a/Customizations/Layers/InformationBoard.ts b/Customizations/Layers/InformationBoard.ts index 70afde05b..c0a9a1681 100644 --- a/Customizations/Layers/InformationBoard.ts +++ b/Customizations/Layers/InformationBoard.ts @@ -1,8 +1,8 @@ import {LayerDefinition} from "../LayerDefinition"; import FixedText from "../Questions/FixedText"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; -import {TagRenderingOptions} from "../TagRendering"; import {And, Tag} from "../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class InformationBoard extends LayerDefinition { constructor() { diff --git a/Customizations/Layers/Map.ts b/Customizations/Layers/Map.ts index 00722c5b3..5786b64e0 100644 --- a/Customizations/Layers/Map.ts +++ b/Customizations/Layers/Map.ts @@ -1,8 +1,8 @@ import {LayerDefinition} from "../LayerDefinition"; import FixedText from "../Questions/FixedText"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; -import {TagRenderingOptions} from "../TagRendering"; import {And, Tag} from "../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Map extends LayerDefinition { constructor() { diff --git a/Customizations/Layers/NatureReserves.ts b/Customizations/Layers/NatureReserves.ts index 9d4fed3a3..4bcceeaa8 100644 --- a/Customizations/Layers/NatureReserves.ts +++ b/Customizations/Layers/NatureReserves.ts @@ -1,15 +1,15 @@ import {LayerDefinition} from "../LayerDefinition"; import {Or, Tag} from "../../Logic/TagsFilter"; -import {TagRenderingOptions} from "../TagRendering"; import {AccessTag} from "../Questions/AccessTag"; import {OperatorTag} from "../Questions/OperatorTag"; import {NameQuestion} from "../Questions/NameQuestion"; import {NameInline} from "../Questions/NameInline"; import {DescriptionQuestion} from "../Questions/DescriptionQuestion"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class NatureReserves extends LayerDefinition { - + constructor(moreQuests: boolean = false) { super("natureReserve"); this.name = "Natuurgebied"; @@ -30,13 +30,6 @@ export class NatureReserves extends LayerDefinition { this.style = this.generateStyleFunction(); this.elementsToShow = [ new ImageCarouselWithUploadConstructor(), - /* new TagRenderingOptions({ - freeform: { - key: "_surface", - renderTemplate: "{_surface}m²", - template: "$$$" - } - }),*/ new NameQuestion(), new AccessTag(), new OperatorTag(), @@ -111,9 +104,9 @@ export class NatureReserves extends LayerDefinition { return function (properties: any) { let questionSeverity = 0; for (const qd of self.elementsToShow) { - if(qd instanceof DescriptionQuestion){ - continue; - } + //if(qd instanceof DescriptionQuestion){ + // continue; + //} if (qd.IsQuestioning(properties)) { questionSeverity = Math.max(questionSeverity, qd.Priority() ?? 0); } diff --git a/Customizations/Layers/Park.ts b/Customizations/Layers/Park.ts index 5c69dae74..cfb8692c4 100644 --- a/Customizations/Layers/Park.ts +++ b/Customizations/Layers/Park.ts @@ -2,11 +2,11 @@ import {LayerDefinition} from "../LayerDefinition"; import {And, Or, Tag} from "../../Logic/TagsFilter"; import {AccessTag} from "../Questions/AccessTag"; import {OperatorTag} from "../Questions/OperatorTag"; -import {TagRenderingOptions} from "../TagRendering"; import {NameQuestion} from "../Questions/NameQuestion"; import {NameInline} from "../Questions/NameInline"; import {DescriptionQuestion} from "../Questions/DescriptionQuestion"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Park extends LayerDefinition { diff --git a/Customizations/Layers/Viewpoint.ts b/Customizations/Layers/Viewpoint.ts index f6c477c15..05122b49b 100644 --- a/Customizations/Layers/Viewpoint.ts +++ b/Customizations/Layers/Viewpoint.ts @@ -3,7 +3,7 @@ import {FixedUiElement} from "../../UI/Base/FixedUiElement"; import FixedText from "../Questions/FixedText"; import {Tag} from "../../Logic/TagsFilter"; import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; -import {TagRenderingOptions} from "../TagRendering"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Viewpoint extends LayerDefinition { diff --git a/Customizations/Layers/Widths.ts b/Customizations/Layers/Widths.ts index 000bd67b4..3a6819475 100644 --- a/Customizations/Layers/Widths.ts +++ b/Customizations/Layers/Widths.ts @@ -1,8 +1,8 @@ import {LayerDefinition} from "../LayerDefinition"; import {And, Not, Or, Tag} from "../../Logic/TagsFilter"; -import {TagRenderingOptions} from "../TagRendering"; import {UIEventSource} from "../../UI/UIEventSource"; import {Park} from "./Park"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class Widths extends LayerDefinition { diff --git a/Customizations/Layouts/Smoothness.ts b/Customizations/Layouts/Smoothness.ts index 1590f2d1d..11d697c77 100644 --- a/Customizations/Layouts/Smoothness.ts +++ b/Customizations/Layouts/Smoothness.ts @@ -1,13 +1,13 @@ import {Layout} from "../Layout"; import {LayerDefinition} from "../LayerDefinition"; import {Or, Tag} from "../../Logic/TagsFilter"; -import {TagRenderingOptions} from "../TagRendering"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class SmoothnessLayer extends LayerDefinition { constructor() { - super(); + super("smoothness"); this.name = "smoothness"; this.minzoom = 17; this.overpassFilter = new Or([ diff --git a/Customizations/Questions/AccessTag.ts b/Customizations/Questions/AccessTag.ts index e947e8b37..7ed7ed05a 100644 --- a/Customizations/Questions/AccessTag.ts +++ b/Customizations/Questions/AccessTag.ts @@ -1,7 +1,7 @@ -import {TagRenderingOptions} from "../TagRendering"; import {UIEventSource} from "../../UI/UIEventSource"; import {Changes} from "../../Logic/Osm/Changes"; import {And, Tag} from "../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class AccessTag extends TagRenderingOptions { diff --git a/Customizations/Questions/DescriptionQuestion.ts b/Customizations/Questions/DescriptionQuestion.ts index 46f7263ab..2abd9e951 100644 --- a/Customizations/Questions/DescriptionQuestion.ts +++ b/Customizations/Questions/DescriptionQuestion.ts @@ -1,4 +1,4 @@ -import {TagRenderingOptions} from "../TagRendering"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class DescriptionQuestion extends TagRenderingOptions{ diff --git a/Customizations/Questions/EmailQuestion.ts b/Customizations/Questions/EmailQuestion.ts index ee99bd4e2..6120ea8c8 100644 --- a/Customizations/Questions/EmailQuestion.ts +++ b/Customizations/Questions/EmailQuestion.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../TagRendering"; import {UIElement} from "../../UI/UIElement"; import Translations from "../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class EmailQuestion extends TagRenderingOptions { diff --git a/Customizations/Questions/FixedText.ts b/Customizations/Questions/FixedText.ts index d3f51001d..5884532fe 100644 --- a/Customizations/Questions/FixedText.ts +++ b/Customizations/Questions/FixedText.ts @@ -1,5 +1,5 @@ -import { TagRenderingOptions } from "../TagRendering"; import {UIElement} from "../../UI/UIElement"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export default class FixedText extends TagRenderingOptions { constructor(category: string | UIElement) { diff --git a/Customizations/Questions/NameInline.ts b/Customizations/Questions/NameInline.ts index 2e28cf91a..4e687f330 100644 --- a/Customizations/Questions/NameInline.ts +++ b/Customizations/Questions/NameInline.ts @@ -1,7 +1,7 @@ -import {TagRenderingOptions} from "../TagRendering"; import {And, Tag} from "../../Logic/TagsFilter"; import {UIElement} from "../../UI/UIElement"; import Translations from "../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class NameInline extends TagRenderingOptions{ diff --git a/Customizations/Questions/NameQuestion.ts b/Customizations/Questions/NameQuestion.ts index 9e8ef9bbf..810578b67 100644 --- a/Customizations/Questions/NameQuestion.ts +++ b/Customizations/Questions/NameQuestion.ts @@ -3,8 +3,8 @@ * One is a big 'name-question', the other is the 'edit name' in the title. * THis one is the big question */ -import {TagRenderingOptions} from "../TagRendering"; import {Tag} from "../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class NameQuestion extends TagRenderingOptions{ diff --git a/Customizations/Questions/OperatorTag.ts b/Customizations/Questions/OperatorTag.ts index 009115e39..2d293f7e9 100644 --- a/Customizations/Questions/OperatorTag.ts +++ b/Customizations/Questions/OperatorTag.ts @@ -1,7 +1,7 @@ -import {TagRenderingOptions} from "../TagRendering"; import {UIEventSource} from "../../UI/UIEventSource"; import {Changes} from "../../Logic/Osm/Changes"; import {Tag} from "../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class OperatorTag extends TagRenderingOptions { diff --git a/Customizations/Questions/OsmLink.ts b/Customizations/Questions/OsmLink.ts index 830ea4029..ef50fd047 100644 --- a/Customizations/Questions/OsmLink.ts +++ b/Customizations/Questions/OsmLink.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../TagRendering"; import {Img} from "../../UI/Img"; import {Tag} from "../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class OsmLink extends TagRenderingOptions { diff --git a/Customizations/Questions/PhoneNumberQuestion.ts b/Customizations/Questions/PhoneNumberQuestion.ts index 5e1c991b7..703376639 100644 --- a/Customizations/Questions/PhoneNumberQuestion.ts +++ b/Customizations/Questions/PhoneNumberQuestion.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../TagRendering"; import {UIElement} from "../../UI/UIElement"; import Translations from "../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class PhoneNumberQuestion extends TagRenderingOptions { diff --git a/Customizations/Questions/Website.ts b/Customizations/Questions/Website.ts index c03f63de2..ce3f3ca6a 100644 --- a/Customizations/Questions/Website.ts +++ b/Customizations/Questions/Website.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../TagRendering"; import {UIElement} from "../../UI/UIElement"; import Translations from "../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export default class Website extends TagRenderingOptions { diff --git a/Customizations/Questions/WikipediaLink.ts b/Customizations/Questions/WikipediaLink.ts index 7d9087c00..f230b8729 100644 --- a/Customizations/Questions/WikipediaLink.ts +++ b/Customizations/Questions/WikipediaLink.ts @@ -1,4 +1,4 @@ -import {TagRenderingOptions} from "../TagRendering"; +import {TagRenderingOptions} from "../TagRenderingOptions"; export class WikipediaLink extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/CafeDiy.ts b/Customizations/Questions/bike/CafeDiy.ts index b72ff7bca..d090ab9c4 100644 --- a/Customizations/Questions/bike/CafeDiy.ts +++ b/Customizations/Questions/bike/CafeDiy.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class CafeDiy extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/CafeName.ts b/Customizations/Questions/bike/CafeName.ts index a834ac573..5d29bdb6d 100644 --- a/Customizations/Questions/bike/CafeName.ts +++ b/Customizations/Questions/bike/CafeName.ts @@ -1,5 +1,5 @@ -import {TagRenderingOptions} from "../../TagRendering"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class CafeName extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/CafePump.ts b/Customizations/Questions/bike/CafePump.ts index a5754af63..088ed548d 100644 --- a/Customizations/Questions/bike/CafePump.ts +++ b/Customizations/Questions/bike/CafePump.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class CafePump extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/CafeRepair.ts b/Customizations/Questions/bike/CafeRepair.ts index f46f64440..d1919567b 100644 --- a/Customizations/Questions/bike/CafeRepair.ts +++ b/Customizations/Questions/bike/CafeRepair.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class CafeRepair extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ParkingAccessCargo.ts b/Customizations/Questions/bike/ParkingAccessCargo.ts index 186ebc93f..00a2983bf 100644 --- a/Customizations/Questions/bike/ParkingAccessCargo.ts +++ b/Customizations/Questions/bike/ParkingAccessCargo.ts @@ -1,6 +1,6 @@ -import { TagRenderingOptions } from "../../TagRendering"; import { Tag } from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ParkingAccessCargo extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ParkingCapacity.ts b/Customizations/Questions/bike/ParkingCapacity.ts index 99470dad5..9d2f9df42 100644 --- a/Customizations/Questions/bike/ParkingCapacity.ts +++ b/Customizations/Questions/bike/ParkingCapacity.ts @@ -1,5 +1,5 @@ import Translations from "../../../UI/i18n/Translations"; -import { TagRenderingOptions } from "../../TagRendering"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ParkingCapacity extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ParkingCapacityCargo.ts b/Customizations/Questions/bike/ParkingCapacityCargo.ts index ad6d923c1..a43bbc08d 100644 --- a/Customizations/Questions/bike/ParkingCapacityCargo.ts +++ b/Customizations/Questions/bike/ParkingCapacityCargo.ts @@ -1,6 +1,6 @@ import Translations from "../../../UI/i18n/Translations"; -import { TagRenderingOptions } from "../../TagRendering"; import Combine from "../../../UI/Base/Combine"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ParkingCapacityCargo extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ParkingCovered.ts b/Customizations/Questions/bike/ParkingCovered.ts index dff25d838..56adaff4e 100644 --- a/Customizations/Questions/bike/ParkingCovered.ts +++ b/Customizations/Questions/bike/ParkingCovered.ts @@ -1,6 +1,6 @@ -import { TagRenderingOptions } from "../../TagRendering"; import { Tag } from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ParkingCovered extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ParkingOperator.ts b/Customizations/Questions/bike/ParkingOperator.ts index 251bcb502..29cd90762 100644 --- a/Customizations/Questions/bike/ParkingOperator.ts +++ b/Customizations/Questions/bike/ParkingOperator.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag, And} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ParkingOperator extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ParkingType.ts b/Customizations/Questions/bike/ParkingType.ts index 301ceda29..2ecb21729 100644 --- a/Customizations/Questions/bike/ParkingType.ts +++ b/Customizations/Questions/bike/ParkingType.ts @@ -1,7 +1,7 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; import Combine from "../../../UI/Base/Combine"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; class ParkingTypeHelper { static GenerateMappings() { diff --git a/Customizations/Questions/bike/PumpManometer.ts b/Customizations/Questions/bike/PumpManometer.ts index 1ae416efd..3d52d58ae 100644 --- a/Customizations/Questions/bike/PumpManometer.ts +++ b/Customizations/Questions/bike/PumpManometer.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class PumpManometer extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/PumpManual.ts b/Customizations/Questions/bike/PumpManual.ts index 44aa4ee7d..92ad165b3 100644 --- a/Customizations/Questions/bike/PumpManual.ts +++ b/Customizations/Questions/bike/PumpManual.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class PumpManual extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/PumpOperational.ts b/Customizations/Questions/bike/PumpOperational.ts index ac84f0c80..fcd679750 100644 --- a/Customizations/Questions/bike/PumpOperational.ts +++ b/Customizations/Questions/bike/PumpOperational.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class PumpOperational extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/PumpValves.ts b/Customizations/Questions/bike/PumpValves.ts index 51247d052..782583995 100644 --- a/Customizations/Questions/bike/PumpValves.ts +++ b/Customizations/Questions/bike/PumpValves.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class PumpValves extends TagRenderingOptions{ diff --git a/Customizations/Questions/bike/ShopDiy.ts b/Customizations/Questions/bike/ShopDiy.ts index afc11105f..b074ccf0b 100644 --- a/Customizations/Questions/bike/ShopDiy.ts +++ b/Customizations/Questions/bike/ShopDiy.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopDiy extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ShopName.ts b/Customizations/Questions/bike/ShopName.ts index dbf98d90d..1dd1f4864 100644 --- a/Customizations/Questions/bike/ShopName.ts +++ b/Customizations/Questions/bike/ShopName.ts @@ -1,5 +1,5 @@ -import {TagRenderingOptions} from "../../TagRendering"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopPump extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ShopPump.ts b/Customizations/Questions/bike/ShopPump.ts index b9f139c73..83acdf833 100644 --- a/Customizations/Questions/bike/ShopPump.ts +++ b/Customizations/Questions/bike/ShopPump.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopPump extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ShopRental.ts b/Customizations/Questions/bike/ShopRental.ts index f2aafca01..f4659c8b3 100644 --- a/Customizations/Questions/bike/ShopRental.ts +++ b/Customizations/Questions/bike/ShopRental.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopRental extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ShopRepair.ts b/Customizations/Questions/bike/ShopRepair.ts index cf7225af4..8193ba47c 100644 --- a/Customizations/Questions/bike/ShopRepair.ts +++ b/Customizations/Questions/bike/ShopRepair.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopRepair extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ShopRetail.ts b/Customizations/Questions/bike/ShopRetail.ts index bf4fd895c..6b98f4c8c 100644 --- a/Customizations/Questions/bike/ShopRetail.ts +++ b/Customizations/Questions/bike/ShopRetail.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopRetail extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/ShopSecondHand.ts b/Customizations/Questions/bike/ShopSecondHand.ts index 956e167e8..064b60312 100644 --- a/Customizations/Questions/bike/ShopSecondHand.ts +++ b/Customizations/Questions/bike/ShopSecondHand.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class ShopPump extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/StationBrand.ts b/Customizations/Questions/bike/StationBrand.ts index b763bf650..17211b73d 100644 --- a/Customizations/Questions/bike/StationBrand.ts +++ b/Customizations/Questions/bike/StationBrand.ts @@ -1,5 +1,5 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; /** diff --git a/Customizations/Questions/bike/StationChain.ts b/Customizations/Questions/bike/StationChain.ts index 7930d3bc6..c1d616e55 100644 --- a/Customizations/Questions/bike/StationChain.ts +++ b/Customizations/Questions/bike/StationChain.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class StationChain extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/StationOperator.ts b/Customizations/Questions/bike/StationOperator.ts index 5d09434e0..39380a744 100644 --- a/Customizations/Questions/bike/StationOperator.ts +++ b/Customizations/Questions/bike/StationOperator.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class BikeStationOperator extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/StationPumpTools.ts b/Customizations/Questions/bike/StationPumpTools.ts index 5442eba51..43876f6d4 100644 --- a/Customizations/Questions/bike/StationPumpTools.ts +++ b/Customizations/Questions/bike/StationPumpTools.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag, And} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class BikeStationPumpTools extends TagRenderingOptions { diff --git a/Customizations/Questions/bike/StationStand.ts b/Customizations/Questions/bike/StationStand.ts index be6ac4a1e..c21d23248 100644 --- a/Customizations/Questions/bike/StationStand.ts +++ b/Customizations/Questions/bike/StationStand.ts @@ -1,6 +1,6 @@ -import {TagRenderingOptions} from "../../TagRendering"; import {Tag} from "../../../Logic/TagsFilter"; import Translations from "../../../UI/i18n/Translations"; +import {TagRenderingOptions} from "../../TagRenderingOptions"; export default class BikeStationStand extends TagRenderingOptions { diff --git a/Customizations/TagRendering.ts b/Customizations/TagRendering.ts index 5b60904f5..5b6eb17bd 100644 --- a/Customizations/TagRendering.ts +++ b/Customizations/TagRendering.ts @@ -3,11 +3,8 @@ import {UIEventSource} from "../UI/UIEventSource"; import {And, Tag, TagsFilter, TagUtils} from "../Logic/TagsFilter"; import {FixedUiElement} from "../UI/Base/FixedUiElement"; import {SaveButton} from "../UI/SaveButton"; -import {Changes} from "../Logic/Osm/Changes"; import {VariableUiElement} from "../UI/Base/VariableUIElement"; -import {Dependencies, TagDependantUIElement, TagDependantUIElementConstructor} from "./UIElementConstructor"; -import {OnlyShowIfConstructor} from "./OnlyShowIf"; -import {UserDetails} from "../Logic/Osm/OsmConnection"; +import {TagDependantUIElement} from "./UIElementConstructor"; import {TextField} from "../UI/Input/TextField"; import {InputElement} from "../UI/Input/InputElement"; import {InputElementWrapper} from "../UI/Input/InputElementWrapper"; @@ -15,151 +12,11 @@ import {FixedInputElement} from "../UI/Input/FixedInputElement"; import {RadioButton} from "../UI/Input/RadioButton"; import Translations from "../UI/i18n/Translations"; import Locale from "../UI/i18n/Locale"; -import * as EmailValidator from 'email-validator'; -import {parsePhoneNumberFromString} from 'libphonenumber-js' import {State} from "../State"; +import {TagRenderingOptions} from "./TagRenderingOptions"; -export class TagRenderingOptions implements TagDependantUIElementConstructor { - - - public static inputValidation = { - "$": (str) => true, - "string": (str) => true, - "int": (str) => str.indexOf(".") < 0 && !isNaN(Number(str)), - "nat": (str) => str.indexOf(".") < 0 && !isNaN(Number(str)) && Number(str) > 0, - "float": (str) => !isNaN(Number(str)), - "pfloat": (str) => !isNaN(Number(str)) && Number(str) > 0, - "email": (str) => EmailValidator.validate(str), - "phone": (str, country) => { - return parsePhoneNumberFromString(str, country.toUpperCase())?.isValid() ?? false; - }, - } - - public static formatting = { - "phone": (str, country) => { - console.log("country formatting", country) - return parsePhoneNumberFromString(str, country.toUpperCase()).formatInternational() - } - } - - /** - * Notes: by not giving a 'question', one disables the question form alltogether - */ - - public options: { - priority?: number; - question?: string | UIElement; - freeform?: { - key: string; - tagsPreprocessor?: (tags: any) => any; - template: string | UIElement; - renderTemplate: string | UIElement; - placeholder?: string | UIElement; - extraTags?: TagsFilter - }; - mappings?: { k: TagsFilter; txt: string | UIElement; priority?: number, substitute?: boolean }[] - }; - - - constructor(options: { - - - - /** - * This is the string that is shown in the popup if this tag is missing. - * - * If 'question' is undefined, then the question is never asked at all - * If the question is "" (empty string) then the question is - */ - question?: UIElement | string, - - /** - * What is the priority of the question. - * By default, in the popup of a feature, only one question is shown at the same time. If multiple questions are unanswered, the question with the highest priority is asked first - */ - priority?: number, - - - /** - * Mappings convert a well-known tag combination into a user friendly text. - * It converts e.g. 'access=yes' into 'this area can be accessed' - * - * If there are multiple tags that should be matched, And can be used. All tags in AND will be added when the question is picked (and the corresponding text will only be shown if all tags are present). - * If AND is used, it is best practice to make sure every used tag is in every option (with empty string) to erase extra tags. - * - * If a 'k' is null, then this one is shown by default. It can be used to force a default value, e.g. to show that the name of a POI is not (yet) known . - * A mapping where 'k' is null will not be shown as option in the radio buttons. - * - * - */ - mappings?: { k: TagsFilter, txt: UIElement | string, priority?: number, substitute?: boolean }[], - - - /** - * If one wants to render a freeform tag (thus no predefined key/values) or if there are a few well-known tags with a freeform object, - * use this. - * In the question, it'll offer a textfield - */ - freeform?: { - key: string, - template: string | UIElement, - renderTemplate: string | UIElement - placeholder?: string | UIElement, - extraTags?: TagsFilter, - }, - - - /** - * In some very rare cases, tags have to be rewritten before displaying - * This function can be used for that. - * This function is ran on a _copy_ of the original properties - */ - tagsPreprocessor?: ((tags: any) => void) - }) { - - this.options = options; - } - - OnlyShowIf(tagsFilter: TagsFilter): TagDependantUIElementConstructor { - return new OnlyShowIfConstructor(tagsFilter, this); - } - - - IsQuestioning(tags: any): boolean { - const tagsKV = TagUtils.proprtiesToKV(tags); - - for (const oneOnOneElement of this.options.mappings ?? []) { - if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tagsKV)) { - return false; - } - } - if (this.options.freeform !== undefined && tags[this.options.freeform.key] !== undefined) { - return false; - } - if (this.options.question === undefined) { - return false; - } - - return true; - } - - - construct(dependencies: Dependencies): TagDependantUIElement { - return new TagRendering(dependencies.tags, this.options); - } - - IsKnown(properties: any): boolean { - return !this.IsQuestioning(properties); - } - - Priority(): number { - return this.options.priority ?? 0; - } - -} - -class TagRendering extends UIElement implements TagDependantUIElement { +export class TagRendering extends UIElement implements TagDependantUIElement { private _priority: number; @@ -189,13 +46,20 @@ class TagRendering extends UIElement implements TagDependantUIElement { private readonly _editMode: UIEventSource = new UIEventSource(false); + private static injected = TagRendering.injectFunction(); + static injectFunction() { + // This is a workaround as not to import tagrendering into TagREnderingOptions + TagRenderingOptions.tagRendering = (tags, options) => new TagRendering(tags, options); + return true; + } + constructor(tags: UIEventSource, options: { priority?: number question?: string | UIElement, freeform?: { - key: string, + key: string, template: string | UIElement, renderTemplate: string | UIElement, placeholder?: string | UIElement, diff --git a/Customizations/TagRenderingOptions.ts b/Customizations/TagRenderingOptions.ts new file mode 100644 index 000000000..7aeb72388 --- /dev/null +++ b/Customizations/TagRenderingOptions.ts @@ -0,0 +1,146 @@ +import {Dependencies, TagDependantUIElement, TagDependantUIElementConstructor} from "./UIElementConstructor"; +import * as EmailValidator from "email-validator"; +import {parsePhoneNumberFromString} from "libphonenumber-js"; +import {UIElement} from "../UI/UIElement"; +import {TagsFilter, TagUtils} from "../Logic/TagsFilter"; +import {OnlyShowIfConstructor} from "./OnlyShowIf"; +import {UIEventSource} from "../UI/UIEventSource"; + +export class TagRenderingOptions implements TagDependantUIElementConstructor { + + + public static inputValidation = { + "$": (str) => true, + "string": (str) => true, + "int": (str) => str.indexOf(".") < 0 && !isNaN(Number(str)), + "nat": (str) => str.indexOf(".") < 0 && !isNaN(Number(str)) && Number(str) > 0, + "float": (str) => !isNaN(Number(str)), + "pfloat": (str) => !isNaN(Number(str)) && Number(str) > 0, + "email": (str) => EmailValidator.validate(str), + "phone": (str, country) => { + return parsePhoneNumberFromString(str, country.toUpperCase())?.isValid() ?? false; + }, + } + + public static formatting = { + "phone": (str, country) => { + console.log("country formatting", country) + return parsePhoneNumberFromString(str, country.toUpperCase()).formatInternational() + } + } + + /** + * Notes: by not giving a 'question', one disables the question form alltogether + */ + + public options: { + priority?: number; + question?: string | UIElement; + freeform?: { + key: string; + tagsPreprocessor?: (tags: any) => any; + template: string | UIElement; + renderTemplate: string | UIElement; + placeholder?: string | UIElement; + extraTags?: TagsFilter + }; + mappings?: { k: TagsFilter; txt: string | UIElement; priority?: number, substitute?: boolean }[] + }; + + + constructor(options: { + + + /** + * This is the string that is shown in the popup if this tag is missing. + * + * If 'question' is undefined, then the question is never asked at all + * If the question is "" (empty string) then the question is + */ + question?: UIElement | string, + + /** + * What is the priority of the question. + * By default, in the popup of a feature, only one question is shown at the same time. If multiple questions are unanswered, the question with the highest priority is asked first + */ + priority?: number, + + + /** + * Mappings convert a well-known tag combination into a user friendly text. + * It converts e.g. 'access=yes' into 'this area can be accessed' + * + * If there are multiple tags that should be matched, And can be used. All tags in AND will be added when the question is picked (and the corresponding text will only be shown if all tags are present). + * If AND is used, it is best practice to make sure every used tag is in every option (with empty string) to erase extra tags. + * + * If a 'k' is null, then this one is shown by default. It can be used to force a default value, e.g. to show that the name of a POI is not (yet) known . + * A mapping where 'k' is null will not be shown as option in the radio buttons. + * + * + */ + mappings?: { k: TagsFilter, txt: UIElement | string, priority?: number, substitute?: boolean }[], + + + /** + * If one wants to render a freeform tag (thus no predefined key/values) or if there are a few well-known tags with a freeform object, + * use this. + * In the question, it'll offer a textfield + */ + freeform?: { + key: string, + template: string | UIElement, + renderTemplate: string | UIElement + placeholder?: string | UIElement, + extraTags?: TagsFilter, + }, + + + /** + * In some very rare cases, tags have to be rewritten before displaying + * This function can be used for that. + * This function is ran on a _copy_ of the original properties + */ + tagsPreprocessor?: ((tags: any) => void) + }) { + + this.options = options; + } + + OnlyShowIf(tagsFilter: TagsFilter): TagDependantUIElementConstructor { + return new OnlyShowIfConstructor(tagsFilter, this); + } + + + IsQuestioning(tags: any): boolean { + const tagsKV = TagUtils.proprtiesToKV(tags); + + for (const oneOnOneElement of this.options.mappings ?? []) { + if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tagsKV)) { + return false; + } + } + if (this.options.freeform !== undefined && tags[this.options.freeform.key] !== undefined) { + return false; + } + if (this.options.question === undefined) { + return false; + } + + return true; + } + + + public static tagRendering : (tags: UIEventSource, options: { priority?: number; question?: string | UIElement; freeform?: { key: string; tagsPreprocessor?: (tags: any) => any; template: string | UIElement; renderTemplate: string | UIElement; placeholder?: string | UIElement; extraTags?: TagsFilter }; mappings?: { k: TagsFilter; txt: string | UIElement; priority?: number; substitute?: boolean }[] }) => TagDependantUIElement; + construct(dependencies: Dependencies): TagDependantUIElement { + return TagRenderingOptions.tagRendering(dependencies.tags, this.options); + } + + IsKnown(properties: any): boolean { + return !this.IsQuestioning(properties); + } + + Priority(): number { + return this.options.priority ?? 0; + } + +} \ No newline at end of file diff --git a/Customizations/UIElementConstructor.ts b/Customizations/UIElementConstructor.ts index dfde608b1..0920c129f 100644 --- a/Customizations/UIElementConstructor.ts +++ b/Customizations/UIElementConstructor.ts @@ -1,5 +1,4 @@ import {UIEventSource} from "../UI/UIEventSource"; -import {Changes} from "../Logic/Osm/Changes"; import {UIElement} from "../UI/UIElement"; diff --git a/InitUiElements.ts b/InitUiElements.ts index d81890e3c..e4072e996 100644 --- a/InitUiElements.ts +++ b/InitUiElements.ts @@ -24,6 +24,8 @@ import {LayerSelection} from "./UI/LayerSelection"; import {CustomLayersPanel} from "./Logic/CustomLayersPanel"; import {CustomLayout} from "./Logic/CustomLayers"; import {Preset} from "./Customizations/LayerDefinition"; +import {VariableUiElement} from "./UI/Base/VariableUIElement"; +import {LayerUpdater} from "./Logic/LayerUpdater"; export class InitUiElements { @@ -123,6 +125,26 @@ export class InitUiElements { }); } + + static InitBaseMap(){ + State.state.bm = new Basemap("leafletDiv", State.state.locationControl, new VariableUiElement( + State.state.locationControl.map((location) => { + const mapComplete = "Mapcomple " + + " " + + "Report bug"; + let editHere = ""; + if (location !== undefined) { + editHere = " | " + + "" + + "edit here" + + "" + } + return mapComplete + editHere; + + }) + )); + State.state.layerUpdater = new LayerUpdater(State.state); + } static InitLayers() { diff --git a/State.ts b/State.ts index b2171fdab..6f6c0bb7a 100644 --- a/State.ts +++ b/State.ts @@ -7,7 +7,6 @@ import {Utils} from "./Utils"; import {LayerDefinition, Preset} from "./Customizations/LayerDefinition"; import {ElementStorage} from "./Logic/ElementStorage"; import {Changes} from "./Logic/Osm/Changes"; -import {Basemap} from "./Logic/Leaflet/Basemap"; import {OsmConnection} from "./Logic/Osm/OsmConnection"; import Locale from "./UI/i18n/Locale"; import {VariableUiElement} from "./UI/Base/VariableUIElement"; @@ -43,7 +42,7 @@ export class State { /** THe basemap with leaflet instance */ - public bm: Basemap; + public bm; /** The user crednetials */ @@ -188,23 +187,7 @@ export class State { return; } - this.bm = new Basemap("leafletDiv", this.locationControl, new VariableUiElement( - this.locationControl.map((location) => { - const mapComplete = "Mapcomple " + - " " + - "Report bug"; - let editHere = ""; - if (location !== undefined) { - editHere = " | " + - "" + - "edit here" + - "" - } - return mapComplete + editHere; - - }) - )); - this.layerUpdater = new LayerUpdater(this); + } diff --git a/UI/FeatureInfoBox.ts b/UI/FeatureInfoBox.ts index 933eb9759..a1d8690da 100644 --- a/UI/FeatureInfoBox.ts +++ b/UI/FeatureInfoBox.ts @@ -2,7 +2,6 @@ import {UIElement} from "./UIElement"; import {UIEventSource} from "./UIEventSource"; import {ImageCarousel} from "./Image/ImageCarousel"; import {VerticalCombine} from "./Base/VerticalCombine"; -import {TagRenderingOptions} from "../Customizations/TagRendering"; import {OsmLink} from "../Customizations/Questions/OsmLink"; import {WikipediaLink} from "../Customizations/Questions/WikipediaLink"; import {And} from "../Logic/TagsFilter"; @@ -12,6 +11,7 @@ import {Changes} from "../Logic/Osm/Changes"; import {UserDetails} from "../Logic/Osm/OsmConnection"; import {FixedUiElement} from "./Base/FixedUiElement"; import {State} from "../State"; +import {TagRenderingOptions} from "../Customizations/TagRenderingOptions"; export class FeatureInfoBox extends UIElement { diff --git a/UI/i18n/Translations.ts b/UI/i18n/Translations.ts index 3630cf944..b411ebe24 100644 --- a/UI/i18n/Translations.ts +++ b/UI/i18n/Translations.ts @@ -956,7 +956,7 @@ export default class Translations { }) }, favourite: { - title: "Custom", + title: new T({en: "Custom"}), description: new T({ en: "

Your custom theme

In your custom theme, you can add some favourite layers from other themes to create a custom theme." }), @@ -982,6 +982,8 @@ export default class Translations { const item = queue.pop(); if (item instanceof Translation || item.translations !== undefined) { tr.push(item); + } else if (typeof (item) === "string") { + console.warn("Got single string in translationgs file: ", item); } else { for (const t in item) { const x = item[t]; diff --git a/createLayouts.ts b/createLayouts.ts index 261f57d91..3f57149bf 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -1,5 +1,6 @@ import {UIElement} from "./UI/UIElement"; UIElement.runningFromConsole = true; + import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; import {Layout} from "./Customizations/Layout"; import {readFileSync, writeFile, writeFileSync} from "fs"; @@ -7,7 +8,22 @@ import svg2img from 'promise-svg2img'; import Translation from "./UI/i18n/Translation"; import Locale from "./UI/i18n/Locale"; import Translations from "./UI/i18n/Translations"; -import {LayerDefinition} from "./Customizations/LayerDefinition"; + +import {All} from "./Customizations/Layouts/All"; +import {StreetWidth} from "./Customizations/Layouts/StreetWidth"; +import {LayerDefinition} from"./Customizations/LayerDefinition"; +import {ClimbingTrees} from "./Customizations/Layouts/ClimbingTrees"; +import {Smoothness} from "./Customizations/Layouts/Smoothness"; +import {Natuurpunt} from "./Customizations/Layouts/Natuurpunt"; +import {Groen} from "./Customizations/Layouts/Groen"; +import Cyclofix from "./Customizations/Layouts/Cyclofix"; +import {CustomLayout} from "./Logic/CustomLayers"; +import {GRB} from "./Customizations/Layouts/GRB"; +import {Artworks} from "./Customizations/Layouts/Artworks"; +import {WalkByBrussels} from "./Customizations/Layouts/WalkByBrussels"; +import {MetaMap} from "./Customizations/Layouts/MetaMap"; +import {Bookcases} from "./Customizations/Layouts/Bookcases"; + console.log("Building the layouts") @@ -16,7 +32,7 @@ function enc(str: string): string { } function validate(layout: Layout) { - + console.log("Validationg ", layout.name) const translations: Translation[] = []; const queue: any[] = [layout] @@ -162,7 +178,6 @@ function createLandingPage(layout: Layout) { const blacklist = ["", "test", ".", "..", "manifest", "index", "land", "preferences", "account", "openstreetmap"] const all = AllKnownLayouts.allSets; -/* for (const layoutName in all) { if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) { console.log(`Skipping a layout with name${layoutName}, it is on the blacklist`); @@ -175,15 +190,17 @@ for (const layoutName in all) { }; const layout = all[layoutName]; validate(layout) + console.log("Generating manifest") const manif = JSON.stringify(createManifest(layout, "/MapComplete")); const manifestLocation = encodeURIComponent(layout.name.toLowerCase()) + ".webmanifest"; writeFile(manifestLocation, manif, err); const landing = createLandingPage(layout); + console.log("Generating html-file for ",layout.name) writeFile(enc(layout.name) + ".html", landing, err) + console.log("done") } - +console.log("COunting all translations") Translations.CountTranslations(); - - */ \ No newline at end of file +console.log("All done!") \ No newline at end of file diff --git a/index.ts b/index.ts index 6b8caf03f..bbd20ac73 100644 --- a/index.ts +++ b/index.ts @@ -71,6 +71,7 @@ if (layoutToUse === undefined) { console.log("Using layout: ", layoutToUse.name); State.state = new State(layoutToUse); +InitUiElements.InitBaseMap(); function setupAllLayerElements() {