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

AddressNL - overarching epic #4431

Open
1 of 7 tasks
sergei-maertens opened this issue Jun 24, 2024 · 3 comments
Open
1 of 7 tasks

AddressNL - overarching epic #4431

sergei-maertens opened this issue Jun 24, 2024 · 3 comments
Assignees
Milestone

Comments

@sergei-maertens
Copy link
Member

sergei-maertens commented Jun 24, 2024

  • 💄 addressNL should be able to hide label
  • 💄 addressNL label should not show "(not required)" - only the fields within the component -> discuss, the component as a whole is not required, and within that some fields are also optional.
  • addressNL street and city should not be disabled by default when "derive" is set, if BAG service is not working user should be able to fill this in themselves -> see Changing postcode does not trigger update of "DeriveStreetName" #2566, belongs to above item too
  • Styling of the <address> content - this is now the browser default which is italic and looks out of place -> I believe the Utrecht community components have something for this
@sergei-maertens sergei-maertens added triage Issue needs to be validated. Remove this label if the issue considered valid. enhancement labels Jun 24, 2024
@joeribekker joeribekker added meta and removed triage Issue needs to be validated. Remove this label if the issue considered valid. labels Jun 24, 2024
@joeribekker joeribekker added this to the Release 2.7.0 milestone Jun 24, 2024
stevenbal added a commit to open-formulieren/formio-builder that referenced this issue Jul 8, 2024
…omponent

the following components can now be validated using regex:
* postcode
* house number
* street name
* city
stevenbal added a commit to open-formulieren/formio-builder that referenced this issue Jul 8, 2024
the following components can now be validated using regex:
* postcode
* house number
* street name
* city
stevenbal added a commit to open-formulieren/formio-builder that referenced this issue Jul 8, 2024
the following components can now be validated using regex:
* postcode
* house number
* street name
* city
stevenbal added a commit to open-formulieren/formio-builder that referenced this issue Jul 8, 2024
the following components can now be validated using regex:
* postcode
* house number
* street name
* city
stevenbal added a commit to open-formulieren/formio-builder that referenced this issue Jul 8, 2024
the following components can now be validated using regex:
* postcode
* house number
* street name
* city
@sergei-maertens sergei-maertens mentioned this issue Jul 8, 2024
9 tasks
@joeribekker
Copy link
Contributor

@sergei-maertens can you let your mind go over this. I tried to incorporate all features.

The AddressNL-component features these fields:

A. postalcode, housenumber
B. houseletter, housenumber-addition
C. city, streetname

The letters are referenced in the text below.

Tasks

  • Add dropdown for "mode" in the component editor, allowing you to choose: Regular, Autofill, Prefill (see Mode-behaviour). This replaces the "adres afleiden" checkbox.
  • Autofill can ONLY be selected if the BAG API is configured. Give an error if its not or hide option completely.
  • Add an option to hide C-fields. By default, they are shown.
  • Add a Prefill-tab to the component editor, allowing you to select a plugin, attribute-set (see Prefill attribute-sets) and source

To discuss: Registration

  • Change the Registration-tab in the componenent editor, allowing to select an attribute-set (see Registration attribute-sets)

--OR--

  • Make sure all A, B and C-fields are shown as variables: <property name>.postalcode, <property name>.housenumber, ... etc.
  • Remove the registration tab, and connect them INDIVIDUALLY via the variables-tab

--OR --

  • Make sure the component is shown as variable
  • Optionally add all A, B and C-fields are shown as variables: <property name>.postalcode, <property name>.housenumber, ... etc.
  • Remove the registration tab, and connect them AS A SET via the variables

Prefill attribute-sets:

  • KvK: Bezoekadres, correspondentie adres
  • StUF-BG/HC BRP: Verblijfsadres
  • HC HR: Bezoeklocatie, postlocatie
  • Demo: Adres

Registration attribute-sets:

  • StUF-ZDS/ZGW-API's: Initiator verblijfsadres

Mode-behaviour

In regular mode:

  • Show A, B and C-fields as editable (C-fields only if enabled to show)

  • If BRK-validation is enabled: Trigger after A and B-fields are filled in.

In Autofill mode:

  • Show A and B-fields as editable fields

  • Show C-fields as read-only fields

  • When A-fields filled in, derive C-fields

  • If the C-fields cannot be derived (service offline, invalid address) make the C-fields editable

  • If the C-fields can be derived, make the C-fields read-only

  • If BRK-validation is enabled: Trigger after A and B-fields are filled in.

In Prefill mode:

  • Show A, B and C-fields as read-only

  • Prefill allows you to select a plugin and an attribute-set:

  • If prefill fails, make A, B and C-fields editable (C-fields only if enabled to show)

  • If BRK-validation is enabled: Trigger upon submit/next step

sergei-maertens added a commit that referenced this issue Nov 22, 2024
This way we don't need to add a data migration to update the options,
the old configuration (pre 3.0) will continue to work.
sergei-maertens added a commit that referenced this issue Nov 22, 2024
The code was already starting to look like a rather fine Italian pasta
before the addressNL mapping because of component-specific handling of
values that was necessary, but now with the additional configuration
options specific to the component type, readability and maintainability
was in serious danger.

I've opted to look at the broader structure on what information we
need, what information we have and what it is exactly that we need
to do with the information:

* We know all the variable values (keys and value), coming from user
  input, derived from user input or entirely independent from user
  input.
* When we know the key of a variable and we know the variable source is
  a form component, we can look up the definition of the form
  component and pass it along as additional context
* We know some user input (file uploads) is processed differently _in
  the context of the objects API_ and we have data storage that allows
  us to translate
* We need to normalize some values to make them suitable for use in the
  Objects API, because a JSON Schema contract is used. Looking at you,
  file uploads with multiple=false.
* We may have additional mapping configuration for a specific variable,
  typically because the variable points to a particular component type
  with special requirements (looking at you, addressNL)
* We must be able to construct the record data for the objects API. The
  keys to be used are specified in the mapped variables configuration,
  namely the target paths.
* We must process all the mapped variables to construct the entire
  object to send to the API.
* We can map all kinds of variables (form, user defined, static,
  registration).

So, working backwards, what we needed was for each mapped variable to
make it return instructions which paths of the final object need to
be set to which value. This is solved with AssignmentSpec data classes,
they simply encode the {key: value} information in a well-typed manner.

Next, a single mapping may result in multiple assignments being done
to different parts of the object - this is the newest requirement from
AddressNL type. We can express that as a sequence of AssignmentSpecs.

Finally, we collect all this information, bundle it up and hand it over
to glom which constructs our actual data object, from the mappings.

That leaves us with the requirement of a thing that produces
AssignmentSpec instructions given a mapping configuration and a value.
Because we already know that the value must be transformed depending
on its meaning (=which component produced it), we also pass the
resolved component configuration along for additional context.

For good measure and better code organization, the bulk of the
implementation is moved into handlers/v2.py. More code will be moved
around if this passes the initial reviews.
sergei-maertens added a commit that referenced this issue Nov 25, 2024
The code was already starting to look like a rather fine Italian pasta
before the addressNL mapping because of component-specific handling of
values that was necessary, but now with the additional configuration
options specific to the component type, readability and maintainability
was in serious danger.

I've opted to look at the broader structure on what information we
need, what information we have and what it is exactly that we need
to do with the information:

* We know all the variable values (keys and value), coming from user
  input, derived from user input or entirely independent from user
  input.
* When we know the key of a variable and we know the variable source is
  a form component, we can look up the definition of the form
  component and pass it along as additional context
* We know some user input (file uploads) is processed differently _in
  the context of the objects API_ and we have data storage that allows
  us to translate
* We need to normalize some values to make them suitable for use in the
  Objects API, because a JSON Schema contract is used. Looking at you,
  file uploads with multiple=false.
* We may have additional mapping configuration for a specific variable,
  typically because the variable points to a particular component type
  with special requirements (looking at you, addressNL)
* We must be able to construct the record data for the objects API. The
  keys to be used are specified in the mapped variables configuration,
  namely the target paths.
* We must process all the mapped variables to construct the entire
  object to send to the API.
* We can map all kinds of variables (form, user defined, static,
  registration).

So, working backwards, what we needed was for each mapped variable to
make it return instructions which paths of the final object need to
be set to which value. This is solved with AssignmentSpec data classes,
they simply encode the {key: value} information in a well-typed manner.

Next, a single mapping may result in multiple assignments being done
to different parts of the object - this is the newest requirement from
AddressNL type. We can express that as a sequence of AssignmentSpecs.

Finally, we collect all this information, bundle it up and hand it over
to glom which constructs our actual data object, from the mappings.

That leaves us with the requirement of a thing that produces
AssignmentSpec instructions given a mapping configuration and a value.
Because we already know that the value must be transformed depending
on its meaning (=which component produced it), we also pass the
resolved component configuration along for additional context.

For good measure and better code organization, the bulk of the
implementation is moved into handlers/v2.py. More code will be moved
around if this passes the initial reviews.
@robinmolen
Copy link
Contributor

robinmolen commented Jan 8, 2025

A small overview of the different items that need to be picked up to complete this epic:

Critial todos:

Other todos:

This should include all items described in Joeri's comment and some items from the first message.

@sergei-maertens
Copy link
Member Author

Rough estimate ~8 weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

4 participants