mapcomplete/Docs/SpecialInputElements.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

259 lines
5 KiB
Markdown
Raw Normal View History

2023-02-12 23:08:57 +01:00
[//]: # (WARNING: this file is automatically generated. Please find the sources at the bottom and edit those sources)
2022-02-14 04:59:49 +01:00
Available types for text fields
2021-10-29 13:53:00 +02:00
=================================
2022-02-14 04:59:49 +01:00
## Table of contents
2021-10-29 13:53:00 +02:00
2021-11-30 22:50:48 +01:00
1. [Available types for text fields](#available-types-for-text-fields)
+ [string](#string)
+ [text](#text)
+ [date](#date)
2022-02-14 23:23:34 +01:00
+ [nat](#nat)
+ [int](#int)
2022-06-22 15:29:10 +02:00
+ [distance](#distance)
2021-11-30 22:50:48 +01:00
+ [direction](#direction)
+ [wikidata](#wikidata)
+ [pnat](#pnat)
+ [float](#float)
+ [pfloat](#pfloat)
+ [email](#email)
+ [url](#url)
+ [phone](#phone)
+ [opening_hours](#opening_hours)
+ [color](#color)
2021-05-11 10:14:33 +02:00
2022-02-14 04:59:49 +01:00
The listed types here trigger a special input element. Use them in `tagrendering.freeform.type` of your tagrendering to activate them
### string
2021-05-11 10:14:33 +02:00
2022-02-14 23:23:34 +01:00
A simple piece of text
2022-02-14 04:59:49 +01:00
### text
2021-07-24 02:42:37 +02:00
2023-02-10 01:49:06 +01:00
A longer piece of text. Uses an textArea instead of a textField
2022-02-14 04:59:49 +01:00
### date
2021-11-30 22:50:48 +01:00
2022-02-14 23:23:34 +01:00
A date with date picker
2022-02-14 04:59:49 +01:00
2022-02-14 23:23:34 +01:00
### nat
2022-02-14 04:59:49 +01:00
2021-11-30 22:50:48 +01:00
A whole, positive number or zero
2022-02-14 23:23:34 +01:00
2022-02-14 23:23:34 +01:00
### int
A whole number, either positive, negative or zero
2021-11-30 22:50:48 +01:00
2022-02-14 23:23:34 +01:00
2022-06-22 15:29:10 +02:00
### distance
2022-02-14 04:59:49 +01:00
2022-06-22 15:29:10 +02:00
A geographical distance in meters (rounded at two points). Will give an extra minimap with a measurement tool. Arguments: [ zoomlevel, preferredBackgroundMapType (comma separated) ], e.g. `["21", "map,photo"]
2022-02-14 04:59:49 +01:00
2022-02-14 23:23:34 +01:00
### direction
A geographical direction, in degrees. 0° is north, 90° is east, ... Will return a value between 0 (incl) and 360 (excl)
2022-02-14 04:59:49 +01:00
### wikidata
2021-07-24 02:42:37 +02:00
2022-02-14 04:59:49 +01:00
A wikidata identifier, e.g. Q42.
### Helper arguments
name | doc
------ | -----
key | the value of this tag will initialize search (default: name)
2022-02-14 04:59:49 +01:00
options | A JSON-object of type `{ removePrefixes: string[], removePostfixes: string[] }`.
2022-12-06 03:41:27 +01:00
subarg \| doc
-------- | -----
2023-03-08 19:17:03 +01:00
removePrefixes | remove these snippets of text from the start of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes
removePostfixes | remove these snippets of text from the end of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes.
instanceOf | A list of Q-identifier which indicates that the search results _must_ be an entity of this type, e.g. [`Q5`](https://www.wikidata.org/wiki/Q5) for humans
notInstanceof | A list of Q-identifiers which indicates that the search results _must not_ be an entity of this type, e.g. [`Q79007`](https://www.wikidata.org/wiki/Q79007) to filter away all streets from the search results
2022-02-14 04:59:49 +01:00
2021-11-08 02:36:01 +01:00
2022-02-14 04:59:49 +01:00
### Example usage
The following is the 'freeform'-part of a layer config which will trigger a search for the wikidata item corresponding with the name of the selected feature. It will also remove '-street', '-square', ... if found at the end of the name
2021-10-29 03:59:28 +02:00
```json
2021-10-29 03:59:28 +02:00
"freeform": {
2021-10-29 13:35:33 +02:00
"key": "name:etymology:wikidata",
"type": "wikidata",
"helperArgs": [
"name",
{
2022-06-24 03:52:54 +02:00
"removePostfixes": {"en": [
2021-10-29 13:35:33 +02:00
"street",
"boulevard",
"path",
"square",
"plaza",
],
2023-03-08 19:17:03 +01:00
"nl": ["straat","plein","pad","weg",laan"],
"fr":["route (de|de la|de l'| de le)"]
2022-06-24 03:52:54 +02:00
},
"#": "Remove streets and parks from the search results:"
"notInstanceOf": ["Q79007","Q22698"]
2021-10-29 13:35:33 +02:00
}
2021-10-29 13:35:33 +02:00
]
}
```
Another example is to search for species and trees:
```json
"freeform": {
"key": "species:wikidata",
"type": "wikidata",
"helperArgs": [
"species",
{
"instanceOf": [10884, 16521]
}]
}
```
2022-02-14 04:59:49 +01:00
### pnat
2021-05-11 10:14:33 +02:00
A strict positive number
2022-02-14 04:59:49 +01:00
### float
2021-05-11 10:14:33 +02:00
A decimal number
2022-02-14 04:59:49 +01:00
### pfloat
2021-05-11 10:14:33 +02:00
A positive decimal number or zero
2022-02-14 04:59:49 +01:00
### email
2021-11-30 22:50:48 +01:00
An email adress
2021-11-30 22:50:48 +01:00
2022-02-14 04:59:49 +01:00
### url
The validatedTextField will format URLs to always be valid and have a https://-header (even though the 'https'-part will be hidden from the user. Furthermore, some tracking parameters will be removed
2022-02-14 04:59:49 +01:00
### phone
2021-11-30 22:50:48 +01:00
A phone number
2021-11-30 22:50:48 +01:00
2022-02-14 04:59:49 +01:00
### opening_hours
Has extra elements to easily input when a POI is opened.
### Helper arguments
name | doc
------ | -----
2022-02-14 04:59:49 +01:00
options | A JSON-object of type `{ prefix: string, postfix: string }`.
2022-12-06 03:41:27 +01:00
subarg \| doc
-------- | -----
2023-03-08 19:17:03 +01:00
prefix | Piece of text that will always be added to the front of the generated opening hours. If the OSM-data does not start with this, it will fail to parse.
postfix | Piece of text that will always be added to the end of the generated opening hours
2022-02-14 04:59:49 +01:00
### Example usage
2022-02-14 04:59:49 +01:00
To add a conditional (based on time) access restriction:
```
2021-10-29 03:59:28 +02:00
2021-10-29 13:35:33 +02:00
"freeform": {
"key": "access:conditional",
"type": "opening_hours",
"helperArgs": [
{
"prefix":"no @ (",
"postfix":")"
}
]
}
```
2022-02-14 04:59:49 +01:00
*Don't forget to pass the prefix and postfix in the rendering as well*: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`
### color
2021-05-11 10:14:33 +02:00
2022-02-14 04:59:49 +01:00
Shows a color picker
2021-11-08 02:36:01 +01:00
This document is autogenerated from [UI/InputElement/Validators.ts](https://github.com/pietervdvn/MapComplete/blob/develop/UI/InputElement/Validators.ts)