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

Linking between forms #404

Closed MartijnR closed 6 years ago

MartijnR commented 8 years ago

Just putting down some thoughts on this possible future feature:

[link](${calc_href})

When you refer to a ${calc_href} in a label or hint, it gets turned into an XForm <output>. In Enketo a markdown [link](href) gets turned into an <a href="href">link</a> element when the form is loaded. What we're trying to set dynamically is the href attribute. You'd get something like this syntax in Enketo:

<a href="<span class=\"or-output\" data-value=\"/path/to/node\"></span>">link</a>

An attribute cannot be a element, so this approach won't work. It will probably work for the link text but not for the link address itself.

The idea is, however, the way forward to properly enable linking between forms. I think we'd require this:

  1. enable dynamic hrefs without XForm outputs. This dynamism could be triggered when the content between the brackets is an <output> element, Enketo would have to process the link differently to make it dynamic, generating something like this: <a href="#" #data-href="/path/to/dynamic/node">link</a>
  2. (ideally an) easy way to refer to an Enketo form without knowing the Enketo URL, probably just by using the formID, e.g. a new XPath function: get-form('widgets') (This might not be easy - we'd be sending a GET API request without authentication. Moreover, it wouldn't work offline).
  3. pass data in the link as (somehow) described in the XForm by the form designer, e.g. get-form('widgets', ${a}, ${b}, ${c}) and relying on the same nodeNames to be present in the linked form, or use a map to map values to a different nodename. This may not be feasible for offline-capable forms until we switch from applicationCache to service workers #401, #386.
MartijnR commented 8 years ago

Is this actually useful enough? Wouldn't it be more useful to redirect upon submission? enketo/enketo-express#476

Especially if the redirect can be dynamic.

To work offline, this would probably require a specially single-submission offline view.

enketo-issue-mover commented 6 years ago

This issue was moved to enketo/enketo#1228