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

[WIP] Update fragments #522

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

[WIP] Update fragments #522

wants to merge 3 commits into from

Conversation

sree-cfa
Copy link
Contributor

@sree-cfa sree-cfa commented Feb 24, 2024

Description of change ✍️

Updated the checkbox and radio fieldset fragments to be able to take a collection of options.

The options param are values from classes that implement InputOption. They must have a value and label/helpText are optional. This is to simplify rendering for static checkboxes and have a more centralized way of referencing these values in html rendering and PDF generation.
*Backwards compatible.

Priority 🥇

Medium - we can override locally for now

Effect on other applications using FFB 🌊

No breaking changes - this will be backwards compatible

Testing

There's a unit test showing how to use this new param. Here's an example as well (GenderOptions will have to be implements)

<th:block th:with="genderOptions=${T(org.ilgcc.app.utils.GenderOption).values()},
  <th:block th:replace="~{fragments/inputs/checkboxFieldset ::
    checkboxFieldset(inputName='childGender',
      label=#{children-ccap-info.gender-question},
      options=${genderOptions})}"/>

✅ Checklist before requesting a review

  • Does the new code follow our preferred coding
    style
    ?
  • Does the code include javadocs, where necessary?
  • Have tests for this feature been added / updated?
  • Has the readme been updated?

@sree-cfa sree-cfa self-assigned this Feb 24, 2024
<th:block th:replace="~{fragments/inputs/checkboxInSet ::
checkboxInSet(inputName=${inputName},
value=${option.getValue()},
label=${#strings.isEmpty(option.getLabel()) ? null : #messages.msg(option.getLabel())},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be interpolated beforehand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sort of think it should just based on how the other messages work - it seems like for Actions and Validations, we interpolate them before the template gets rendered.
I also think it's kind of nice that it isn't interpolated beforehand because the enums work pretty well here and it's not straightforward to use the messageSource through an enum

@sree-cfa sree-cfa changed the title Update fragments WIP Update fragments Feb 26, 2024
@sree-cfa
Copy link
Contributor Author

I want to try this out in IL-GCC first before integrating to FFL. There's probably a better way to do this and maybe get interpolation to work easily 🤔

Holding off on merging, but feedback is welcome!

@sree-cfa sree-cfa changed the title WIP Update fragments [WIP] Update fragments Feb 29, 2024
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