Skip to content

Commit

Permalink
doc: multi choice checkbox (#331)
Browse files Browse the repository at this point in the history
* doc: multi choice checkbox

* update of doc based of changes in PR

* add table for options

* added options attribute

* dropdown fix
  • Loading branch information
johnnyblasta authored Dec 16, 2024
1 parent f88d100 commit 146c223
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions content/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ type | format | required | readonly | maxLength | constraint | Description
`text` | string | supported | supported | supported || Text input
`textarea` | string | supported | supported | supported || Text input with resizable box
`dropdown` | string || supported || supported | Dropdown based on options values
`checkbox` | boolean or configured values || supported ||| Checkbox, defaults to not checked.
`checkbox` | boolean or configured values || supported ||| Checkbox, defaults not checked.
`checkboxgroup` | array with configured values || supported ||| A group of checkboxes where multiple choices can be selected and also freetext choices can be added, defaults to not checked.
`image` | base64 || supported ||| Uploads image
`color` | hexadecimal || supported ||| Activates a color-picker
`time` | hh:mm:ss | supported | supported ||| Defaults to current time. Use defaultTime:false to not.
Expand Down Expand Up @@ -890,6 +891,7 @@ Property | Description | Required | Default value
`valueQueryParameter`| When using `useBackingValue` in combination with `dynamic` the GET parameter name that is used for reverse lookup can be set using this parameter | No | "value"

**defaultValue object**

The defaultValue object controls how an attribute's default value is handled. Default values are always set when creating new features, and can optionally be set when updating attributes.
Default values can be overridden in the attribute editor unless attribute is configured as readonly or hidden.

Expand All @@ -901,8 +903,8 @@ Property | Description | Required | Default value
`timeStampFormat`| One of `time` = "HH:mm:ss", `date`= "yyyy-MM-dd", `datetime` = "yyyy-MM-dd HH:mm:ss", `timestamp` = "yyyy-MM-ddTHH:mm:ss | No | `timestamp`
`useUTC` | `true`if time should be in UTC, otherwise local time | No | `false`


**checkbox Config object**

An object that defines additional configuration for checkbox. The entire object is optional and all
properties are set to default if omitted.

Expand All @@ -911,6 +913,26 @@ Property | Description | Required | Default value
`uncheckedValue` | Value that corresponds to the unchecked state | No | 0 (false)
`checkedValue` | Value that corresponds to the checked state | No | 1 (true)

**checkboxgroup additional attributes**

Attribute option | Description | Note | Default value
---|---|---|---
`options` | An array of objects further explained in next section | This shares the name with `dropdown` but not the syntax. Required for type `checkboxgroup` | Defaults to `[]`.
`separator` | The separator to be used to differentiate the values. | This effects the way the value is saved so changes in config will need updating the data values correspondingly. | Defaults to `;`.
`freetextOptionPrefix` | The prefix text in the value to be uesd to differentiate that this is a freetext value. | This effects the way the value is saved so changes in config will need updating the data values correspondingly. | Defaults to `freetext_option:`.
`freetextOptionValueSeparator`| The sign used to differentiate the unique freetext option and it's value. | This effects the way the value is saved so changes in config will need updating the data values correspondingly. | Defaults to `=`.

**checkboxgroup options array syntax**

For the checkboxgroup attribute type an array can be supplied used to set up multiple choice type checkbox questions.
The array should at least contain one object with the key `text` and a string value.

Property | Description | Required | Default value
---|---|---|---
`text` | The text for the choice and will also be the value unless another is specified | Yes |
`value` | Optional the object can have the key `value` which holds an alternative value for the option. | No | Defaults to the `text` if not supplied.
`type` | By adding to the object the type `textbox`, a textbox is attached to the option, the text box is enabled only if the option is checked. This can be used as an "other"/"miscellaneous" free text option. | No |

#### Example editor attributes

```json
Expand All @@ -931,6 +953,17 @@ Property | Description | Required | Default value
"uncheckedValue": "false"
}
},
{
"name": "multiChoice",
"title": "Please select all that applies: ",
"type": "checkboxgroup",
"options": [
{ "text": "choice 1" },
{ "text": "choice 2", "value": 2 },
{ "text": "choice 3" },
{ "text": "choice other", "type": "textbox" }
]
},
{
"name": "category",
"title": "category: ",
Expand Down Expand Up @@ -1323,4 +1356,4 @@ WMS servers can usually serve getFeatureInfo requests with a text/html reply. So

It is advisable to check the default function in src/getfeatureinfo.js to see the form of what is to be returned depending on whether a `htmlSeparator` prop is provided.

Note that the `source` of the [WMS](#wms) layer must have the `type` prop with the `geoserver` value for the `text/html` value of the `infoFormat` property to have the proper effect.
Note that the `source` of the [WMS](#wms) layer must have the `type` prop with the `geoserver` value for the `text/html` value of the `infoFormat` property to have the proper effect.

0 comments on commit 146c223

Please sign in to comment.