Skip to content

Conversation

bluepython508
Copy link

Much like #429, this adds support for nesting repeating_subfields.

This only exists because #429 doesn't apply cleanly anymore.

I'm aware of two limitations, both apparently imposed by CKAN's handling of nested schemas:

  • A field with repeating subfields being the only subfield of a field crashes, due to this check.
    This seems like it should be a relatively rare case.

  • Validators aren't applied to an empty leaf dictionary.
    I've worked around that in the validators test case, by adding a field there.
    This generally shouldn't be a problem when updating with a form, but I'm not sure how it would work with an API update.

This also fixes an issue, tested in the first commit, where deleting an instance of a repeating_subfields field would either reorder or remove entries of lexically later repeating_subfields fields.

Closes #429

If a dataset has two `repeating_subfields` fields such that the earlier
has at least two entries, removing an entry that isn't the last breaks
the later field.

In this instance, `contact_address` is simply absent from the dataset.
In others, it could reorder the subfields.

This is because in `expand_form_composite`, the indexes dictionary
isn't scoped to the field, so here `indexes['1'] = 0` due to the deletion,
then `indexes['0'] = 1` for `contact_address`, but 1 is out of range
for the `contact_address` list.
- JS Module: include field name in many names to avoid touching inner fields
- Template: the other half of the above
- `_expand`: recurse correctly on subfields
- `expand_form_composite`: rewrite to handle nested subfields.
  This also fixes the issue mentioned in the previous commit, that indexes
  are not scoped to the field.

Also adds a test (`test_dashed_field_name_create`) testing fields
similar to those in `ckanext-fluent`, as those broke in development.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant