Browse Source

Dynamically add missing filter options

master
jeffvli 3 years ago
committed by Jeff
parent
commit
96b87804a8
  1. 27
      src/components/library/AdvancedFilters.tsx

27
src/components/library/AdvancedFilters.tsx

@ -1,4 +1,3 @@
/* eslint-disable react/destructuring-assignment */
import _ from 'lodash'; import _ from 'lodash';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { ButtonToolbar, Icon, RadioGroup } from 'rsuite'; import { ButtonToolbar, Icon, RadioGroup } from 'rsuite';
@ -174,7 +173,18 @@ const AdvancedFilters = ({ filteredData, originalData, filter, setAdvancedFilter
<ButtonToolbar> <ButtonToolbar>
<StyledCheckPicker <StyledCheckPicker
container={() => genreFilterPickerContainerRef.current} container={() => genreFilterPickerContainerRef.current}
data={availableGenres} data={_.concat(
availableGenres,
_.compact(
filter.properties.genre.list.map((genre: any) => {
if (!_.includes(_.map(availableGenres, 'title'), genre)) {
return { title: genre };
}
return undefined;
})
)
)}
value={filter.properties.genre.list} value={filter.properties.genre.list}
labelKey="title" labelKey="title"
valueKey="title" valueKey="title"
@ -235,7 +245,18 @@ const AdvancedFilters = ({ filteredData, originalData, filter, setAdvancedFilter
<ButtonToolbar> <ButtonToolbar>
<StyledCheckPicker <StyledCheckPicker
container={() => artistFilterPickerContainerRef.current} container={() => artistFilterPickerContainerRef.current}
data={availableArtists} data={_.concat(
availableArtists,
_.compact(
filter.properties.artist.list.map((artistId: any) => {
if (!_.includes(_.map(availableArtists, 'id'), artistId)) {
return { title: artistId, id: artistId };
}
return undefined;
})
)
)}
value={filter.properties.artist.list} value={filter.properties.artist.list}
labelKey="title" labelKey="title"
valueKey="id" valueKey="id"

Loading…
Cancel
Save