Skip to content

Commit

Permalink
Merge pull request #273 from getodk/features/value-nodes
Browse files Browse the repository at this point in the history
Support for `<select>` and `<select1>` value types, partial support for `<range>`
  • Loading branch information
eyelidlessness authored Jan 15, 2025
2 parents 4b31432 + a0c3da2 commit ca615e6
Show file tree
Hide file tree
Showing 81 changed files with 3,913 additions and 870 deletions.
10 changes: 10 additions & 0 deletions .changeset/curvy-owls-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@getodk/common": patch
"@getodk/scenario": patch
"@getodk/web-forms": minor
---

- Partial support for `<odk:range>` (basic horizontal and vertical sliders)
- Partial support for `<select1>` bind/value types (string, int, decimal)
- Partial support for `<select>` bind/value types (string, int, decimal)
- **BREAKING CHANGE** (`@getodk/xforms-engine`): `SelectNode`'s write methods have been replaced with more ergonomic alternatives
8 changes: 7 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ export default tseslint.config(
'prettier-vue/prettier': 'error',
'vue/html-indent': ['error', 'tab'],
'vue/html-comment-indent': ['error', 'tab'],
'vue/script-indent': ['error', 'tab'],
'vue/script-indent': [
'error',
'tab',
{
switchCase: 1,
},
],
// should be based on the printWidth
'vue/max-attributes-per-line': 'off',
'vue/no-undef-components': 'error',
Expand Down
44 changes: 44 additions & 0 deletions packages/common/src/fixtures/controls/range-controls.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:h="http://www.w3.org/1999/xhtml">

<h:head>
<h:title>Range controls</h:title>
<model>
<instance>
<root id="range-controls">
<range-decimal>1.0</range-decimal>
<range-int>2</range-int>

<vertical>
<v-decimal>1.25</v-decimal>
<v-int>1</v-int>
</vertical>
</root>
</instance>
<bind nodeset="/root/range-decimal" type="xsd:decimal" />
<bind nodeset="/root/range-int" type="int" />
<bind nodeset="/root/vertical/v-decimal" type="decimal" />
<bind nodeset="/root/vertical/v-int" type="xsd:int" />
</model>
</h:head>

<h:body>
<range ref="/root/range-decimal" start="-2.0" end="2.0" step="0.5">
<label>Range control (decimal)</label>
</range>
<range ref="/root/range-int" start="-6" end="4" step="2">
<label>Range control (int)</label>
</range>

<group ref="/root/vertical">
<range ref="/root/vertical/v-decimal" start="-5.0" end="7.0" step="0.5"
appearance="vertical">
<label>Range control (decimal)</label>
</range>
<range ref="/root/vertical/v-int" start="-3" end="4" step="3" appearance="vertical no-ticks">
<label>Range control (int)</label>
</range>
</group>
</h:body>

</h:html>
6 changes: 6 additions & 0 deletions packages/common/src/fixtures/notes/2-all-possible-notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<note_w_ex_appearance />
<read_only_int />
<read_only_int_value>3</read_only_int_value>
<note_calc_decimal_from_int />
</group>
<meta>
<instanceID />
Expand All @@ -34,6 +35,8 @@
<bind nodeset="/data/group/note_w_ex_appearance" readonly="true()" type="string" />
<bind nodeset="/data/group/read_only_int" type="int" readonly="true()" />
<bind nodeset="/data/group/read_only_int_value" type="int" readonly="true()" />
<bind nodeset="/data/group/note_calc_decimal_from_int" type="decimal"
calculate="/data/group/read_only_int_value + 1.5" readonly="true()" />
<bind nodeset="/data/meta/instanceID" type="string" readonly="true()" jr:preload="uid" />
</model>
</h:head>
Expand Down Expand Up @@ -70,6 +73,9 @@
<input ref="/data/group/read_only_int_value">
<label>A readonly integer with value</label>
</input>
<input ref="/data/group/note_calc_decimal_from_int">
<label>A note with decimal type calculated from int</label>
</input>
</group>
</h:body>
</h:html>
187 changes: 187 additions & 0 deletions packages/common/src/fixtures/select/5-select-types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms"
xmlns:orx="http://openrosa.org/xforms">
<h:head>
<h:title>Select types</h:title>
<model>
<instance>
<root id="select-types">
<select-relevance>yes</select-relevance>

<sel-1>
<string-value>explicit string</string-value>
<implicit-string-value>implicit string</implicit-string-value>
<int-value>123</int-value>
<decimal-value>45.67</decimal-value>
</sel-1>

<sel-n>
<string-value>explicit string</string-value>
<implicit-string-value>implicit string</implicit-string-value>
<int-value>123</int-value>
<decimal-value>45.67</decimal-value>
</sel-n>
</root>
</instance>
<instance id="strings">
<root>
<!-- for select1 -->
<item>
<value>implicit string</value>
<label>Implicit String</label>
</item>
<item>
<value>explicit string</value>
<label>Explicit String</label>
</item>
<item>
<value>updated string</value>
<label>Updated String</label>
</item>

<!-- for select (multiple) -->
<item>
<value>implicit</value>
<label>Implicit</label>
</item>
<item>
<value>explicit</value>
<label>Explicit</label>
</item>
<item>
<value>updated</value>
<label>Updated</label>
</item>
<item>
<value>string</value>
<label>string</label>
</item>
</root>
</instance>
<instance id="ints">
<root>
<item>
<value>123</value>
<label>123</label>
</item>
<item>
<value>10</value>
<label>10</label>
</item>
<item>
<value>23</value>
<label>23</label>
</item>
<item>
<value>89</value>
<label>89</label>
</item>
</root>
</instance>
<instance id="decimals">
<root>
<item>
<value>45.67</value>
<label>45.67</label>
</item>
<item>
<value>89</value>
<label>89</label>
</item>
<item>
<value>10</value>
<label>10</label>
</item>
<item>
<value>23.4</value>
<label>23.4</label>
</item>
</root>
</instance>
<bind nodeset="/root/sel-1/string-value" type="string"
relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-1/implicit-string-value" relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-1/int-value" type="int" relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-1/decimal-value" type="decimal"
relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-n/string-value" type="string"
relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-n/implicit-string-value" relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-n/int-value" type="int" relevant="/root/select-relevance = 'yes'" />
<bind nodeset="/root/sel-n/decimal-value" type="decimal"
relevant="/root/select-relevance = 'yes'" />
</model>
</h:head>
<h:body>
<select1 ref="/root/select-relevance">
<label>All selects relevant?</label>
<item>
<label>Yes</label>
<value>yes</value>
</item>
<item>
<label>No</label>
<value>no</value>
</item>
</select1>

<group ref="/root/sel-1">
<label>Select (1) with types</label>

<select1 ref="/root/sel-1/string-value">
<itemset nodeset="instance('strings')/root/item">
<value ref="value" />
<label ref="label" />
</itemset>
</select1>
<select1 ref="/root/sel-1/implicit-string-value">
<itemset nodeset="instance('strings')/root/item">
<value ref="value" />
<label ref="label" />
</itemset>
</select1>
<select1 ref="/root/sel-1/int-value">
<itemset nodeset="instance('ints')/root/item">
<value ref="value" />
<label ref="label" />
</itemset>
</select1>
<select1 ref="/root/sel-1/decimal-value">
<itemset nodeset="instance('decimals')/root/item">
<value ref="value" />
<label ref="label" />
</itemset>
</select1>
</group>

<group ref="/root/sel-n">
<label>Select (N) with types</label>

<select ref="/root/sel-n/string-value">
<itemset nodeset="instance('strings')/root/item[not(contains(value, ' '))]">
<value ref="value" />
<label ref="label" />
</itemset>
</select>
<select ref="/root/sel-n/implicit-string-value">
<itemset nodeset="instance('strings')/root/item[not(contains(value, ' '))]">
<value ref="value" />
<label ref="label" />
</itemset>
</select>
<select ref="/root/sel-n/int-value">
<itemset nodeset="instance('ints')/root/item">
<value ref="value" />
<label ref="label" />
</itemset>
</select>
<select ref="/root/sel-n/decimal-value">
<itemset nodeset="instance('decimals')/root/item">
<value ref="value" />
<label ref="label" />
</itemset>
</select>
</group>
</h:body>
</h:html>
Loading

0 comments on commit ca615e6

Please sign in to comment.