Support for negative filters in the UI
genesys-server#307 (closed) adds support for "negative" NOT filters, isNull
NULL and isNotNull
NOTNULL filtering to the Genesys backend. Most relevant code is in application-blocks project commit application-blocks@4456892d.
This allows us to apply really interesting filters:
Positive filters
The existing filters are "positive", they require the value to be present. The filter:
{
"taxa": {
"genus": ["Manihot"],
"species": ["esculenta"]
}
}
translates to: Find records where taxa.genus == Manihot and taxa.species == esculenta
.
Negative filters
If we want to filter records that match Manihot
genus, but do not match species esculenta
, then we need to send:
{
"taxa": {
"genus": ["Manihot"]
},
"NOT": {
"taxa": {
"species": ["esculenta"]
}
}
}
This translates to: Find records where taxa.genus == Manihot and taxa.species != esculenta
.
All positive filter options available now are supported as elements of the NOT
filter. Please extend the **Filter
class definitions to include:
class AccessionFilter {
public acceNumb: StringFilter;
...
public NOT: AccessionFilter;
...
}
The user interface needs to be updated to support "toggling" between a filter value being in the positive or negative filters. Any ideas?
I think the "esculenta" filter should have a little +
/ !
toggler on the left side that allows the user to move the esculenta
filter value from positive to a negative filter and back. Maybe the negative filter should be displayed in red.
isNull
filters
Sometimes we want to find records that do not specify any value. For example, accession available
field can have values true
, false
or null
, where null
means that we don't know if the accession is available, but we know that it is not unavailable.
To filter for such records, we use cannot use the null
value:
{
"available": null
}
This just indicates we don't care about available
field and it is ignored by the server. To specify that we're looking for Accessions that have available == null
we must use:
{
"NULL": [ "available" ]
}
The NULL
filter accepts a set of property names and looks up data where available is null
in the database.
Existing filter classes should be extends to include:
class AccessionFilter {
public acceNumb: StringFilter;
...
public NULL: string[];
...
}
The UI should allow the user to say: "Hey, I want records where this value is null
!". A checkbox in the "Available" filter that says Data not provided?
isNotNull
filters
Sometimes we want to find records that have any value (but null
). For example, accession available
field can have values true
, false
or null
, where null
means that we don't know if the accession is available, but we know that it is not unavailable.
To specify that we're looking for Accessions that have available != null
we must use:
{
"NOTNULL": [ "available" ]
}
The NOTNULL
filter accepts a set of property names and looks up data where available is not null
in the database.
class AccessionFilter {
public acceNumb: StringFilter;
...
public NOTNULL: string[];
...
}
The UI should allow the user to say: "Hey, I want records where this value is not null
!". A checkbox in the "Available" filter that says Data exists? How do we mix that with the isNull
filter above?