Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #967 from eyelidlessness/fix/draw-widget-load-inst…
Browse files Browse the repository at this point in the history
…ance-attachments

Fix: ensure instance attachments are loaded in draw widget
  • Loading branch information
eyelidlessness authored Mar 24, 2023
2 parents 90a1542 + 6f3877f commit beaac75
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [7.2.2] - 2023-03-23

- Fix: ensure instance attachments are loaded in draw widget (#967)

## [7.2.1] - 2023-03-21

- Fix: revert jQuery upgrade to address regressions accessing jQuery extensions in Enketo Express (#964)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "enketo-core",
"description": "Extensible Enketo form engine",
"homepage": "https://enketo.org",
"version": "7.2.1",
"version": "7.2.2",
"license": "Apache-2.0",
"os": [
"darwin",
Expand Down
18 changes: 14 additions & 4 deletions src/widget/draw/draw-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,28 @@ class DrawWidget extends Widget {
return '';
}

let fileOrURL = file;

if (typeof file === 'string') {
try {
fileOrURL = await fileManager.getFileUrl(file);
} catch {
// Ignore error, attempt to load
}
}

try {
if (
typeof file === 'string' &&
file.startsWith('jr://') &&
typeof fileOrURL === 'string' &&
fileOrURL.startsWith('jr://') &&
this.element.dataset.loadedUrl
) {
file = this.element.dataset.loadedUrl;
fileOrURL = this.element.dataset.loadedUrl;
}

this.pad.reset();

await this.pad.setBaseImage(file);
await this.pad.setBaseImage(fileOrURL);

return this.pad.toObjectURL();
} catch {
Expand Down

0 comments on commit beaac75

Please sign in to comment.