kobotoolbox / enketo-express

We've moved! Please use the new repository 🠊 https://github.com/enketo/enketo-express
Apache License 2.0
102 stars 90 forks source link

Reset button for drawing/signature and upload not working #990

Closed MartijnR closed 6 years ago

MartijnR commented 6 years ago

This is for file upload/drawing item types. The reset button does not work for any of these, so it is not possible to clear the image/file/drawing. Note that the Undo button works for draw/annotate, but it is only undoing the lines, not the image upload for annotate.

Note that the reset button is not doing anything (there is no popup confirmation of the action like there was before).

MartijnR commented 6 years ago
MartijnR commented 6 years ago

in dialog.js, the gui object is empty. This affects all modal dialogs called from widgets (e.g. geo widgets too).

Could be an aliasify issue.

MartijnR commented 6 years ago

very mysterious. If I copy gui.js to gui.1.js and change require('./gui) to require('./gui.1') all is good again. This seems like some kind of interaction with another module with the same name.

MartijnR commented 6 years ago

You can trick the system into a correct build by calling require('../dialog') from e.g. the main-webform.js entry file.

MartijnR commented 6 years ago

Leaving this open. I was not able to find the actual cause of this JS build issue yet. I added a temporary workaround for now.

pbowen-oc commented 6 years ago

@MartijnR - The Reset Button is generally working now, but it is not considering whether the form is open in edit/review-only/read-only mode. We expect that the file should be able to be reset in edit mode, but not review-only or read-only mode. However, we are observing that the reset button is present and active in review-only and read-only mode. The button should be disabled in these modes or not visible at all. (Note that review-only mode is actually submitting the file removal back to us, but read-only is not submitting it.)

MartijnR commented 6 years ago

ah yes, of course. That was never implemented (including geo widgets).

pbowen-oc commented 6 years ago

@MartijnR - Ideally, the Reset button and Undo button would not be visible in review-only and read-only modes. The Download button should still be visible and functional in all modes.

MartijnR commented 6 years ago
MartijnR commented 6 years ago

working too fast. Reset no longer functional in drawings in note-only mode, but still visible. Properly hidden in file upload widgets.

MartijnR commented 6 years ago

fixed in 1.65.0.oc-2

MartijnR commented 6 years ago

reopening as this this needs a proper fix (without the temporary workaround)

MartijnR commented 6 years ago

I think this is because of the way gui.js self-initializes.

MartijnR commented 6 years ago

Finally figured it out. It's very subtle so here is the post-op for posterity:

TL/DR; it's a circular reference

  1. dialog.js (aliasified from enketo/dialog) requires gui.js
  2. gui.js requires ../core/print.js
  3. ../core/print.js requires dialog.js (aliasified from enketo/dialog)
  4. for some reason that results in the gui module in dialog.js becoming an empty object

Commenting out the require('../core/print') eliminates the issue.

The fix: