uiconfiguration.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. .. _community_metadata_uiconfiguration:
  2. Fields configuration
  3. ====================
  4. The ui for the metadata tab is made from a list of field components.
  5. The type of the field component and how they behave can be configured in the yaml file.
  6. All fields should be configured as a list which has the parent key ``attributes``.
  7. .. contents:: :local:
  8. :depth: 1
  9. Field options
  10. -------------
  11. A field is defined in the yaml following key-value pairs:
  12. - `key`_
  13. - `fieldType`_
  14. - `label`_
  15. - `occurrence`_
  16. - `condition`_
  17. - `tab`_
  18. - `values <#values>`_ (specific field types)
  19. - `derivedFrom`_ (specific field types)
  20. - `typename`_ (specific field types)
  21. key
  22. ^^^
  23. The key is the identifier for the field and should therefore be unique.
  24. Other configurations can refer the field by using this identifier. E.g the geonetwork mapping, internationalization.
  25. ================ ======== ============================
  26. Key Required Value
  27. ================ ======== ============================
  28. key yes a unique string
  29. ================ ======== ============================
  30. fieldType
  31. ^^^^^^^^^
  32. Chooses the type of input widget for the field.
  33. A detailed description for each type can be found in the `Field Types`_ section.
  34. ================ ======== ============================
  35. Key Required Value
  36. ================ ======== ============================
  37. fieldType yes - COMPLEX
  38. - TEXT
  39. - NUMBER
  40. - TEXT_AREA
  41. - DATE
  42. - DATETIME
  43. - BOOLEAN
  44. - UUID
  45. - DROPDOWN
  46. - SUGGESTBOX
  47. - REQUIREBOX
  48. - DERIVED
  49. ================ ======== ============================
  50. label
  51. ^^^^^
  52. If present this value will be used as the label for the field.
  53. When the label is not present in the yaml configuration the key will be used as label.
  54. Note: when the key is present in the internationalization (i18n) file see `Internationalization support`_ than the value from that file will be used as the label.
  55. ================ ======== ============================
  56. Key Required Value
  57. ================ ======== ============================
  58. label no any string
  59. ================ ======== ============================
  60. occurrence
  61. ^^^^^^^^^^
  62. The value for ``occurrence`` determines whether or not the field should displayed as a table or as a single input field.
  63. ``SINGLE`` will result in one input field.
  64. .. figure:: images/single-value.png
  65. e.g. single value input field of fieldType ``TEXT``.
  66. Choosing ``REPEAT`` will render the field in a table allowing the user to input multiple values.
  67. .. figure:: images/repeat.png
  68. e.g. field of fieldType ``TEXT`` rendered as a table.
  69. The data in table can be sorted using the green arrow buttons.
  70. ================ ======== ============================
  71. Key Required Value
  72. ================ ======== ============================
  73. occurrence no - SINGLE (Default)
  74. - REPEAT
  75. ================ ======== ============================
  76. condition
  77. ^^^^^^^^^
  78. Conditional attributes are attributes that are only visible for some layers. A typical example are attributes only present for raster or vector layers.
  79. The condition is specified in :ref:`CQL <cql_tutorial>` which is evaluated against the layer's :ref:`ResourceInfo <csw_features>` object.
  80. For example:
  81. .. code:: YAML
  82. condition: equalTo(typeOf("."), 'FeatureTypeInfo')
  83. tab
  84. ^^^
  85. Optionally, attributes may be displayed on separate tabs. All tabs must be listed under `tabs` in the main configuration. Then this
  86. property is used to assign each attribute to one or more tab (separated by comma),
  87. so that the custom metadata panel is divided in tabs:
  88. .. figure:: images/metadata-tabs.png
  89. values
  90. ^^^^^^
  91. The choices in a `DROPDOWN`_, `SUGGESTBOX`_ or `REQUIREBOX`_ can be set using the ``values`` attribute in the yaml.
  92. This is useful for small list, for larger list it can be better to list the choices in a separate .csv file.
  93. derivedFrom
  94. ^^^^^^^^^^^
  95. Only used in the `DERIVED`_ field. The attribute ``derivedFrom`` contains the key for the parent on which the `DERIVED`_ field depends.
  96. Follow the link for more information on the `DERIVED`_ field.
  97. typename
  98. ^^^^^^^^
  99. The ``typename`` is a required attribute for `COMPLEX`_ fields. It contains the key pointing to the definition of the `COMPLEX`_ field.
  100. A special ``typename`` `featureAttribute` is reserved for the `Feature Catalog Generation`_ and should not be used.
  101. Field Types
  102. -----------
  103. - `TEXT`_
  104. - `TEXT_AREA`_
  105. - `UUID`_
  106. - `NUMBER`_
  107. - `BOOLEAN`_
  108. - `DATE`_
  109. - `DATETIME`_
  110. - `DROPDOWN`_
  111. - `SUGGESTBOX`_
  112. - `REQUIREBOX`_
  113. - `DERIVED`_
  114. - `COMPLEX`_
  115. TEXT
  116. ^^^^
  117. Input field that allows any text.
  118. .. figure:: images/fieldtext.png
  119. .. code:: YAML
  120. attributes:
  121. - key: text-field
  122. fieldType: TEXT
  123. TEXT_AREA
  124. ^^^^^^^^^
  125. A multiline input.
  126. .. figure:: images/fieldtextarea.png
  127. .. code:: YAML
  128. attributes:
  129. - key: text-area-field
  130. fieldType: TEXT_AREA
  131. UUID
  132. ^^^^
  133. Input field for a UUID, it allows any text input or the user can generate a UUID.
  134. .. figure:: images/fielduuid.png
  135. .. code:: YAML
  136. attributes:
  137. - key: uuid-field
  138. fieldType: UUID
  139. NUMBER
  140. ^^^^^^
  141. Only numbers are accepted as valid input.
  142. .. figure:: images/fieldnumber.png
  143. .. code:: YAML
  144. attributes:
  145. - key: number-field
  146. fieldType: NUMBER
  147. BOOLEAN
  148. ^^^^^^^
  149. Input field with checkbox.
  150. .. figure:: images/fieldboolean.png
  151. .. code:: YAML
  152. attributes:
  153. - key: boolean-field
  154. fieldType: BOOLEAN
  155. DATE
  156. ^^^^
  157. Date selection without time information.
  158. .. figure:: images/fielddate.png
  159. .. code:: YAML
  160. attributes:
  161. - key: date-field
  162. fieldType: DATE
  163. DATETIME
  164. ^^^^^^^^
  165. Selection date with time information.
  166. .. figure:: images/fielddatetime.png
  167. .. code:: YAML
  168. attributes:
  169. - key: datetime-field
  170. fieldType: DATETIME
  171. DROPDOWN
  172. ^^^^^^^^
  173. A field for selecting a value from a dropdown.
  174. The values can be configured with the ``values`` attribute in the yaml or they can be configured in an other .csv file which is used for dropdowns with a lot of choices.
  175. .. figure:: images/fielddropdown.png
  176. Configuration in the yaml file.
  177. .. code:: YAML
  178. attributes:
  179. - key: dropdown-field
  180. fieldType: DROPDOWN
  181. values:
  182. - first
  183. - second
  184. - third
  185. To configure the values in a separate file add a yaml key ``csvImports`` on the same level as ``attributes`` and add the list of CSV files under this key.
  186. The first line in each CSV file should contain the key of the dropdown field for which you want to add the choices.
  187. ``metadata-ui.yaml``
  188. .. code:: YAML
  189. attributes:
  190. - key: dropdown-field
  191. fieldType: DROPDOWN
  192. csvImports:
  193. - dropdowncontent.csv
  194. ``dropdowncontent.csv``
  195. .. code::
  196. dropdown-field
  197. first
  198. second
  199. third
  200. SUGGESTBOX
  201. ^^^^^^^^^^
  202. A field for selecting a value from a suggestbox. Suggestions will be given for the values where the input matches the beginning of the possible values.
  203. The values can be put in a separate CSV file in the same way as for the DROPDOWN field.
  204. .. figure:: images/fieldsuggest.png
  205. .. code:: YAML
  206. attributes:
  207. - key: suggestbox-field
  208. fieldType: SUGGESTBOX
  209. values:
  210. - first
  211. - second
  212. - third
  213. REQUIREBOX
  214. ^^^^^^^^^^
  215. This type is identical to suggestbox, except that the user is not allowed to fill in a custom value but enforced to choose a suggested value.
  216. This can be handy when an field value must be an element from a list, but this list is too long for a dropdown to be practical.
  217. DERIVED
  218. ^^^^^^^
  219. A derived field is a hidden field whose value depends on an other field. The yaml key ``derivedFrom`` should contain the key of the field it depends on.
  220. When a value is selected in the parent field a matching value for the derived field is searched in csv file or the value with the same index is picked from the values list.
  221. The CSV file should have at least two columns and start with the key of the parent field in the first column followed by the values for the parent field, the other columns should contain the key(s) of the derived field(s) in the first row followed by the matching values.
  222. Example derived field with config in a CSV file:
  223. .. figure:: images/fielddireved.png
  224. ``metadata-ui.yaml``
  225. .. code:: YAML
  226. attributes:
  227. - key: derived-parent-field
  228. fieldType: DROPDOWN
  229. - key: hidden-field
  230. fieldType: DERIVED
  231. derivedFrom: derived-parent-field
  232. csvImports:
  233. - derived-mapping.csv
  234. ``derivedmapping.csv``
  235. .. code::
  236. derived-parent-field;hidden-field
  237. parent-value01;hidden-value01
  238. parent-value02;hidden-value02
  239. parent-value03;hidden-value03
  240. Example derived field with values lists:
  241. ``metadata-ui.yaml``
  242. .. code:: YAML
  243. attributes:
  244. - key: derived-parent-field
  245. fieldType: DROPDOWN
  246. values:
  247. - parent-value01
  248. - parent-value02
  249. - parent-value03
  250. - key: hidden-field
  251. fieldType: DERIVED
  252. derivedFrom: derived-parent-field
  253. values:
  254. - hidden-value01
  255. - hidden-value02
  256. - hidden-value03
  257. COMPLEX
  258. ^^^^^^^
  259. A complex field is composed of multiple other fields. The yaml key ``typename`` is added to the field configuration.
  260. On the root level the yaml key ``types`` indicates the beginning of all complex type definition.
  261. A type definition should contain the ``typename`` followed by the key ``attributes`` which contains the configuration for the subfields.
  262. .. figure:: images/fieldcomplex.png
  263. .. code:: YAML
  264. attributes:
  265. - key: complex-type
  266. fieldType: COMPLEX
  267. typename: complex-field
  268. types:
  269. - typename: complex-field
  270. attributes:
  271. - key: object-text
  272. fieldType: TEXT
  273. - key: object-numer
  274. fieldType: NUMBER
  275. Feature Catalog Generation
  276. --------------------------
  277. To create a feature catalog for a vector layer, a complex structure is needed to describe all the attributes. A lot of this information is already present in the GeoServer feature type or the database.
  278. Metadata supports automatically generating a new structure in the metadata from the information at hands that can be customised afterwards.
  279. To create support for this feature in your configuration, define a repeatable COMPLEX_ field with built-in ``fieldType`` `featureAttribute` .
  280. In the example the featureCatalog object has two attributes. A unique identifier of the type UUID_ and the feature attribute field.
  281. .. figure:: images/fa01.png
  282. e.g. Empty Feature attribute field
  283. .. code:: YAML
  284. - typename: featureCatalog
  285. attributes:
  286. - label: Unique identifier
  287. key: feature-catalog-identifier
  288. fieldType: UUID
  289. - label: Feature attribute
  290. key: feature-attribute
  291. fieldType: COMPLEX
  292. typename: featureAttribute
  293. occurrence: REPEAT
  294. The ``Generate`` action will check the database metadata for that layer and generate a feature attribute for each column in the table.
  295. .. figure:: images/fa02.png
  296. e.g. Feature attribute with generate feature types
  297. Whitin each feature attribute there is another ``Generate`` action that will generate the domain.
  298. .. figure:: images/generate_domain.png
  299. e.g. Generate domain dialog
  300. There are two options to do this:
  301. - Using the existing data in the database for this attribute.
  302. - Using data from a look-up table in the same database. In this case you must specify the table, an attribute from which to take values and an attribute from which to take definitions.
  303. .. figure:: images/fa03.png
  304. e.g. Feature attribute with generate domain
  305. Internationalization support
  306. ----------------------------
  307. All metadata field labels that appear in the :guilabel:`Metadata fields` can be internationalized.
  308. This is performed by creating an internationalization (i18n) file named metadata.properties.
  309. Create an entry for each key in the gui configuration following this pattern: `PREFIX.attribute-key`
  310. e.g.
  311. ``metadata.properties``
  312. .. code::
  313. metadata.generated.form.metadata-identifier=Unique identifier for the metadata
  314. ``metadata_nl.properties``
  315. .. code::
  316. metadata.generated.form.metadata-identifier=Metadata identificator
  317. Drop-down labels can be translated too, in the same properties file, using the key ``metadata.generated.form.[attributeKey].[value]=[label]``.
  318. The value that will be internally stored for this field stays the same.
  319. .. _community_metadata_uiconfiguration_hidden_fields:
  320. Hidden Fields
  321. -------------
  322. Hidden fields are not visible in the GUI and do not need to be configured. They are updated automatically.
  323. - ``_timestamp``: date and time of the last metadata update.