Skip to content

Commit

Permalink
feat(facet): SKFP-1407 add default operator facet and QF
Browse files Browse the repository at this point in the history
  • Loading branch information
GaelleA committed Dec 17, 2024
1 parent 0f26278 commit 065d0c1
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@babel/core": "^7.26.0",
"@dnd-kit/core": "^4.0.3",
"@dnd-kit/sortable": "^5.1.0",
"@ferlab/ui": "^10.14.4",
"@ferlab/ui": "^10.14.6",
"@loadable/component": "^5.16.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@react-keycloak/core": "^3.2.0",
Expand Down
10 changes: 9 additions & 1 deletion src/components/uiKit/FilterList/CustomFilterContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { ReactNode, useEffect, useState } from 'react';
import intl from 'react-intl-universal';
import FilterContainer from '@ferlab/ui/core/components/filters/FilterContainer';
import { IFilter, IFilterGroup, TExtendedMapping } from '@ferlab/ui/core/components/filters/types';
import {
IFilter,
IFilterGroup,
TExtendedMapping,
TFilterGroupDefaults,
} from '@ferlab/ui/core/components/filters/types';
import { updateActiveQueryFilters } from '@ferlab/ui/core/components/QueryBuilder/utils/useQueryBuilderState';
import { underscoreToDot } from '@ferlab/ui/core/data/arranger/formatting';
import { getFilterGroup } from '@ferlab/ui/core/data/filters/utils';
Expand All @@ -28,6 +33,7 @@ type OwnProps = {
queryBuilderId: string;
filterKey: string;
defaultOpen?: boolean;
defaults?: TFilterGroupDefaults;
extendedMappingResults: IExtendedMappingResults;
filtersOpen?: boolean;
filterMapper?: TCustomFilterMapper;
Expand All @@ -44,6 +50,7 @@ const CustomFilterContainer = ({
queryBuilderId,
filtersOpen,
defaultOpen,
defaults,
extendedMappingResults,
filterKey,
filterMapper,
Expand Down Expand Up @@ -83,6 +90,7 @@ const CustomFilterContainer = ({
const filterGroup = getFilterGroup({
extendedMapping: found,
aggregation: aggregations,
defaults,
rangeTypes: [],
filterFooter: filterWithFooter,
headerTooltip,
Expand Down
1 change: 1 addition & 0 deletions src/components/uiKit/FilterList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const FilterList = ({
}
filterWithFooter={filterWithFooter}
categoryIcon={group.categoryIcon}
defaults={group.defaults?.[facet]}
/>
) : (
<div key={i + ii} className={cx(styles.customFilterWrapper, styles.filter)}>
Expand Down
2 changes: 2 additions & 0 deletions src/components/uiKit/FilterList/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { ReactNode } from 'react';
import { TFilterGroupDefaults } from '@ferlab/ui/core/components/filters/types';
import { IExtendedMappingResults } from '@ferlab/ui/core/graphql/types';
import { DocumentNode } from 'graphql';

export interface FilterGroup {
title?: string;
facets: string[] | ReactNode[];
defaults?: { [key: string]: TFilterGroupDefaults };
tooltips?: string[];
noDataOption?: string[];
intervalDecimal?: { [key: string]: number };
Expand Down
6 changes: 6 additions & 0 deletions src/graphql/quickFilter/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ export const GET_QUICK_FILTER_EXPLO = gql`
doc_count
}
}
# Range
files__imaging__device__magnetic_field_strength {
stats {
count
}
}
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/views/DataExploration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '@ferlab/ui/core/components/SidebarMenu/QuickFilter';
import { underscoreToDot } from '@ferlab/ui/core/data/arranger/formatting';
import { getFilterGroup, getFilterType } from '@ferlab/ui/core/data/filters/utils';
import { TermOperators } from '@ferlab/ui/core/data/sqon/operators';
import { RangeOperators, TermOperators } from '@ferlab/ui/core/data/sqon/operators';
import { MERGE_VALUES_STRATEGIES } from '@ferlab/ui/core/data/sqon/types';
import { getSelectedFilters } from '@ferlab/ui/core/data/sqon/utils';
import { IExtendedMappingResults, TAggregationBuckets } from '@ferlab/ui/core/graphql/types';
Expand Down Expand Up @@ -77,6 +77,7 @@ import BiospecimenUploadIds from './components/UploadIds/BiospecimenUploadIds';
import FileUploadIds from './components/UploadIds/FileUploadIds';
import ParticipantUploadIds from './components/UploadIds/ParticipantUploadIds';
import {
getDefaultOperator,
getFieldCategoryIcon,
getFieldWithoutPrefix,
getIndexFromQFValueFacet,
Expand Down Expand Up @@ -217,6 +218,11 @@ const filterGroups: {
'imaging__device__manufacturer',
'imaging__device__model_name',
],
defaults: {
imaging__device__magnetic_field_strength: {
operator: RangeOperators['>'],
},
},
categoryIcon: <FileTextOutlined className={styles.categoryIcon} />,
},
],
Expand Down Expand Up @@ -404,6 +410,7 @@ const DataExploration = () => {
const filterGroup = getFilterGroup({
extendedMapping: found,
aggregation: aggregations,
defaults: getDefaultOperator(option.key),
rangeTypes: [],
filterFooter: false,
headerTooltip: false,
Expand Down
15 changes: 14 additions & 1 deletion src/views/DataExploration/utils/quickFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ExperimentOutlined, FileTextOutlined, UserOutlined } from '@ant-design/icons';
import { AntdIconProps } from '@ant-design/icons/lib/components/AntdIcon';
import { VisualType } from '@ferlab/ui/core/components/filters/types';
import { IFilterGroupDefaultsRange, VisualType } from '@ferlab/ui/core/components/filters/types';
import { CheckboxQFOption } from '@ferlab/ui/core/components/SidebarMenu/QuickFilter';
import { RangeOperators } from '@ferlab/ui/core/data/sqon/operators';
import {
ISyntheticSqon,
IValueFilter,
Expand Down Expand Up @@ -77,6 +78,18 @@ export const getFieldWithPrefixUnderscore = (index: string, field: string): stri
}
};

export const getDefaultOperator = (facetKey: string): IFilterGroupDefaultsRange | undefined => {
switch (facetKey) {
case 'files__imaging__device__magnetic_field_strength':
return {
operator: RangeOperators['>'],
};

default:
return undefined;
}
};

export const getSqonForQuickFilterFacetValue = (activeQuery: ISyntheticSqon): ISyntheticSqon => {
const activeQueryUpdated = cloneDeep(activeQuery);
activeQueryUpdated.content.forEach((sqonContent: TSyntheticSqonContentValue) => {
Expand Down
28 changes: 28 additions & 0 deletions src/views/Variants/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import intl from 'react-intl-universal';
import { UserOutlined } from '@ant-design/icons';
import SidebarMenu, { ISidebarMenuItem } from '@ferlab/ui/core/components/SidebarMenu';
import { RangeOperators } from '@ferlab/ui/core/data/sqon/operators';
import ScrollContent from '@ferlab/ui/core/layout/ScrollContent';
import { INDEXES } from 'graphql/constants';

Expand Down Expand Up @@ -66,6 +67,11 @@ const filterGroups: {
'studies__zygosity',
'studies__transmission',
],
defaults: {
start: {
operator: RangeOperators['between'],
},
},
noDataOption: ['start'],
intervalDecimal: {
start: 0,
Expand All @@ -90,6 +96,11 @@ const filterGroups: {
'genes__gnomad__pli',
'genes__gnomad__loeuf',
],
defaults: {
genes__gnomad__pli: {
operator: RangeOperators['>'],
},
},
noDataOption: ['genes__gnomad__pli', 'genes__gnomad__loeuf'],
},
{
Expand Down Expand Up @@ -129,6 +140,23 @@ const filterGroups: {
'genes__spliceai__ds',
'genes__consequences__predictions__sift_pred',
],
defaults: {
genes__consequences__predictions__cadd_score: {
operator: RangeOperators['>'],
},
genes__consequences__predictions__cadd_phred: {
operator: RangeOperators['>'],
},
genes__consequences__predictions__dann_score: {
operator: RangeOperators['>'],
},
genes__consequences__predictions__revel_score: {
operator: RangeOperators['>'],
},
genes__spliceai__ds: {
operator: RangeOperators['>'],
},
},
tooltips: [
'genes__consequences__predictions__cadd_score',
'genes__consequences__predictions__cadd_phred',
Expand Down

0 comments on commit 065d0c1

Please sign in to comment.