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

Nested facets for admin form #3035

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lauraghiorghisor-tw
Copy link
Contributor

@lauraghiorghisor-tw lauraghiorghisor-tw commented Mar 5, 2025

This PR introduces the ability to add and edit nested facets in the admin form.
We decided to not do a full design for this feature, but provide a developer-readable solution as MVP.

Nested Facet

  • Note the radio button, the input that takes both Facet name and key (key on edit only), and the hint including instructions on subfacets and example.

Screenshot 2025-03-05 at 15 49 56


Show option select filter

Additionally, this PR includes a few clean-up commits to finish the IPO finder. Note in particular the introducing of the show_option_select_filter on the generated schema. This is an option we only use for Licence finder and Trademark Decisons. But it is handy to have it includes so that we don't get unnecessary diffs. It was required to pass the feature test added for Trademarks.

It's also handy to have it as a viable option on the admin UI. This option enables the kind of search seen for Appointed person/ hearing officer here.

Screenshot 2025-03-05 at 15 50 11

Trello

This commit enables the rendering of subfacet values from the schema.

In the schema, a nested facet includes a `sub_facets` key with additional label-value pairs. As per this commit, the main facet's values and their subfacet's values are mapped to "blocks" of facets:
 - the first line is the main facet (which will slow as label only on a new form "Main Facet" and label-key on edit form "Main Facet{main-facet}")
 - subsequent rows include the subfacets in the same style: "Sub Facet", and "Sub Facet{sub-facet}" respectively.
 - each facet block is separated from the next by an empty line.

The splitting of the allowed value text area string (see subsequent commits) required that I render the two new lines as "\r\n\r\n" - it basically means one **visible** blank line.
This commit prepares the views and permits controller params for passing values for nested facets.

We require the name and key of a subfacet, which are here mixed one single input called subfacet. This value will be given as "Facet {key}", as we do elsewhere on the form.
This is to minimize difference in the schema diff, as well as offering the option in the admin UI.
The field `short_` should be before `special_`. This is to ensure we don't get unnecessary diffs when generating a schema in the admin area.
This is to ensure we don't get unnecessary diffs when generating a schema in the admin area.
This test was not running with the test suite as it was missing the _spec suffix.

Other tests such as:
- creating_a_data_ethics_guidance_document.rb
- creating_a_product_safety_alert_report_recall.rb
- creating_an_animal_disease_case.rb
should also be renamed but will be deleted in a parallel PR so leaving them.
@lauraghiorghisor-tw lauraghiorghisor-tw force-pushed the nested-facets-for-admin-form branch from 201b337 to b440a73 Compare March 5, 2025 16:04
There was a `Polynomial regular expression used on uncontrolled data` alert due to the potential length of the string on which we're then calling match.

The fix is to truncate the string. The assumption here is that any such string would include a very long key, so the cropping includes an ending "}".
@lauraghiorghisor-tw lauraghiorghisor-tw force-pushed the nested-facets-for-admin-form branch from a448105 to 75fbcc8 Compare March 5, 2025 17:57
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