-
Notifications
You must be signed in to change notification settings - Fork 14
feat(#347): adds support for select with images - engine part #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
65c8b94
f6dce4c
418a894
cd4d2dc
7bc6605
bad1225
73b350b
c894e38
1c2d6b3
4682e07
c9eff33
2fdc371
a8e1497
81cbb8e
5fe4313
15f61d8
474ad19
959e5d
8000
0
dfa911c
45ec08a
21e4caa
8820c6f
6479027
725d34a
e4d676c
c7a2b76
5e5b467
4891b42
d011a8b
c5e0c02
9a6c13a
49762c4
457b16b
03b90fa
55e8130
b2cb130
ef32d5b
3a4e769
11fbc00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@getodk/xforms-engine': minor | ||
'@getodk/xpath': minor | ||
'@getodk/web-forms': patch | ||
'@getodk/scenario': patch | ||
'@getodk/common': patch | ||
--- | ||
|
||
Adds support for downloading image attachments referenced in a form's IText |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ const extractURLIdentifier = (remoteUrl: URL): string => { | |
return match?.[1] ?? ''; | ||
}; | ||
|
||
type LoadXFormXML = () => Promise<string>; | ||
type LoadXFormXML = () => Promise<Blob | string>; | ||
|
||
const xformURLLoader = (url: URL): LoadXFormXML => { | ||
return async () => { | ||
|
@@ -102,7 +102,7 @@ export class XFormResource<Type extends XFormResourceType> { | |
const service = new JRResourceService(); | ||
const parentPath = localPath.replace(/\/[^/]+$/, ''); | ||
|
||
service.activateFixtures(parentPath, ['file', 'file-csv']); | ||
service.activateFixtures(parentPath, ['file', 'file-csv', 'images']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used to load files (forms and attachments) from the common package on the Preview Page when running the project in the local environment. I'm unsure yet what it needs to load attachments on the Preview Page when deployed in central. |
||
|
||
return service; | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
10000
|
@@ -19,6 +19,8 @@ export interface SelectItem { | |
export type SelectValueOptions = readonly SelectItem[]; | ||
|
||
export interface SelectNodeState extends BaseValueNodeState<readonly string[]> { | ||
get isSelectWithImages(): boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will go away, and not changes in this file |
||
|
||
get children(): null; | ||
|
||
get valueOptions(): readonly SelectItem[]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { JRResourceURL } from '@getodk/common/jr-resources/JRResourceURL.ts'; | ||
import type { ActiveLanguage } from './FormLanguage.ts'; | ||
import type { RootNodeState } from './RootNode.ts'; | ||
|
||
/** | ||
* **COMMENTARY** | ||
|
@@ -156,4 +156,8 @@ export interface TextRange<Role extends TextRole, Origin extends TextOrigin = Te | |
|
||
get asString(): string; | ||
get formatted(): unknown; | ||
|
||
get imageSource(): JRResourceURL | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up with |
||
get audioSource(): JRResourceURL | undefined; | ||
get videoSource(): JRResourceURL | undefined; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ interface SelectControlStateSpec extends ValueNodeStateSpec<readonly string[]> { | |
readonly label: Accessor<TextRange<'label'> | null>; | ||
readonly hint: Accessor<TextRange<'hint'> | null>; | ||
readonly valueOptions: Accessor<SelectValueOptions>; | ||
readonly isSelectWithImages: Accessor<boolean>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All these changes might be reverted and handled in the front-end side |
||
} | ||
|
||
export class SelectControl | ||
|
@@ -109,6 +110,10 @@ export class SelectControl | |
|
||
const valueOptions = createItemCollection(this); | ||
|
||
const isSelectWithImages = this.scope.runTask(() => { | ||
return createMemo(() => valueOptions().some((item) => !!item.label.imageSource)); | ||
}); | ||
|
||
const mapOptionsByValue: Accessor<SelectItemMap> = this.scope.runTask(() => { | ||
return createMemo(() => { | ||
return new Map(valueOptions().map((item) => [item.value, item])); | ||
|
@@ -150,6 +155,7 @@ export class SelectControl | |
valueOptions, | ||
value: valueState, | ||
instanceValue: this.getInstanceValue, | ||
isSelectWithImages, | ||
}, | ||
this.instanceConfig | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import helper is used for the Preview Page and the scenario tests.