mapcomplete/Customizations/Layers/Bookcases.ts

183 lines
7.1 KiB
TypeScript
Raw Normal View History

2020-06-24 00:35:19 +02:00
import {LayerDefinition} from "../LayerDefinition";
2020-07-20 18:24:00 +02:00
import {And, Or, Tag} from "../../Logic/TagsFilter";
2020-07-08 16:07:16 +02:00
import {NameInline} from "../Questions/NameInline";
2020-07-20 09:57:19 +02:00
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
import Translations from "../../UI/i18n/Translations";
2020-07-27 01:19:38 +02:00
import T from "../../UI/i18n/Translation";
2020-07-31 17:38:03 +02:00
import {TagRenderingOptions} from "../TagRenderingOptions";
2020-06-24 00:35:19 +02:00
export class Bookcases extends LayerDefinition {
constructor() {
2020-07-31 04:58:58 +02:00
super("bookcases");
2020-06-24 00:35:19 +02:00
this.name = "boekenkast";
this.presets = [{
tags: [new Tag("amenity", "public_bookcase")],
description: "Add a new bookcase here",
title: Translations.t.bookcases.bookcase,
}];
2020-06-24 00:35:19 +02:00
this.icon = "./assets/bookcase.svg";
2020-07-08 16:07:16 +02:00
this.overpassFilter = new Tag("amenity", "public_bookcase");
2020-07-08 17:09:12 +02:00
this.minzoom = 11;
2020-06-24 00:35:19 +02:00
2020-07-27 01:19:38 +02:00
const Tr = Translations.t;
const Trq = Tr.bookcases.questions;
this.title = new NameInline(Translations.t.bookcases.bookcase);
2020-07-08 16:07:16 +02:00
this.elementsToShow = [
2020-07-20 09:57:19 +02:00
new ImageCarouselWithUploadConstructor(),
2020-07-08 17:09:12 +02:00
new TagRenderingOptions({
2020-07-27 01:19:38 +02:00
question: Trq.hasName,
2020-07-08 17:09:12 +02:00
freeform: {
key: "name",
2020-07-27 01:19:38 +02:00
template: "$$$",
2020-07-08 17:09:12 +02:00
renderTemplate: "", // We don't actually render it, only ask
placeholder: "",
2020-07-27 01:19:38 +02:00
extraTags: new Tag("noname", "")
2020-07-08 17:09:12 +02:00
},
mappings: [
2020-07-27 01:19:38 +02:00
{k: new Tag("noname", "yes"), txt: Trq.noname},
2020-07-08 17:09:12 +02:00
]
}),
2020-07-08 16:07:16 +02:00
new TagRenderingOptions(
{
2020-07-27 01:19:38 +02:00
question: Trq.capacity,
2020-07-08 16:07:16 +02:00
freeform: {
2020-07-27 01:19:38 +02:00
renderTemplate: Trq.capacityRender,
template: Trq.capacityInput,
2020-07-08 16:07:16 +02:00
key: "capacity",
placeholder: "aantal"
},
}
2020-07-08 17:09:12 +02:00
),
new TagRenderingOptions({
2020-07-27 01:19:38 +02:00
question: Trq.bookkinds,
2020-07-12 23:19:05 +02:00
mappings: [
{k: new Tag("books", "children"), txt: "Voornamelijk kinderboeken"},
{k: new Tag("books", "adults"), txt: "Voornamelijk boeken voor volwassenen"},
{k: new Tag("books", "children;adults"), txt: "Zowel kinderboeken als boeken voor volwassenen"}
2020-07-08 17:09:12 +02:00
],
}),
2020-07-12 23:19:05 +02:00
new TagRenderingOptions({
question: "Staat dit boekenruilkastje binnen of buiten?",
mappings: [
{k: new Tag("indoor", "yes"), txt: "Dit boekenruilkastje staat binnen"},
{k: new Tag("indoor", "no"), txt: "Dit boekenruilkastje staat buiten"},
{k: new Tag("indoor", ""), txt: "Dit boekenruilkastje staat buiten"}
]
}),
new TagRenderingOptions({
question: "Is dit boekenruilkastje vrij toegankelijk?",
mappings: [
{k: new Tag("access", "yes"), txt: "Ja, vrij toegankelijk"},
{k: new Tag("access", "customers"), txt: "Enkel voor klanten"},
]
}).OnlyShowIf(new Tag("indoor", "yes")),
2020-07-13 14:14:00 +02:00
2020-07-12 23:19:05 +02:00
new TagRenderingOptions({
question: "Wie (welke organisatie) beheert dit boekenruilkastje?",
freeform: {
2020-07-23 12:03:44 +02:00
key: "operator",
2020-07-12 23:19:05 +02:00
renderTemplate: "Dit boekenruilkastje wordt beheerd door {operator}",
template: "Dit boekenruilkastje wordt beheerd door $$$"
}
}),
new TagRenderingOptions({
question: "Zijn er openingsuren voor dit boekenruilkastje?",
mappings: [
{k: new Tag("opening_hours", "24/7"), txt: "Dag en nacht toegankelijk"},
{k: new Tag("opening_hours", ""), txt: "Dag en nacht toegankelijk"},
{k: new Tag("opening_hours", "sunrise-sunset"), txt: "Van zonsopgang tot zonsondergang"},
],
freeform: {
key: "opening_hours",
renderTemplate: "De openingsuren zijn {opening_hours}",
template: "De openingsuren zijn $$$"
}
}),
new TagRenderingOptions({
question: "Is dit boekenruilkastje deel van een netwerk?",
freeform: {
key: "brand",
renderTemplate: "Deel van het netwerk {brand}",
template: "Deel van het netwerk $$$"
},
mappings: [{
k: new And([new Tag("brand", "Little Free Library"), new Tag("nobrand", "")]),
txt: "Little Free Library"
},
{
k: new And([new Tag("brand", ""), new Tag("nobrand", "yes")]),
txt: "Maakt geen deel uit van een groter netwerk"
}]
2020-07-13 15:09:29 +02:00
}).OnlyShowIf(new Or([
new Tag("ref", ""),
new And([new Tag("ref","*"), new Tag("brand","")])
])),
2020-07-12 23:19:05 +02:00
2020-07-08 17:09:12 +02:00
new TagRenderingOptions({
2020-07-13 15:09:29 +02:00
question: "Wat is het referentienummer van dit boekenruilkastje?",
2020-07-12 23:19:05 +02:00
freeform: {
key: "ref",
2020-07-13 15:09:29 +02:00
template: "Het referentienummer is $$$",
2020-07-13 14:14:00 +02:00
renderTemplate: "Gekend als {brand} <b>{ref}</b>"
},
mappings: [
2020-07-23 12:03:44 +02:00
{k: new And([new Tag("brand",""), new Tag("nobrand","yes"), new Tag("ref", "")]),
txt: "Maakt geen deel uit van een netwerk"}
]
2020-07-13 15:09:29 +02:00
}).OnlyShowIf(new Tag("brand","*")),
2020-07-12 23:19:05 +02:00
new TagRenderingOptions({
question: "Wanneer werd dit boekenruilkastje geinstalleerd?",
priority: -1,
freeform: {
2020-07-08 17:09:12 +02:00
key: "start_date",
renderTemplate: "Geplaatst op {start_date}",
template: "Geplaatst op $$$"
}
}),
2020-07-12 23:19:05 +02:00
2020-07-08 17:09:12 +02:00
new TagRenderingOptions({
question: "Is er een website waar we er meer informatie is over dit boekenruilkastje?",
2020-07-12 23:19:05 +02:00
freeform: {
key: "website",
2020-07-08 17:09:12 +02:00
renderTemplate: "<a href='{website}' target='_blank'>Meer informatie over dit boekenruilkastje</a>",
2020-07-12 23:19:05 +02:00
template: "$$$",
placeholder: "website"
}
2020-07-08 17:09:12 +02:00
}),
2020-07-12 23:19:05 +02:00
new TagRenderingOptions({
freeform: {
key: "description",
renderTemplate: "<b>Beschrijving door de uitbater:</b><br>{description}",
2020-07-12 23:19:05 +02:00
template: "$$$",
}
})
2020-07-08 17:09:12 +02:00
2020-06-24 00:35:19 +02:00
2020-07-12 23:19:05 +02:00
];
2020-06-24 00:35:19 +02:00
this.style = function (tags) {
return {
icon: {
2020-06-24 00:35:19 +02:00
iconUrl: "assets/bookcase.svg",
iconSize: [40, 40],
2020-07-26 23:28:31 +02:00
iconAnchor: [20,20],
popupAnchor: [0, -15]
},
2020-07-05 18:59:47 +02:00
color: "#0000ff"
2020-06-24 00:35:19 +02:00
};
}
2020-07-08 17:09:12 +02:00
2020-06-24 00:35:19 +02:00
}
}