enketo-core
enketo-core copied to clipboard
Readonly status can be lifted when ancestor group becomes relevant
http://localhost:8005/?xform=Read.Only.xml
Looks like I took a wrong turn at some point. The disable
function in a modern widget is used to make a widget readonly, which done when:
- during widget initialization when a question has a
<bind>
withreadonly="true()"
- a question or its ancestor becomes irrelevant
The reason for 2, is to cater to views that show irrelevant questions, and to provide some extra security for users that hack around in the dev console. That seems correct to me.
The enable
function is supposed to be the opposite of disable
and is called when:
- the question becomes relevant (directly or via ancestor)
This is where the flaw is.
Some widgets do not have the flaw as they include the wrapper if (!this.props.readonly){}
in the enable function. We could do that in all widgets. However, soon readonly will not be a static condition anymore https://github.com/enketo/enketo-core/issues/391, so it may be worth thinking about that already when resolving this issue.
I think this is the way forward: https://github.com/enketo/enketo-core/issues/391#issuecomment-478742942,
so for now:
- [ ] remove all
if(!this.props.readonly)
wrappers from widgets - [ ] add readonly check to widgets controller whenever
enable
is called