refactoring: move logic of lastclick into special layer, fix labels, fix anchoring

This commit is contained in:
Pieter Vander Vennet 2023-04-02 02:59:20 +02:00
parent 25a98af057
commit 52a0810ea9
47 changed files with 682 additions and 197 deletions

View file

@ -0,0 +1,116 @@
{
"id": "last_click",
"description": "This layer defines how to render the 'last click'-location. By default, it will show a marker with the possibility to add a new point (if there are some presets) and/or to add a new note (if the 'note' layer attribute is set). If none are possible, this layer won't show up",
"source": "special",
"name": null,
"titleIcons": [],
"title": {
"mappings": [
{
"if": {
"and": [
"has_note_layer=yes",
"has_presets=yes"
]
},
"then": {
"en": "Add a new point or add a note",
"nl": "Voeg een nieuw punt of een nieuwe kaartnota toe"
}
},
{
"if": "has_note_layer=yes",
"then": {
"en": "Add a new note",
"nl": "Voeg een nieuwe kaartnota toe"
}
},
{
"if": "has_presets=yes",
"then": {
"en": "Add a new point",
"nl": "Voeg een nieuw punt toe"
}
}
]
},
"tagRenderings": [
{
"id": "add_new",
"mappings": [
{
"if": "has_presets=yes",
"then": {
"*": "{add_new_point()}"
}
}
]
},
"all_tags"
],
"mapRendering": [
{
"icon": {
"mappings": [
{
"if": "number_of_presets=1",
"then": "{first_preset}"
}
],
"render": "<div class='relative'> <img src='./assets/svg/add_pin.svg' class='absolute' style='height: 50px'> <div class='absolute top-0 left-0 rounded-full overflow-hidden' style='width: 40px; height: 40px'><div class='flex slide min-w-min' style='animation: slide linear {number_of_presets}s infinite; width: calc( (1 + {number_of_presets}) * 40px ); height: 40px'>{renderings}{first_preset}</div></div></div>"
},
"labelCssClasses": "text-sm min-w-min pl-1 pr-1 bg-gray-400 rounded-3xl text-white opacity-65 whitespace-nowrap",
"label": {
"render": {
"ca": "Afegir nou element",
"cs": "Klikněte zde pro přidání nové položky",
"da": "Klik her for at tilføje et nyt punkt",
"de": "Hier klicken, um ein neues Element hinzuzufügen",
"en": "Click here to add a new item",
"es": "Haga clic aquí para añadir un nuevo ítem",
"fil": "I-click ito para mag-dagdag ng bagong bagay",
"fr": "Cliquez ici pour ajouter un élément",
"hu": "Új elem hozzáadásához kattints ide",
"id": "Klik di sini untuk menambahkan item baru",
"it": "Aggiungi nuovo elemento",
"nb_NO": "Legg til nytt element",
"nl": "Klik hier om een item toe te voegen",
"pt": "Adicionar novo item",
"zh_Hant": "點這邊新增新項目"
}
},
"iconBadges": [
{
"if": {
"or": [
"has_note_layer=yes",
"has_presets=yes"
]
},
"then": "<img class='animate-pulse' src='./assets/svg/addSmall.svg'>"
}
],
"location": [
"point"
],
"iconSize": "40,50,bottom"
}
],
"filter": [
{
"id": "action",
"options": [
{
"default": true,
"question": "only_if_action_is_possible",
"osmTags": {
"or": [
"has_note_layer=yes",
"has_presets=yes"
]
}
}
]
}
]
}

View file

@ -22,4 +22,4 @@
"cssClasses": "block relative rounded-full"
}
]
}
}

View file

@ -2,27 +2,39 @@
"id": "shared_questions",
"questions": {
"description": "Show the images block at this location",
"render": "{questions()}"
"render": {
"*": "{questions()}"
}
},
"images": {
"description": "This block shows the known images which are linked with the `image`-keys, but also via `mapillary` and `wikidata`",
"render": "{image_carousel()}{image_upload()}{nearby_images(expandable)}"
"render": {
"*": "{image_carousel()}{image_upload()}{nearby_images(expandable)}"
}
},
"mapillary": {
"description": "Shows a button to open Mapillary on this location",
"render": "{mapillary()}"
"render": {
"*": "{mapillary()}"
}
},
"export_as_gpx": {
"description": "Shows a button to export this feature as GPX. Especially useful for route relations",
"render": "{export_as_gpx()}"
"render": {
"*": "{export_as_gpx()}"
}
},
"export_as_geojson": {
"description": "Shows a button to export this feature as geojson. Especially useful for debugging or using this in other programs",
"render": "{export_as_geojson()}"
"render": {
"*": "{export_as_geojson()}"
}
},
"wikipedia": {
"description": "Shows a wikipedia box with the corresponding wikipedia article; the wikidata-item link can be changed by a contributor",
"render": "{wikipedia():max-height:25rem}",
"render": {
"*": "{wikipedia():max-height:25rem}"
},
"question": {
"en": "What is the corresponding Wikidata entity?",
"nl": "Welk Wikidata-item komt overeen met dit object?",
@ -106,11 +118,15 @@
},
"reviews": {
"description": "Shows the reviews module (including the possibility to leave a review)",
"render": "{reviews()}"
"render": {
"*": "{reviews()}"
}
},
"minimap": {
"description": "Shows a small map with the feature. Added by default to every popup",
"render": "{minimap(18, id): width:100%; height:8rem; border-radius:2rem; overflow: hidden; pointer-events: none;}"
"render": {
"*": "{minimap(18, id): width:100%; height:8rem; border-radius:2rem; overflow: hidden; pointer-events: none;}"
}
},
"phone": {
"question": {
@ -138,7 +154,9 @@
"da": "Hvad er telefonnummeret til {title()}?",
"cs": "Jaké je telefonní číslo {title()}?"
},
"render": "<a href='tel:{phone}'>{phone}</a>",
"render": {
"*": "<a href='tel:{phone}'>{phone}</a>"
},
"mappings": [
{
"if": "contact:phone~*",
@ -155,7 +173,9 @@
}
},
"osmlink": {
"render": "<a href='https://openstreetmap.org/{id}' target='_blank'><img src='./assets/svg/osm-logo-us.svg'/></a>",
"render": {
"*": "<a href='https://openstreetmap.org/{id}' target='_blank'><img src='./assets/svg/osm-logo-us.svg'/></a>"
},
"mappings": [
{
"if": "id~=-",
@ -164,7 +184,9 @@
]
},
"wikipedialink": {
"render": "<a href='https://wikipedia.org/wiki/{wikipedia}' target='_blank'><img src='./assets/wikipedia.svg' alt='WP'/></a>",
"render": {
"*": "<a href='https://wikipedia.org/wiki/{wikipedia}' target='_blank'><img src='./assets/wikipedia.svg' alt='WP'/></a>"
},
"question": {
"en": "What is the corresponding item on Wikipedia?",
"nl": "Welk Wikipedia-artikel beschrijft dit object?",
@ -217,7 +239,9 @@
}
},
"email": {
"render": "<a href='mailto:{email}' target='_blank'>{email}</a>",
"render": {
"*": "<a href='mailto:{email}' target='_blank'>{email}</a>"
},
"question": {
"nl": "Wat is het e-mailadres van {title()}?",
"fr": "Quelle est l'adresse courriel de {title()} ?",
@ -284,7 +308,9 @@
"da": "Hvad er webstedet for {title()}?",
"cs": "Jaká je webová stránka {title()}?"
},
"render": "<a href='{website}' rel='nofollow noopener noreferrer' target='_blank'>{website}</a>",
"render": {
"*": "<a href='{website}' rel='nofollow noopener noreferrer' target='_blank'>{website}</a>"
},
"freeform": {
"key": "website",
"type": "url",
@ -598,7 +624,9 @@
"da": "Er der stadig noget relevant, du ikke kunne give i de foregående spørgsmål? Tilføj det her.",
"cs": "Je ještě něco relevantního, co jste nemohli uvést v předchozích otázkách? Přidejte to sem."
},
"render": "{description}",
"render": {
"*": "{description}"
},
"freeform": {
"key": "description"
},
@ -1385,11 +1413,15 @@
"last_edit": {
"#": "Gives some metainfo about the last edit and who did edit it - rendering only",
"condition": "_last_edit:contributor~*",
"render": "<div class='subtle' style='font-size: small; margin-top: 2em; margin-bottom: 0.5em;'><a href='https://www.openStreetMap.org/changeset/{_last_edit:changeset}' target='_blank'>Last edited on {_last_edit:timestamp}</a> by <a href='https://www.openStreetMap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a></div>"
"render": {
"*": "<div class='subtle' style='font-size: small; margin-top: 2em; margin-bottom: 0.5em;'><a href='https://www.openStreetMap.org/changeset/{_last_edit:changeset}' target='_blank'>Last edited on {_last_edit:timestamp}</a> by <a href='https://www.openStreetMap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a></div>"
}
},
"all_tags": {
"description": "Shows a table with all the tags of the feature",
"render": "{all_tags()}"
"render": {
"*": "{all_tags()}"
}
},
"multilevels": {
"builtin": "level",
@ -1984,4 +2016,4 @@
"pl": "Nazwa sieci to <b>{internet_access:ssid}</b>"
}
}
}
}