Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export const fetchRows = async <
readonly fields: FIELDS;
readonly distinct?: boolean;
readonly limit?: number;
readonly filterChronostrat?: boolean;
},
/**
* Advanced filters, not type-safe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('fetchPickListItems', () => {
});

overrideAjax(
'/api/specify_rows/locality/?limit=0&domainfilter=true&distinct=true&fields=localityname',
'/api/specify_rows/locality/?limit=0&domainfilter=true&filterchronostrat=false&distinct=true&fields=localityname',
[['abc']]
);
test('entire column', async () => {
Expand Down
3 changes: 2 additions & 1 deletion specifyweb/frontend/js_src/lib/components/PickLists/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
deserializeResource,
serializeResource,
} from '../DataModel/serializers';
import { strictGetTable } from '../DataModel/tables';
import { strictGetTable, tables } from '../DataModel/tables';
import type { PickList, PickListItem, Tables } from '../DataModel/types';
import { softFail } from '../Errors/Crash';
import { format } from '../Formatters/formatters';
Expand Down Expand Up @@ -159,6 +159,7 @@ async function fetchFromField(
fields: { [fieldName]: ['string', 'number', 'boolean', 'null'] },
distinct: true,
domainFilter: true,
filterChronostrat: tableName === tables.GeologicTimePeriod.name.toLowerCase() && fieldName === "name", // Prop for age filter in QueryBuilder
}).then((rows) =>
rows
.map((row) => row[fieldName] ?? '')
Expand Down
6 changes: 5 additions & 1 deletion specifyweb/specify/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,14 @@ class GetCollectionForm(forms.Form):

orderby = forms.CharField(required=False)

filterchronostrat = forms.BooleanField(required=False)

defaults = dict(
domainfilter=None,
limit=0,
offset=0,
orderby=None,
filterchronostrat=False,
)

def clean_limit(self):
Expand Down Expand Up @@ -1010,7 +1013,7 @@ def apply_filters(logged_in_collection, params, model, control_params=GetCollect

filters.update({param: val})

if model.__name__ == 'Geologictimeperiod':
if control_params['filterchronostrat'] == True:
# Filter out invalid chronostrats
filters.update({
'startperiod__isnull': False,
Expand Down Expand Up @@ -1081,6 +1084,7 @@ class RowsForm(GetCollectionForm):
orderby=None,
distinct=False,
fields=None,
filterchronostrat=False,
)

def rows(request, model_name: str) -> HttpResponse:
Expand Down