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

Filtering support for all options-components #2806

Merged
merged 20 commits into from
Dec 16, 2024
Merged

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Dec 10, 2024

Description

This adds support for filtering options via an expression. The optionFilter property allows an expression that will run for each of the available options, and will only keep the option if the expression returns true.

An example from the ttd/frontend-test test-case:

{
  "id": "ingredientType",
  "type": "Dropdown",
  "textResourceBindings": {
    "title": "Ingrediens"
  },
  "dataModelBindings": {
    "simpleBinding": "FilteredOptions.Ingredients.Type"
  },
  "optionsId": "foods",
  "optionFilter": ["and",
    // Always remove disliked foods
    ["not", ["commaContains", ["dataModel", "FilteredOptions.Dislikes"], ["value"]]],
    ["or",
      // Remove those that have been used elsewhere
      ["not", ["commaContains", ["dataModel", "FilteredOptions.UsedTypes"], ["value"]]],
      // But not if it's the currently chosen ingredient here
      ["equals", ["component", "ingredientType"], ["value"]]
    ]
  ],
  "sortOrder": "asc",
  "required": true
}

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
  • 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

@olemartinorg olemartinorg added the kind/product-feature Pull requests containing new features label Dec 10, 2024
Ole Martin Handeland added 7 commits December 11, 2024 10:39
…, until I saw the comment I made long ago about that leading to a bad developer experience. Trying to stop myself from doing this again in the future.
…e tests that failed, as options were never again the exact same object as before.
…mode, and setting it again if using optionFilter
@olemartinorg olemartinorg marked this pull request as ready for review December 11, 2024 12:08
Ole Martin Handeland added 2 commits December 11, 2024 14:47
Copy link
Contributor

@paal2707 paal2707 left a comment

Choose a reason for hiding this comment

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

Ser bra ut! :)

@olemartinorg olemartinorg merged commit 3603222 into main Dec 16, 2024
13 of 14 checks passed
@olemartinorg olemartinorg deleted the feat/filterOptions branch December 16, 2024 08:02
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
None yet
Development

Successfully merging this pull request may close these issues.

Forhindre gjenbruk av innhold i dropdownliste på tvers av rader i repeterende tabell
2 participants