diff --git a/hypha/static_src/src/app/src/containers/ByRoundListing.js b/hypha/static_src/src/app/src/containers/ByRoundListing.js index 12c32e958a4c34e62b52847e8fc5d983698fc713..ec687f7da18f56365445f12fc18819fb98321685 100644 --- a/hypha/static_src/src/app/src/containers/ByRoundListing.js +++ b/hypha/static_src/src/app/src/containers/ByRoundListing.js @@ -44,7 +44,8 @@ class ByRoundListing extends React.Component { isLoading: PropTypes.bool, errorMessage: PropTypes.string, filters: PropTypes.array, - groupBy: PropTypes.string + groupBy: PropTypes.string, + loadRounds: PropTypes.func }; componentDidMount() { @@ -54,13 +55,14 @@ class ByRoundListing extends React.Component { } componentDidUpdate(prevProps) { - const { statuses, groupBy } = this.props; + const { statuses } = this.props; if (!statuses.every(v => prevProps.statuses.includes(v)) - || !groupBy && !Object.keys(this.props.rounds).length || this.props.filters != prevProps.filters) { loadData(this.props) } + + if(!Object.keys(this.props.rounds).length) this.props.loadRounds() } prepareOrder = () => { diff --git a/hypha/static_src/src/app/src/containers/SubmissionFilters/index.js b/hypha/static_src/src/app/src/containers/SubmissionFilters/index.js index 026c9d99056d99eb9b2691b097678bd96f15766f..4aae7c2c1555f18af35d826d5e7eae16bc386d80 100644 --- a/hypha/static_src/src/app/src/containers/SubmissionFilters/index.js +++ b/hypha/static_src/src/app/src/containers/SubmissionFilters/index.js @@ -66,9 +66,9 @@ export class SubmissionFiltersContainer extends React.PureComponent { } componentDidUpdate(prevProps, prevState){ - if(this.props.getScreeningLoading == false - && !this.props.isGroupedIconShown - && this.props.history.location.search.includes("&") + if( + !this.props.isGroupedIconShown && + this.props.history.location.search.includes("&") && !this.props.submissionFilters.loading){ this.props.initializeAction(this.props.history.location.search, this.onFilter) } @@ -82,6 +82,7 @@ export class SubmissionFiltersContainer extends React.PureComponent { filterQuery.push({"key": "f_"+key, "value": options[key]}) ) this.props.updateFilterQuery(filterQuery) + if(!filterQuery.length) this.props.history.push(window.location.pathname) this.props.onFilter() } diff --git a/hypha/static_src/src/app/src/containers/SubmissionFilters/sagas.js b/hypha/static_src/src/app/src/containers/SubmissionFilters/sagas.js index e68cefeeef74d57556454d36b0e7b057430900ba..112b5bd854c3e453be28437a91be875591ab53ee 100644 --- a/hypha/static_src/src/app/src/containers/SubmissionFilters/sagas.js +++ b/hypha/static_src/src/app/src/containers/SubmissionFilters/sagas.js @@ -16,8 +16,7 @@ function getFilters(params) { if(urlParams.get(key)){ if(key == "f_status"){ filters[key.slice(2)] = JSON.parse(urlParams.get(key)) - } - else filters[key.slice(2)] = urlParams.get(key).split(",").map(i=>Number(i)) + }else filters[key.slice(2)] = urlParams.get(key).split(",").map(i => i !== 'null' ? Number(i) : null) } } return filters diff --git a/hypha/static_src/src/app/src/redux/actions/submissions.js b/hypha/static_src/src/app/src/redux/actions/submissions.js index 251bc054f79f06ecf4e60f9ea544a1ce66d0c229..a64ff3c8650d62219c22e64977df410e6a2a532f 100644 --- a/hypha/static_src/src/app/src/redux/actions/submissions.js +++ b/hypha/static_src/src/app/src/redux/actions/submissions.js @@ -214,13 +214,13 @@ export const setSubmissionParam = (id) => (dispatch, getState) => { const urlParams = new URLSearchParams(state.router.location.search); const urlID = Number(urlParams.get('submission')); - // check whether filters available & create searchParams accordingly + // check whether filters selected & create searchParams accordingly let searchParams = "" if(filters && filters.length){ filters.forEach(filter => { if(filter.key == "f_status"){ - searchParams = searchParams + `&${filter.key}=${JSON.stringify(filter.value)}` - }else searchParams = searchParams + `&${filter.key}=${filter.value.join()}` + searchParams = searchParams + `&${filter.key}=${JSON.stringify(filter.value)}` + }else searchParams = searchParams + `&${filter.key}=${filter.value.map(v => !v ? "null" : v).join()}` }) } @@ -229,15 +229,18 @@ export const setSubmissionParam = (id) => (dispatch, getState) => { const shouldUpdate = id !== null && submissionID !== id && urlID !== id && !(submissionID == null && urlParams.toString().includes("&")); // if url contains filter query & it is shared, don't update id - // check both url query parmas & filters are equal - const queryUpdate = (filters && - filters.filter(filter => urlParams.get(filter.key) === null || - filter.value.length !== urlParams.get(filter.key).split(',').length).length) || - urlParams.toString().includes("&") && filters != null && !filters.length || - urlParams.toString().includes("&") && filters != null && filters.length - && searchParams.split("&").length != urlParams.toString().split("&").length + + function hasEqualFilters(filter) { + if(filter.key === "f_status") return urlParams.get(filter.key) !== JSON.stringify(filter.value) + else return urlParams.get(filter.key) !== filter.value.join(',') + } - if (shouldSet || shouldUpdate || queryUpdate) { + const hasEqualNoOfFilters = searchParams.split("&").length == urlParams.toString().split("&").length + + // check url query parmas are same as filters selected + const shouldUpdateURLQuery = filters && (filters.filter(hasEqualFilters).length || !hasEqualNoOfFilters) + + if (shouldSet || shouldUpdate || Boolean(shouldUpdateURLQuery)) { dispatch(push({search: `?submission=${id}${searchParams}`})); }else if (id === null ) { dispatch(clearCurrentSubmissionParam());