diff --git a/hypha/apply/funds/templates/funds/submissions.html b/hypha/apply/funds/templates/funds/submissions.html index 0ed85d1e4044ef43e383b0c5f021a3c6219562c7..5344620603f5266e5ce47666b90ff79a9129c27f 100644 --- a/hypha/apply/funds/templates/funds/submissions.html +++ b/hypha/apply/funds/templates/funds/submissions.html @@ -1,6 +1,8 @@ {% extends "funds/base_submissions_table.html" %} -{% block title %}Submissions{% endblock %} +{% load static %} +{% load render_bundle from webpack_loader %} +{% block title %}Submissions{% endblock %} {% block content %} <div class="admin-bar"> <div class="admin-bar__inner wrapper--search"> @@ -8,13 +10,17 @@ <div> <h1 class="gamma heading heading--no-margin heading--bold">All Submissions</h1> </div> + <div id="submissions-all-react-app-switcher"></div> {% endblock %} </div> </div> -<div class="wrapper wrapper--large wrapper--inner-space-medium"> - {% block table %} - {{ block.super }} - {% endblock %} +<div id="submissions-all-react-app"> + <div class="wrapper wrapper--large wrapper--inner-space-medium"> + {% block table %} + {{ block.super }} + {% endblock %} + </div> </div> +{% render_bundle 'allSubmissions' %} {% endblock %} diff --git a/hypha/static_src/src/app/src/AllSubmissionsApp.js b/hypha/static_src/src/app/src/AllSubmissionsApp.js new file mode 100644 index 0000000000000000000000000000000000000000..29eedf97b8bad6571d565c5bcadfa0d7fadc597f --- /dev/null +++ b/hypha/static_src/src/app/src/AllSubmissionsApp.js @@ -0,0 +1,46 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { hot } from 'react-hot-loader'; +import { connect } from 'react-redux' +import SwitcherApp from './SwitcherApp'; +import GroupByRoundDetailView from '@containers/GroupByRoundDetailView'; +import { setCurrentStatuses } from '@actions/submissions'; +import { + getSubmissionsForListing, +} from '@selectors/submissions'; + +class AllSubmissionsApp extends React.Component { + static propTypes = { + pageContent: PropTypes.node.isRequired, + setStatuses: PropTypes.func.isRequired, + submissions: PropTypes.array + }; + + + componentDidMount() { + this.props.setStatuses([]); + } + + render() { + return ( + <SwitcherApp + detailComponent={<GroupByRoundDetailView submissions= {this.props.submissions} groupBy = "all"/>} + switcherSelector={'submissions-all-react-app-switcher'} + pageContent={this.props.pageContent} /> + ) + } +} + +const mapStateToProps = (state, ownProps) => ({ + submissions: getSubmissionsForListing(state), +}) + +const mapDispatchToProps = dispatch => { + return { + setStatuses: statuses => {dispatch(setCurrentStatuses(statuses));}, + } +}; + +export default hot(module)( + connect(mapStateToProps, mapDispatchToProps)(AllSubmissionsApp) +); diff --git a/hypha/static_src/src/app/src/SubmissionsByStatusApp.js b/hypha/static_src/src/app/src/SubmissionsByStatusApp.js index 90c6b8989f4665e129841af6da44a87134142410..3b9325b678ba83a0d7964f32b122460934850c0b 100644 --- a/hypha/static_src/src/app/src/SubmissionsByStatusApp.js +++ b/hypha/static_src/src/app/src/SubmissionsByStatusApp.js @@ -6,6 +6,7 @@ import { connect } from 'react-redux' import GroupByRoundDetailView from '@containers/GroupByRoundDetailView'; import { setCurrentStatuses } from '@actions/submissions'; +import { getCurrentStatusesSubmissions } from '@selectors/submissions'; class SubmissionsByStatusApp extends React.Component { @@ -13,6 +14,7 @@ class SubmissionsByStatusApp extends React.Component { pageContent: PropTypes.node.isRequired, statuses: PropTypes.arrayOf(PropTypes.string), setStatuses: PropTypes.func.isRequired, + submissions: PropTypes.array }; componentDidMount() { @@ -21,19 +23,24 @@ class SubmissionsByStatusApp extends React.Component { render() { return <SwitcherApp - detailComponent={<GroupByRoundDetailView />} + detailComponent={<GroupByRoundDetailView submissions= {this.props.submissions}/>} switcherSelector={'submissions-by-status-app-react-switcher'} pageContent={this.props.pageContent} />; } } +const mapStateToProps = (state, ownProps) => ({ + submissions: getCurrentStatusesSubmissions(state), +}) + const mapDispatchToProps = dispatch => { return { - setStatuses: statuses => {dispatch(setCurrentStatuses(statuses));}, + setStatuses: statuses => {dispatch(setCurrentStatuses(statuses)); + }, } }; export default hot(module)( - connect(null, mapDispatchToProps)(SubmissionsByStatusApp) + connect(mapStateToProps, mapDispatchToProps)(SubmissionsByStatusApp) ); diff --git a/hypha/static_src/src/app/src/allSubmissionsIndex.js b/hypha/static_src/src/app/src/allSubmissionsIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..728a687510d82ce5d80ee345f7c7e70ab5fa8b77 --- /dev/null +++ b/hypha/static_src/src/app/src/allSubmissionsIndex.js @@ -0,0 +1,24 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import Modal from 'react-modal'; +import { Provider } from 'react-redux'; +import { ConnectedRouter } from 'connected-react-router'; + +import AllSubmissionsApp from './AllSubmissionsApp'; +import createStore, { history } from '@redux/store'; + + +const container = document.getElementById('submissions-all-react-app'); + +const store = createStore(); + +Modal.setAppElement(container) + +ReactDOM.render( + <Provider store={store}> + <ConnectedRouter history={history}> + <AllSubmissionsApp pageContent={container.innerHTML}/> + </ConnectedRouter> + </Provider>, + container +); diff --git a/hypha/static_src/src/app/src/components/GroupedListing/index.js b/hypha/static_src/src/app/src/components/GroupedListing/index.js index 43c72b22d8682ff2491d1e3f293949e65e9f6a11..76e2ca23ce3896b52fe69ddee93f2e8fc1919a73 100644 --- a/hypha/static_src/src/app/src/components/GroupedListing/index.js +++ b/hypha/static_src/src/app/src/components/GroupedListing/index.js @@ -113,7 +113,6 @@ export default class GroupedListing extends React.Component { render() { const { isLoading, isErrored, errorMessage } = this.props; - const passProps = { items: this.state.orderedItems, renderItem: this.renderItem, diff --git a/hypha/static_src/src/app/src/components/GroupedListing/styles.scss b/hypha/static_src/src/app/src/components/GroupedListing/styles.scss index db881d048ddc84149bf98a527dde386dd036aba3..225412a6f1618f0656f7917834a91d61a6da1695 100644 --- a/hypha/static_src/src/app/src/components/GroupedListing/styles.scss +++ b/hypha/static_src/src/app/src/components/GroupedListing/styles.scss @@ -2,7 +2,6 @@ height: 100vh; display: flex; flex-direction: column; - @include media-query(tablet-landscape) { height: calc(100vh - var(--header-admin-height)); } diff --git a/hypha/static_src/src/app/src/containers/ByRoundListing.js b/hypha/static_src/src/app/src/containers/ByRoundListing.js index e9d1778f64b742a3b74f09c4ecde5e96577d234b..08921582905741a7760f3a5054ebcbe79fd1ba83 100644 --- a/hypha/static_src/src/app/src/containers/ByRoundListing.js +++ b/hypha/static_src/src/app/src/containers/ByRoundListing.js @@ -16,6 +16,7 @@ import { import { getCurrentSubmissionID, getCurrentStatusesSubmissions, + getSubmissionsForListing, } from '@selectors/submissions'; import { getCurrentStatuses, @@ -23,7 +24,6 @@ import { getByStatusesError, } from '@selectors/statuses'; - const loadData = props => { props.loadRounds() props.loadSubmissions() @@ -89,9 +89,9 @@ class ByRoundListing extends React.Component { } } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state, ownProps) => ({ statuses: getCurrentStatuses(state), - submissions: getCurrentStatusesSubmissions(state), + submissions: ownProps.groupBy ? getSubmissionsForListing(state) :getCurrentStatusesSubmissions(state), isErrored: getRoundsErrored(state) || getByStatusesError(state), isLoading: ( getByStatusesLoading(state) || diff --git a/hypha/static_src/src/app/src/containers/GroupByRoundDetailView.js b/hypha/static_src/src/app/src/containers/GroupByRoundDetailView.js index a5492c4afdc14f771b14db0b0a500ea8ab6151ea..a49804989d96d953b5b75cb0df0f553d4a98ea8c 100644 --- a/hypha/static_src/src/app/src/containers/GroupByRoundDetailView.js +++ b/hypha/static_src/src/app/src/containers/GroupByRoundDetailView.js @@ -9,7 +9,6 @@ import { getRoundsErrored, } from '@selectors/rounds' import { - getCurrentStatusesSubmissions, getCurrentSubmissionID, } from '@selectors/submissions'; import { @@ -18,17 +17,16 @@ import { } from '@selectors/statuses'; const GroupByRoundDetailView = props => { - const listing = <ByRoundListing submissionStatuses={props.submissionStatuses} /> + const listing = <ByRoundListing submissionStatuses={props.submissionStatuses} groupBy = {props.groupBy && props.groupBy}/> const { isLoading, isErrored, submissions, submissionID, errorMessage } = props const isEmpty = submissions.length === 0 - const activeSubmision = !!submissionID - + const activeSubmission = !!submissionID return ( <DetailView isEmpty={isEmpty} listing={listing} isLoading={isLoading} - showSubmision={activeSubmision} + showSubmision={activeSubmission} isErrored={isErrored} errorMessage={errorMessage} /> @@ -42,6 +40,7 @@ GroupByRoundDetailView.propTypes = { isLoading: PropTypes.bool, isErrored: PropTypes.bool, errorMessage: PropTypes.string, + groupBy: PropTypes.string } const mapStateToProps = (state, ownProps) => ({ @@ -49,7 +48,6 @@ const mapStateToProps = (state, ownProps) => ({ isLoading: ( getByStatusesLoading(state) || getRoundsFetching(state) ), - submissions: getCurrentStatusesSubmissions(state), submissionID: getCurrentSubmissionID(state), }) diff --git a/hypha/static_src/src/app/src/containers/ReviewInformation.js b/hypha/static_src/src/app/src/containers/ReviewInformation.js index 0ccd9e89949b2649e9423dfd79d9e7bad07b33fc..12ffb818501b010a5df28ac0cdf00611ad0f66f2 100644 --- a/hypha/static_src/src/app/src/containers/ReviewInformation.js +++ b/hypha/static_src/src/app/src/containers/ReviewInformation.js @@ -162,7 +162,7 @@ const ReviewInformation = ({ submission, submissionID, showReviewForm, toggleRev ReviewInformation.propTypes = { submission: PropTypes.object, - submissionID: PropTypes.number.isRequired, + submissionID: PropTypes.number, showReviewForm: PropTypes.bool, reviewDraftStatus: PropTypes.bool, toggleReviewForm: PropTypes.func, diff --git a/hypha/static_src/src/app/src/containers/ScreeningStatus/index.js b/hypha/static_src/src/app/src/containers/ScreeningStatus/index.js index 39918ba31180515627273cf5db3be06c2f2e9cce..a446e73f7faef282fe4dd2c1bd162f2ff9d13876 100644 --- a/hypha/static_src/src/app/src/containers/ScreeningStatus/index.js +++ b/hypha/static_src/src/app/src/containers/ScreeningStatus/index.js @@ -88,7 +88,7 @@ class ScreeningStatusContainer extends React.PureComponent { label={option.title} variant={!option.selected ? "outlined" : "default"} key={option.id} - icon={option.selected && <DoneIcon />} + icon={option.selected ? <DoneIcon /> : null} onClick={() => selectVisibleOption(submissionID, option)}> </Chip>) } diff --git a/hypha/static_src/src/app/src/containers/StatusActions.js b/hypha/static_src/src/app/src/containers/StatusActions.js index 1f8de8db3e817313206abf4deb4be0552b509320..7f926bfa39cc74b13d26e2dd418e8a6e5aae0b01 100644 --- a/hypha/static_src/src/app/src/containers/StatusActions.js +++ b/hypha/static_src/src/app/src/containers/StatusActions.js @@ -15,7 +15,7 @@ import './StatusActions.scss'; class StatusActions extends React.Component { static propTypes = { - submissionID: PropTypes.number.isRequired, + submissionID: PropTypes.number, submission: PropTypes.shape({ id: PropTypes.number, phase: PropTypes.string, 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 919c442f348b11297b23536001e5a351deaa38bb..cfd39dd91d05154d2cf1f37826573782d7f0eb78 100644 --- a/hypha/static_src/src/app/src/redux/actions/submissions.js +++ b/hypha/static_src/src/app/src/redux/actions/submissions.js @@ -105,7 +105,7 @@ export const clearCurrentDeterminationAction = () => ({ export const fetchReviewDraft = (submissionID) => ({ [CALL_API]: { - types: [ START_LOADING_SUBMISSION, FETCH_REVIEW_DRAFT, FAIL_LOADING_SUBMISSION], + types: [ START_LOADING_SUBMISSION, FETCH_REVIEW_DRAFT, CLEAR_REVIEW_DRAFT], endpoint: api.fetchReviewDraft(submissionID), }, submissionID, diff --git a/hypha/static_src/src/app/src/redux/selectors/statuses.js b/hypha/static_src/src/app/src/redux/selectors/statuses.js index ff17929c7c7242b7c34cd566814fb1d6416ae6f1..70344be7e8d75aa7c6db17be17064a596faaf825 100644 --- a/hypha/static_src/src/app/src/redux/selectors/statuses.js +++ b/hypha/static_src/src/app/src/redux/selectors/statuses.js @@ -11,6 +11,13 @@ const getSubmissionsByStatuses = state => state.statuses.byStatuses; const getSubmissionIDsForCurrentStatuses = createSelector( [ getSubmissionsByStatuses, getCurrentStatuses ], (grouped, current) => { + if (!current.length){ + let acc = [] + for (let status in grouped){ + acc = acc.concat(grouped[status]) + } + return acc + } return current.reduce((acc, status) => acc.concat(grouped[status] || []), []) } ); diff --git a/hypha/static_src/src/app/src/redux/selectors/submissions.js b/hypha/static_src/src/app/src/redux/selectors/submissions.js index 5bcb0d6f9a0cc79db6f5b09bc814ab36f750d335..360c9adb3a9e3650865991be4a188786edf837fb 100644 --- a/hypha/static_src/src/app/src/redux/selectors/submissions.js +++ b/hypha/static_src/src/app/src/redux/selectors/submissions.js @@ -24,6 +24,8 @@ const getCurrentDetermination = state => state.submissions.currentDetermination; const getDeterminationDraftStatus = state => state.submissions.isDeterminationDraftExist; +const getSubmissionsForListing = state => Object.values(state.submissions.byID) + const getCurrentRoundSubmissions = createSelector( [ getCurrentRoundSubmissionIDs, getSubmissions], @@ -61,6 +63,8 @@ const getSubmissionsByRoundError = state => state.rounds.error; const getSubmissionsByRoundLoadingState = state => state.submissions.itemsLoading === true; export { + getSubmissions, + getSubmissionsForListing, getCurrentRoundSubmissions, getCurrentSubmission, getCurrentSubmissionID, diff --git a/hypha/static_src/src/app/webpack.base.config.js b/hypha/static_src/src/app/webpack.base.config.js index 96429b96707987cfbe03220eb4359dc54ae0c074..91f22855e20eff1361d5954292b76255e8d9dd41 100644 --- a/hypha/static_src/src/app/webpack.base.config.js +++ b/hypha/static_src/src/app/webpack.base.config.js @@ -15,6 +15,7 @@ module.exports = (webpackEnv) => { entry: { submissionsByRound: COMMON_ENTRY.concat(['./src/submissionsByRoundIndex']), submissionsByStatus: COMMON_ENTRY.concat(['./src/submissionsByStatusIndex']), + allSubmissions: COMMON_ENTRY.concat(['./src/allSubmissionsIndex']) }, output: {