enketo-core
enketo-core copied to clipboard
add method to obtain compact state of model
here is a start: https://github.com/alxndrsn/xform-conmpact-record-representation-for-sms.js
Considering how little code is required, let's add such a method to Enketo Core, for apps to use.
- adding methods for delimiter,
- avoiding jQuery
How do you think this would best fit? As an option on form.getDataStr()
? e.g. form.getDataStr({ compact:true })
Any thoughts on how to parse XML without using jquery? jquery.parseXML(modelStr)
(which I know is still jquery) has issues with undefined XML namespaces, which using jquery(modelStr)
does not.
adding methods for delimiter
Does this mean allowing the delimiter to be set when calling form.getDataStrCompact()
?
@MartijnR I'm also interested in your opinion of this:
https://github.com/alxndrsn/xform-conmpact-record-representation-for-sms.js/blob/master/test/index.spec.js#L44-L46
It will complicate code a bit to include fields which don't have a value set. For medic's uses, I don't think it's an essential feature, although deviating from the spec may not be desirable for enketo.
As an option on form.getDataStr()? e.g. form.getDataStr({ compact:true })
Yes, that sounds great!
parse XML
We're using this: https://github.com/enketo/enketo-core/blob/master/src/js/Form-model.js#L120
allowing the delimiter to be set
I meant just to extract it from the model like these (also for prefix
): https://github.com/enketo/enketo-core/blob/master/src/js/Form-model.js#L62-L91, just for consistency.
although deviating from the spec may not be desirable for enketo
Yes, we should follow the spec. It might be worth starting a conversation on changing the spec though. Maybe this is to make a distinction between a user changing a default value to "" vs. not answering?
Yes, we should follow the spec. It might be worth starting a conversation on changing the spec though. Maybe this is to make a distinction between a user changing a default value to "" vs. not answering?
I think this actually relates to non-relevant fields - in the first compact example in the spec, <firstname>
is not included in the full response, but fn||
is included in the compact representation. Although perhaps this is actually a mistake in the spec, and an empty <firstname></firstname>
element should be included in the first example?
yes totally, right!
Spec changed or in the process of being changed pending comments from you! https://github.com/opendatakit/xforms-spec/pull/215