Skip to content

Commit

Permalink
feat(explorer): allow filters on link attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
TdyP authored and P0ppoff committed Dec 24, 2024
1 parent 75eae8d commit 8584870
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
39 changes: 19 additions & 20 deletions libs/ui/src/components/Explorer/_queries/useExplorerData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,26 @@ export const useExplorerData = ({
}) => {
const {lang: availableLangs} = useLang();

const preparedFilters: RecordFilterInput[][] = filters
.filter(
({value, condition}) =>
value !== null ||
[RecordFilterCondition.IS_EMPTY, RecordFilterCondition.IS_NOT_EMPTY].includes(condition)
)
.map(({attribute, field, condition, value}) =>
attribute.format === AttributeFormat.date
? _getDateRequestFilters({field, condition, value})
: [
{
field,
condition,
value
}
]
);
const queryFilters: RecordFilterInput[] = interleaveElement(
const queryFilters = interleaveElement(
{operator: RecordFilterOperator.AND},
preparedFilters
) as RecordFilterInput[];
filters
.filter(
({value, condition}) =>
value !== null ||
[RecordFilterCondition.IS_EMPTY, RecordFilterCondition.IS_NOT_EMPTY].includes(condition)
)
.map(({attribute, field, condition, value}) =>
attribute.format === AttributeFormat.date
? _getDateRequestFilters({field, condition, value})
: [
{
field,
condition,
value
}
]
)
);

const {data, loading, refetch} = useExplorerQuery({
skip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ export const FilterItems: FunctionComponent<{libraryId: string}> = ({libraryId})
dispatch({type: ViewSettingsActionTypes.MOVE_FILTER, payload: {indexFrom, indexTo}});
};

const ignoredTypes = [AttributeType.tree];
const activeFilters = filters.filter(({field}) => searchFilteredColumnsIds.includes(field));
const inactiveFilters = searchFilteredColumnsIds.filter(
attributeId =>
attributeDetailsById?.[attributeId]?.type === AttributeType.simple &&
!ignoredTypes.includes(attributeDetailsById?.[attributeId]?.type) &&
filters.every(filterItem => filterItem.field !== attributeId)
);

Expand Down

0 comments on commit 8584870

Please sign in to comment.