Skip to content

feat(card-template-editor): introduce FieldFilters [DEV-only]#20688

Merged
mikehardy merged 1 commit intoankidroid:mainfrom
david-allison:field-filters
Apr 19, 2026
Merged

feat(card-template-editor): introduce FieldFilters [DEV-only]#20688
mikehardy merged 1 commit intoankidroid:mainfrom
david-allison:field-filters

Conversation

@david-allison
Copy link
Copy Markdown
Member

Note

Assisted-by: Claude Opus 4.6
Discussed design, most of the code was mine
The concept of canApplyTo/updateContext was the largest contribution

Purpose / Description

See #20533 for context

FieldFilters are the filters to the left side of a Field: {{type:Front}}

Users should be made aware of all available filters.

We first introduce the concept, then the concept of a chain: {{kana:text:Front}}.

Due to various capabilities of a chain, some filters may not be applied on top of others (tts is terminal; text removes HTML; hint adds HTML)

Fixes

Approach

Define validation rules on top of a chain based on 'context': canApplyTo and updateContext over a FilterContext

This allows UI validation: "once a user has applied hint, no longer allow them to apply text"

FieldFilters contains the object, we use 'ALL' as the filters inherit from FieldFilter, not FieldFilters

How Has This Been Tested?

Unit tested

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Comment thread AnkiDroid/src/test/java/com/ichi2/anki/model/FieldFilterChainTest.kt Outdated
FieldFilters are the filters to the left side of a Field: {{type:Front}}

Users should be made aware of all available filters.

We first introduce the concept, then the concept of a chain:
{{kana:text:Front}}.

Due to various capabilities of a chain, some filters may not be applied
on top of others (`tts` is terminal; text removes HTML; hint adds HTML)

So we define validation rules on top of a chain based on 'context':
 `canApplyTo` and `updateContext` over a `FilterContext`

This allows UI validation: "once a user has applied `hint`, no
 longer allow them to apply `text`"

FieldFilters contains the object, we use 'ALL' as the filters inherit
 from `FieldFilter`, not `FieldFilters`

Issue 20533

Assisted-by: Claude Opus 4.6
Copy link
Copy Markdown
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

Let's go

@mikehardy mikehardy added this pull request to the merge queue Apr 19, 2026
@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Review labels Apr 19, 2026
Merged via the queue into ankidroid:main with commit 9476f24 Apr 19, 2026
15 checks passed
@github-actions github-actions Bot added this to the 2.24 release milestone Apr 19, 2026
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Apr 19, 2026
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.

3 participants