You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
3.1 KiB

  1. Each category can define a list of filters. This is an additional JSON value with the key "filter", e.g.:
  2. ```json
  3. {
  4. "query": {
  5. "13": "nwr[amenity]"
  6. },
  7. "filter": {
  8. "type": {
  9. "name": "{{ keyTrans('amenity') }}",
  10. "type": "select",
  11. "values": {
  12. "bar": {
  13. "nwr[
  14. },
  15. }
  16. }
  17. }
  18. ```
  19. This defines a filter with the ID 'type' and the translated name of the key 'amenity'. It's of type 'select' and has several possible values.
  20. Each filter can define the following values:
  21. * name: Name of the filter. String, which can make use of twig functions, e.g. `keyTrans` as in the above example.
  22. * type: A form type, e.g. 'text', 'select', 'radio', 'checkbox'
  23. * values: Possible values. Can either be an array, an object or a html string with several `<option>` tags (even for radio and checkbox). See below for more information.
  24. * valueName: if the values do not have names (resp. an `<option>` without text content), use this twig template to create a each name. Use `{{ value }}` for the current value.
  25. * query: A twig template which builds a query from the selected value (if the value has not a query defined), e.g. `nwr[amenity={{ value }}]`. If not defined the query will be built from `key` (or the filter ID), `op` and the selected value.
  26. * key: If not overridden by query, use this key for searching. If not defined, use the filter's ID. Can also be an array with a list of keys. You can use wildcards too, e.g. "name:*" to query all localized name tags.
  27. * op: operator to use (if not overridden by query):
  28. * '=' exact match (default)
  29. * '!=' any value but this
  30. * '~' regular expression, case sensitive
  31. * '~i' regular expression, case insensitive
  32. * '!~', '!~i' regular expression, negated
  33. * 'has' query in semicolon-separated lists like `cuisine=kebap;noodles`
  34. * 'has_key_value' query object with a tag with this key
  35. * 'strsearch' query string parts (e.g. "kai keb" would match "Kaiser Kebap") and query character variants (e.g. "cafe" would match "café").
  36. * show_default: if true, this filter will be shown by default, others need to be added via the select box.
  37. * placeholder: a text which is shown as placeholder (Twig enabled)
  38. * emptyQuery: A Overpass filter query which is added, when no value is selected.
  39. ### Values
  40. #### Array
  41. Values can either be an array, e.g.
  42. ```json
  43. [ "bar", "restaurant", ... ]
  44. ```
  45. #### Object
  46. Values can be an object, e.g.
  47. ```json
  48. { "bar":
  49. {
  50. "name": "Bar",
  51. "query": "nwr[amenity=bar]"
  52. }
  53. }
  54. ```
  55. * Name is optional and can be created via `valueName`.
  56. * Query is optional, it can be created from key (or filter id), op and the value.
  57. #### Twig template
  58. Values can be a twig template (string). It has access to the `const` part of the category. It can create a list of options:
  59. ```html
  60. {% for k in const %}
  61. <option value="{{ k }}"></option>
  62. {% endfor %}
  63. <option value="restaurant" query="nwr[amenity=restaurant]">Restaurant</option>
  64. ```
  65. * Name is generated from text content. If it is empty, it can be created via `valueName`.
  66. * Query is optional, it can be created from key (or filter id), op and the value.