mapcomplete/Docs/SpecialInputElements.md

234 lines
3.6 KiB
Markdown
Raw Normal View History

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)
+ [decimal](#decimal)
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
2022-02-14 23:23:34 +01:00
A longer piece of text
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
2022-02-14 23:23:34 +01:00
A positive number or zero
2022-02-14 23:23:34 +01:00
### int
A number
2021-11-30 22:50:48 +01:00
2022-02-14 23:23:34 +01:00
### decimal
2022-02-14 04:59:49 +01:00
A geographical length 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 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[] }`.
subarg | doc
-------- | -----
removePrefixes | remove these snippets of text from the start of the passed string to search
removePostfixes | remove these snippets of text from the end of the passed string to search
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
```
"freeform": {
2021-10-29 13:35:33 +02:00
"key": "name:etymology:wikidata",
"type": "wikidata",
"helperArgs": [
"name",
{
"removePostfixes": [
"street",
"boulevard",
"path",
"square",
"plaza",
]
}
]
}
```
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
2022-02-14 04:59:49 +01:00
### pfloat
2021-05-11 10:14:33 +02:00
2022-02-14 23:23:34 +01:00
A positive decimal (inclusive 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
### 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 }`.
subarg | doc
-------- | -----
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
2022-02-15 00:11:11 +01:00
This document is autogenerated from [UI/Input/ValidatedTextField.ts](https://github.com/pietervdvn/MapComplete/blob/develop/UI/Input/ValidatedTextField.ts)