fix(ui): fix metadata in saved search
This commit is contained in:
parent
1035a1a219
commit
b9e2cafe4b
3 changed files with 8 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ interface Props {
|
||||||
fetchListSavedSearch: () => void;
|
fetchListSavedSearch: () => void;
|
||||||
list: any;
|
list: any;
|
||||||
savedSearch: any;
|
savedSearch: any;
|
||||||
|
fetchedMeta: boolean
|
||||||
}
|
}
|
||||||
function SavedSearch(props: Props) {
|
function SavedSearch(props: Props) {
|
||||||
const { list } = props;
|
const { list } = props;
|
||||||
|
|
@ -18,10 +19,10 @@ function SavedSearch(props: Props) {
|
||||||
const { showModal } = useModal();
|
const { showModal } = useModal();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (list.size === 0) {
|
if (list.size === 0 && props.fetchedMeta) {
|
||||||
props.fetchListSavedSearch()
|
props.fetchListSavedSearch()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [props.fetchedMeta])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex items-center", { [stl.disabled] : list.size === 0})}>
|
<div className={cn("flex items-center", { [stl.disabled] : list.size === 0})}>
|
||||||
|
|
@ -48,5 +49,6 @@ function SavedSearch(props: Props) {
|
||||||
|
|
||||||
export default connect((state: any) => ({
|
export default connect((state: any) => ({
|
||||||
list: state.getIn([ 'search', 'list' ]),
|
list: state.getIn([ 'search', 'list' ]),
|
||||||
savedSearch: state.getIn([ 'search', 'savedSearch' ])
|
savedSearch: state.getIn([ 'search', 'savedSearch' ]),
|
||||||
|
fetchedMeta: state.getIn(['customFields', 'fetchedMetadata'])
|
||||||
}), { fetchListSavedSearch })(SavedSearch);
|
}), { fetchListSavedSearch })(SavedSearch);
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ const FETCH_SOURCES_SUCCESS = success(FETCH_SOURCES);
|
||||||
const initialState = Map({
|
const initialState = Map({
|
||||||
list: List(),
|
list: List(),
|
||||||
instance: CustomField(),
|
instance: CustomField(),
|
||||||
|
fetchedMetadata: false,
|
||||||
sources: List(),
|
sources: List(),
|
||||||
optionsReady: false,
|
optionsReady: false,
|
||||||
});
|
});
|
||||||
|
|
@ -54,7 +55,7 @@ const reducer = (state = initialState, action = {}) => {
|
||||||
addElementToFlagConditionsMap(FilterCategory.METADATA, '_' + item.key)
|
addElementToFlagConditionsMap(FilterCategory.METADATA, '_' + item.key)
|
||||||
addElementToConditionalFiltersMap(FilterCategory.METADATA, '_' + item.key)
|
addElementToConditionalFiltersMap(FilterCategory.METADATA, '_' + item.key)
|
||||||
});
|
});
|
||||||
return state.set('list', List(action.data).map(CustomField))
|
return state.set('list', List(action.data).map(CustomField)).set('fetchedMetadata', true)
|
||||||
|
|
||||||
case FETCH_SOURCES_SUCCESS:
|
case FETCH_SOURCES_SUCCESS:
|
||||||
return state.set(
|
return state.set(
|
||||||
|
|
|
||||||
|
|
@ -849,7 +849,7 @@ export default Record({
|
||||||
_filter = subFilterMap[type];
|
_filter = subFilterMap[type];
|
||||||
} else {
|
} else {
|
||||||
if (type === FilterKey.METADATA) {
|
if (type === FilterKey.METADATA) {
|
||||||
_filter = filtersMap[filter.source];
|
_filter = filtersMap[`_${filter.source}`];
|
||||||
} else {
|
} else {
|
||||||
if (filtersMap[filter.key]) {
|
if (filtersMap[filter.key]) {
|
||||||
_filter = filtersMap[filter.key]
|
_filter = filtersMap[filter.key]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue