Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itemset from previous answers - select one from ${node} #38

Closed
MartijnR opened this issue Jun 18, 2015 · 7 comments · Fixed by #472
Closed

Itemset from previous answers - select one from ${node} #38

MartijnR opened this issue Jun 18, 2015 · 7 comments · Fixed by #472
Assignees

Comments

@MartijnR
Copy link
Contributor

Triggered by this question

It exposes the so-far-untapped XForm capability to create a choice list from previous answers (in a repeat).

It could have a wider implication by avoiding the more difficult indexed-repeat() or a combination of concat() and selected-at().

After discussion with @dorey we came up with the following initial syntax suggestion:

type name label choice_filter
begin repeat rep
text name Enter name
end repeat
select one from ${name} choice Choose string-length(./name) > 0
<select1 ref="/data/choice">
   <label>Choose name</label>
   <itemset nodeset="/data/rep[string-length(./name) > 0]">
       <label ref="name"/>
       <value ref="name"/>
   </itemset>
</select1>

The ref attribute is the nodename of ${name} and the nodeset attribute is the parent of ${name} with an optional choice filter.

@MartijnR MartijnR changed the title Itemset from previous answers Itemset from previous answers - select one from ${node} Jun 18, 2015
@MartijnR
Copy link
Contributor Author

select multiple support might be difficult because we cannot allow spaces in the answers...

@dorey
Copy link
Contributor

dorey commented Jun 18, 2015

I like the idea of adding the ability to reference previous repeats. After thinking about the syntax a little more, I'm wondering if we could come up with a better way to specify it in the xlsform. Main reasons--

  • select one from ${name} could require new regex changes for parsing the type field. Even if we went with select_one ${name} there's a high probability that parsers in pyxform and various xlsform form-builders and parsers () would need their regex fixed. And though we could do it on individual cases, it'd be cleaner if we could settle on a way of extending functionality that doesn't involve changing the regex.
  • I vaguely remember people wanting to move away from { "type": "select_one listname" } towards something like { "type": "select_one", "list_name": "listname" }. Which would make parsing and validation of the form easier and more precise. (Note: I may have imagined this conversation)

How about:

type
select_one ${prev_name}

* still might need regex changes

or

type list name
select_one ${prev_name}

@MartijnR
Copy link
Contributor Author

I can see that would make sense from a developer perspective. Maybe move that discussion to a different issue, since it relates to all select type questions?

@ukanga
Copy link
Contributor

ukanga commented Oct 2, 2019

I took the approach of using select one ${prev_name} in #381, it seemed the easiest way to implement without adding any additional syntax other than a reference to a previous field.

Any thoughts on the implementation?

@MartijnR
Copy link
Contributor Author

MartijnR commented Oct 2, 2019

Just happy thoughts about the feature from me and that test looks good.

@lognaturel
Copy link
Contributor

@MartijnR you may want to check out @DavisRayM's progress at #472 and some of my comments to see whether you agree. I now see that in your initial example you weren't using ${} syntax in the choice_filter. Was that intentional? I initially thought it would be easier to let users use ${} but maybe it's reasonable to explain that fields within the target repeat are written as ./<field name>.

@MartijnR
Copy link
Contributor Author

MartijnR commented Sep 24, 2020

Thanks! I will do that. I believe that not using ${} syntax in the choice_filter was not intentional or maybe it was because pyxform wasn't producing relative paths at that time. Seems better to use the ${}syntax in examples (and support it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants