Port bicycle cafés to JSON-defined-layer

This commit is contained in:
Pieter Vander Vennet 2020-09-11 02:14:16 +02:00
parent 3653c3ecaa
commit 0c2f662040
17 changed files with 229 additions and 276 deletions

View file

@ -47,6 +47,10 @@ export class AllKnownLayouts {
let layer = layout.layers[i];
if (typeof (layer) === "string") {
layer = layout.layers[i] = FromJSON.sharedLayers.get(layer);
if(layer === undefined){
console.log("Defined layers are ", FromJSON.sharedLayers.keys())
throw `Layer ${layer} was not found or defined - probably a type was made`
}
}

View file

@ -16,6 +16,7 @@ import * as bike_parking from "../../assets/layers/bike_parking/bike_parking.jso
import * as bike_repair_station from "../../assets/layers/bike_repair_station/bike_repair_station.json"
import * as birdhides from "../../assets/layers/bird_hide/birdhides.json"
import * as nature_reserve from "../../assets/layers/nature_reserve/nature_reserve.json"
import * as bike_cafes from "../../assets/layers/bike_cafe/bike_cafes.json"
import {Utils} from "../../Utils";
import ImageCarouselWithUploadConstructor from "../../UI/Image/ImageCarouselWithUpload";
@ -41,6 +42,7 @@ export class FromJSON {
FromJSON.Layer(bike_repair_station),
FromJSON.Layer(birdhides),
FromJSON.Layer(nature_reserve),
FromJSON.Layer(bike_cafes),
];
for (const layer of sharedLayersList) {

View file

@ -1,65 +0,0 @@
import {LayerDefinition} from "../LayerDefinition";
import FixedText from "../Questions/FixedText";
import ImageCarouselWithUploadConstructor from "../../UI/Image/ImageCarouselWithUpload";
import Translations from "../../UI/i18n/Translations";
import CafeName from "../Questions/bike/CafeName";
import {And, Or, RegexTag, Tag} from "../../Logic/Tags";
import {PhoneNumberQuestion} from "../Questions/PhoneNumberQuestion";
import Website from "../Questions/Website";
import CafeRepair from "../Questions/bike/CafeRepair";
import CafeDiy from "../Questions/bike/CafeDiy";
import CafePump from "../Questions/bike/CafePump";
import {EmailQuestion} from "../Questions/EmailQuestion";
export default class BikeCafes extends LayerDefinition {
private readonly to = Translations.t.cyclofix.cafe
constructor() {
super("bikecafe")
this.name = this.to.name
this.icon = "./assets/bike/cafe.svg"
this.overpassFilter = new And([
new RegexTag(/^amenity$/, /^pub|bar|cafe$/),
new Or([
new RegexTag(/^service:bicycle:/, /.*/),
new RegexTag(/^pub$/, /^cycling|bicycle$/),
new RegexTag(/^theme$/, /^cycling|bicycle$/),
])
])
this.presets = [
{
title: Translations.t.cyclofix.cafe.title,
tags : [
new Tag("amenity", "pub"),
new Tag("pub", "cycling"),
]
}
]
this.maxAllowedOverlapPercentage = 10;
this.minzoom = 13
this.style = () => ({
color: "#00bb00",
icon: {
iconUrl: "./assets/bike/cafe.svg",
iconSize: [50, 50],
iconAnchor: [25, 50]
}
});
this.title = new FixedText(this.to.title)
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new CafeName(),
new Website("{name}"),
new PhoneNumberQuestion("{name}"),
new EmailQuestion("{name}"),
new CafeRepair(),
new CafeDiy(),
new CafePump()
]
this.wayHandling = LayerDefinition.WAYHANDLING_CENTER_AND_WAY
}
}

View file

@ -3,7 +3,6 @@ import BikeShops from "../Layers/BikeShops";
import Translations from "../../UI/i18n/Translations";
import Combine from "../../UI/Base/Combine";
import BikeOtherShops from "../Layers/BikeOtherShops";
import BikeCafes from "../Layers/BikeCafes";
export default class Cyclofix extends Layout {
@ -21,8 +20,8 @@ export default class Cyclofix extends Layout {
"cyclofix",
["en", "nl", "fr", "gl"],
Translations.t.cyclofix.title,
["bike_repair_station", new BikeShops(), "drinking_water", "bike_parking", new BikeOtherShops(), new BikeCafes(),
// The first of november, we remember our dead
["bike_repair_station", "bike_cafes", new BikeShops(), "drinking_water", "bike_parking", new BikeOtherShops(),
// The first of november, halloween and the second of november, we remember our dead
...(Cyclofix.RememberTheDead() ? ["ghost_bike"] : [])],
16,
50.8465573,

View file

@ -1,18 +0,0 @@
import {Tag} from "../../../Logic/Tags";
import Translations from "../../../UI/i18n/Translations";
import {TagRenderingOptions} from "../../TagRenderingOptions";
export default class CafeDiy extends TagRenderingOptions {
constructor() {
const key = 'service:bicycle:diy'
const to = Translations.t.cyclofix.cafe.diy
super({
question: to.question,
mappings: [
{k: new Tag(key, "yes"), txt: to.yes},
{k: new Tag(key, "no"), txt: to.no},
]
});
}
}

View file

@ -1,17 +0,0 @@
import Translations from "../../../UI/i18n/Translations";
import {TagRenderingOptions} from "../../TagRenderingOptions";
export default class CafeName extends TagRenderingOptions {
constructor() {
const to = Translations.t.cyclofix.cafe.qName
super({
question: to.question,
freeform: {
key: "name",
renderTemplate: to.render,
template: to.template
}
})
}
}

View file

@ -1,18 +0,0 @@
import {Tag} from "../../../Logic/Tags";
import Translations from "../../../UI/i18n/Translations";
import {TagRenderingOptions} from "../../TagRenderingOptions";
export default class CafePump extends TagRenderingOptions {
constructor() {
const key = 'service:bicycle:pump'
const to = Translations.t.cyclofix.cafe.pump
super({
question: to.question,
mappings: [
{k: new Tag(key, "yes"), txt: to.yes},
{k: new Tag(key, "no"), txt: to.no},
]
});
}
}

View file

@ -1,18 +0,0 @@
import {Tag} from "../../../Logic/Tags";
import Translations from "../../../UI/i18n/Translations";
import {TagRenderingOptions} from "../../TagRenderingOptions";
export default class CafeRepair extends TagRenderingOptions {
constructor() {
const key = 'service:bicycle:repair'
const to = Translations.t.cyclofix.cafe.repair
super({
question: to.question,
mappings: [
{k: new Tag(key, "yes"), txt: to.yes},
{k: new Tag(key, "no"), txt: to.no}
]
});
}
}

View file

@ -1,19 +0,0 @@
import { Tag } from "../../../Logic/Tags";
import Translations from "../../../UI/i18n/Translations";
import {TagRenderingOptions} from "../../TagRenderingOptions";
export default class ParkingCovered extends TagRenderingOptions {
constructor() {
const key = 'covered'
const to = Translations.t.cyclofix.parking.covered
super({
priority: 15,
question: to.question.Render(),
mappings: [
{k: new Tag(key, "yes"), txt: to.yes},
{k: new Tag(key, "no"), txt: to.no}
]
});
}
}

View file

@ -1,27 +0,0 @@
import {Tag, And} from "../../../Logic/Tags";
import Translations from "../../../UI/i18n/Translations";
import {TagRenderingOptions} from "../../TagRenderingOptions";
export default class ParkingOperator extends TagRenderingOptions {
constructor() {
const to = Translations.t.cyclofix.parking.operator
super({
priority: 15,
question: to.question.Render(),
freeform: {
key: "operator",
template: to.template,
renderTemplate: to.render,
placeholder: Translations.t.cyclofix.freeFormPlaceholder
},
mappings: [
{k: new Tag("operator", "KU Leuven"), txt: "KU Leuven"},
{k: new Tag("operator", "Stad Halle"), txt: "Stad Halle"},
{k: new Tag("operator", "Saint Gilles - Sint Gillis"), txt: "Saint Gilles - Sint Gillis"},
{k: new Tag("operator", "Jette"), txt: "Jette"},
{k: new And([new Tag("operator", ""), new Tag("operator:type", "private")]), txt: to.private.Render()}
]
});
}
}