Skip to content

feat(filters): pick listed filter parameters from selects - #1499

Open
revam wants to merge 1 commit into
masterfrom
feat/filter-parameter-inputs
Open

revam wants to merge 1 commit into
masterfrom
feat/filter-parameter-inputs

Conversation

@revam

@revam revam commented Oct 6, 2026

Copy link
Copy Markdown
Member

Why

The filter editor only gave a condition a value picker when the server listed values for it, or when its parameter was a number. Everything else became a True/False condition:

  • Conditions that take free text (an AniDB character or creator ID, a name) could not be given a value, and a saved one was read back as True/False, so saving the filter again dropped its parameter.
  • Conditions with two parameters but no pairs (a character with an appearance, a creator with a role) were treated the same way, losing both parameters.
  • A number parameter without a list opened an empty picker.

The server's filter expression help now sends one list per parameter: either PossibleParameters/PossibleSecondParameters or PossibleParameterPairs, never both, with ParameterName/SecondParameterName to label the inputs. This PR builds the editor on that, and supersedes the parameter editing of #1482.

Where this sits

  • Branch: feat/filter-parameter-inputs, one commit on master. Independent of the other open PRs.
  • Server: needs the server's filter expression help from the current core master (the name hints, the second-parameter lists, and pairs only for source genres and tags). Against an older core the inputs fall back to "Value"/"Second Value" labels, and the appearance and role are typed instead of picked.

What

One rule: a list from the server means you pick from it, never type; free text only when the server sends no list for that parameter.

  • Every expression that takes a parameter gets a value widget (getWidgetKind): pairs or a second parameter make it a two-value condition, any parameter a one-value condition. Only parameterless expressions stay True/False. Saved conditions with free-text parameters now load and save with their values.
  • MultiValueCriteriaModal picks in one of two ways:
    • One list when the server sends pairs, or a list for a single parameter: the existing click-to-add list, now labelled from the name hints (Source: Genre for pairs).
    • One input per parameter otherwise, each a select when that parameter is listed and a text input (a number input for Number) when it is not, with an Add button (and Enter). For example, "AniDB Character ID" is typed and "Appearance" is picked.
  • Values are kept as their raw parameters and joined only for display, so a value containing : is never split wrongly. Duplicates and empty values cannot be added.
  • FilterExpression gained ParameterName and SecondParameterName.

Look first at: src/components/Collection/Filter/MultiValueCriteriaModal.tsx (ParameterInput and the list or inputs branch), then getWidgetKind in src/core/utilities/filterTree.ts.

Feedback wanted

  • A single listed parameter and pairs keep the click-to-add list rather than a <select>; only the per-parameter form uses selects. Is that split right, or should a single list become a select too?
  • Character and creator IDs are typed by hand. A search-backed picker would suit them better; worth a follow-up?
  • Labels fall back to "Value" and "Second Value" when the server sends no name. Fine, or should the expression's name be used instead?

Testing

  • On the tip: pnpm lint, pnpm tscheck, pnpm test (199 passed; filterTree.test.ts gained cases for free-text parameters and two-parameter expressions without pairs) and pnpm build all pass. No dependency changes.
  • Not yet tried against a running server.
  • To try: in the filter editor, add "Has Character With Appearance": type a character ID, pick an appearance, Add, save, reopen and edit it again. Do the same with a source genre (one list of pairs) and a free-text condition such as a creator ID, and check that each keeps its values after saving and reloading.

- Gave every parameterised expression a value widget in `getWidgetKind`, so two-parameter expressions without pairs and free-text ones are editable
- Made `MultiValueCriteriaModal` pick pairs or a single listed parameter from its list, and otherwise show one select (listed) or text input (unlisted) per parameter
- Labelled the inputs with the new `ParameterName` and `SecondParameterName`

This branch has not been deployed

No deployments
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