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

Supporting component and dataModel lookups in optionFilter when using source options #2839

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Dec 19, 2024

Description

After the optionFilter property was added, in an unrelated task, I saw that filtering the 'repeating group-sourced' options on the 'Pets' page in ttd/frontend-test was a perfect use-case for optionFilter. In order to filter out repeating group rows that had not been filled out yet, it was painfully obvious that the filter should support lookups per row when each option comes from a row.

So, this functionality allows this expression filter to work:

{
  "id": "hiddenPets",
  "type": "Checkboxes",
  "source": {
    "group": "Pets",
    "label": "PetName",
    "value": "Pets.UniqueId"
  },
  "optionFilter": [
    "and",
    ["notEquals", ["dataModel", "Pets.Age"], null],
    ["notEquals", ["dataModel", "Pets.Name"], null],
    ["notEquals", ["dataModel", "Pets.Species"], null]
  ]
}

This Checkboxes component will get options from the Pets repeating group, but rows where all the fields are null (Age, Name and Species) will be filtered out. I was also able to do this using the existing value function, but it's much more fiddly, brittle and difficult to work with - looking up in the data model directly is obviously better.

Also, component lookups will work as well (but only if there is a RepeatingGroup bound to the path in the data model - dataModel lookups will work regardless).

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Ole Martin Handeland added 5 commits December 18, 2024 22:04
…ay we can write expressions that also look up data inside the row (in the data model), not just the values in ["value", ...].
…lookups work even when there are no RepeatingGroup components configured
@olemartinorg olemartinorg added the kind/product-feature Pull requests containing new features label Dec 19, 2024
@olemartinorg olemartinorg self-assigned this Dec 19, 2024
Copy link
Member

@bjosttveit bjosttveit left a comment

Choose a reason for hiding this comment

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

Very nice addition 🙌

@olemartinorg olemartinorg merged commit efbb4df into main Dec 19, 2024
16 checks passed
@olemartinorg olemartinorg deleted the feat/optionFilter-per-row branch December 19, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/product-feature Pull requests containing new features
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants