Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/proud-parks-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@getodk/xforms-engine': minor
'@getodk/scenario': minor
'@getodk/web-forms': minor
---

Add support for setvalue action and odk-instance-first-load, odk-new-repeat, xforms-value-changed events
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,26 @@ This section is auto generated. Please update `feature-matrix.json` and then run
<summary>

<!-- prettier-ignore -->
##### Form Logic<br/>🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩⬜⬜⬜ 84\%
##### Form Logic<br/>🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩⬜⬜ 92\%

</summary>
<br/>

| Feature <img width=250px/> | Progress |
| -------------------------- | :------: |
| calculate | ✅ |
| relevant | ✅ |
| required | ✅ |
| required message | ✅ |
| custom constraint | ✅ |
| constraint message | ✅ |
| read only | ✅ |
| trigger | |
| choice filter | ✅ |
| default | ✅ |
| query parameter | |
| repeat_count | ✅ |
| create or update Entities | ✅ |
| Feature <img width=250px/> | Progress |
| ----------------------------------------------- | :------: |
| calculate | ✅ |
| relevant | ✅ |
| required | ✅ |
| required message | ✅ |
| custom constraint | ✅ |
| constraint message | ✅ |
| read only | ✅ |
| dynamic defaults (including trigger<br/>column) | |
| choice filter | ✅ |
| default | ✅ |
| query parameter | |
| repeat_count | ✅ |
| create or update Entities | ✅ |

</details>

Expand Down
2 changes: 1 addition & 1 deletion feature-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"custom constraint": "✅",
"constraint message": "✅",
"read only": "✅",
"trigger": "",
"dynamic defaults (including trigger column)": "",
"choice filter": "✅",
"default": "✅",
"query parameter": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

<my-value>5</my-value>
<my-calculated-value/>
<meta>
<instanceID/>
</meta>
</data>
</instance>

Expand Down
14 changes: 14 additions & 0 deletions packages/scenario/src/answer/AttributeNodeAnswer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { AttributeNode } from '../../../xforms-engine/dist/client/AttributeNode';
import { ComparableAnswer } from './ComparableAnswer.ts';

export class AttributeNodeAnswer extends ComparableAnswer {
readonly valueType = 'attribute';
readonly stringValue: string;
readonly value: string;

constructor(readonly node: AttributeNode) {
super();
this.stringValue = node.currentState.value;
this.value = node.currentState.value;
}
}
19 changes: 16 additions & 3 deletions packages/scenario/src/jr/Scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { constants as ENGINE_CONSTANTS } from '@getodk/xforms-engine';
import type { Accessor, Owner, Setter } from 'solid-js';
import { createMemo, createSignal } from 'solid-js';
import { afterEach, assert, expect } from 'vitest';
import { AttributeNodeAnswer } from '../answer/AttributeNodeAnswer.ts';
import { RankValuesAnswer } from '../answer/RankValuesAnswer.ts';
import { SelectValuesAnswer } from '../answer/SelectValuesAnswer.ts';
import type { ValueNodeAnswer } from '../answer/ValueNodeAnswer.ts';
Expand Down Expand Up @@ -180,11 +181,12 @@ export class Scenario {
this: This,
...args: ScenarioStaticInitParameters
): Promise<This['prototype']> {
let formMeta: ScenarioFormMeta;

if (isFormFileName(args[0])) {
return this.init(r(args[0]));
} else if (args.length === 1) {
}

let formMeta: ScenarioFormMeta;
if (args.length === 1) {
const [resource] = args;

formMeta = {
Expand Down Expand Up @@ -465,6 +467,17 @@ export class Scenario {
return answerOf(this.instanceRoot, reference);
}

attributeOf(reference: string, attributeName: string): AttributeNodeAnswer {
const node = this.getInstanceNode(reference);
const attribute = node.currentState.attributes.find((attr) => {
return attr.definition.qualifiedName.localName === attributeName;
});
if (attribute == null) {
throw new Error(`No attribute node for reference: ${reference}/@${attributeName}`);
}
return new AttributeNodeAnswer(attribute);
}

/**
* **PORTING NOTES**
*
Expand Down
Loading