-
Notifications
You must be signed in to change notification settings - Fork 14
Keep the taxa-list filters when opening a taxon's occurrences, and add Device & Site filters #1347
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
Open
mihow
wants to merge
7
commits into
main
Choose a base branch
from
feat/taxa-occurrence-filters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2d44c9f
feat: carry taxa filters into occurrences and add Device & Site filters
mihow ff6be8a
fix: return 400 instead of 500 for a non-integer filter id
mihow 36c04a3
refactor: share the taxa-to-occurrence filter carry-over and apply it…
mihow 50bb5a2
feat: match the taxa filter layout to the occurrence list and carry f…
mihow 33e4fd5
refactor: key filter carry-over by destination (FILTERS_TO_OCCURRENCE…
mihow 25d66a7
refactor: move the carry-over contracts into their destination modules
mihow f631c66
refactor: chain the filter-id exceptions and route the "More filters"…
mihow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { API_ROUTES } from 'data-services/constants' | ||
| import { EntityPicker } from 'nova-ui-kit' | ||
| import { FilterProps } from './types' | ||
|
|
||
| export const DeviceFilter = ({ onAdd, onClear, value }: FilterProps) => ( | ||
| <EntityPicker | ||
| collection={API_ROUTES.DEVICES} | ||
| onValueChange={(value) => { | ||
| if (value) { | ||
| onAdd(value) | ||
| } else { | ||
| onClear() | ||
| } | ||
| }} | ||
| value={value} | ||
| /> | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { API_ROUTES } from 'data-services/constants' | ||
| import { EntityPicker } from 'nova-ui-kit' | ||
| import { FilterProps } from './types' | ||
|
|
||
| export const SiteFilter = ({ onAdd, onClear, value }: FilterProps) => ( | ||
| <EntityPicker | ||
| collection={API_ROUTES.SITES} | ||
| onValueChange={(value) => { | ||
| if (value) { | ||
| onAdd(value) | ||
| } else { | ||
| onClear() | ||
| } | ||
| }} | ||
| value={value} | ||
| /> | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // The occurrence list's filter carry-over contract: filter fields that another view may | ||
| // carry into the occurrence list (see useCarryOverFilters). A field belongs here only if | ||
| // both bounds hold: | ||
| // | ||
| // 1. The occurrence list backend honors it — keep this in sync by hand with the server | ||
| // filterset (OCCURRENCE_FILTERSET_FIELDS, the custom occurrence filter backends, and | ||
| // TaxonViewSet.get_occurrence_filters in ami/main/api/views.py). | ||
| // 2. The occurrence filter panel can display it — every field here has a control on the | ||
| // panel (a pickable control, or a readonly chip such as event/capture that appears | ||
| // once set), so a carried filter is always visible and clearable on arrival rather | ||
| // than silently shrinking the list. | ||
| // | ||
| // This is a curated subset, not "every field the panel renders" — a field can be on the | ||
| // panel yet deliberately left out of carry-over. The carryOverFilters test pins that every | ||
| // field here is a registered filter. | ||
| export const FILTERS_TO_OCCURRENCES = [ | ||
| 'detections__source_image', | ||
| 'event', | ||
| 'taxon', | ||
| 'taxa_list_id', | ||
| 'not_taxa_list_id', | ||
| 'verified', | ||
| 'verified_by_me', | ||
| 'collection', | ||
| 'date_start', | ||
| 'date_end', | ||
| 'deployment', | ||
| 'deployment__device', | ||
| 'deployment__research_site', | ||
| 'algorithm', | ||
| 'not_algorithm', | ||
| 'apply_defaults', | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // The taxa list's filter carry-over contract: filter fields that another view may carry | ||
| // into the taxa list (see useCarryOverFilters). A field belongs here only if both bounds | ||
| // hold: | ||
| // | ||
| // 1. The taxa list backend honors it — keep this in sync by hand with the server | ||
| // filterset (TaxonViewSet.filterset_fields and get_occurrence_filters in | ||
| // ami/main/api/views.py). | ||
| // 2. The taxa filter panel can display it — every field here has a control on the panel | ||
| // (pickable, or a readonly chip such as event that appears once set), so a carried | ||
| // filter is always visible and clearable on arrival. | ||
| // | ||
| // Differs from FILTERS_TO_OCCURRENCES where the lists differ: the taxa list carries | ||
| // "show unobserved taxa" and the tag filters (its own filters) but not the occurrence-only | ||
| // ones. The carryOverFilters test pins that every field here is a registered filter. | ||
| export const FILTERS_TO_TAXA = [ | ||
| 'event', | ||
| 'taxon', | ||
| 'taxa_list_id', | ||
| 'not_taxa_list_id', | ||
| 'verified', | ||
| 'include_unobserved', | ||
| 'deployment', | ||
| 'deployment__device', | ||
| 'deployment__research_site', | ||
| 'tag_id', | ||
| 'not_tag_id', | ||
| 'apply_defaults', | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.