Commit 0d6915cc authored by nickstiffler's avatar nickstiffler Committed by Yannis Barlas

feat(dashboard): filter by status in editor section

parent 6cfbc3a4
......@@ -17,6 +17,7 @@ import ComposedDashboard from './compose/Dashboard'
import Loading from './Loading'
import { DASHBOARD_MANUSCRIPTS } from './compose/pieces/dashboardManuscripts'
import { CURRENT_USER } from './Private'
import Select from './ui/Select'
const SubmitButton = props => {
const { client, createManuscript, currentUser, history } = props
......@@ -86,6 +87,53 @@ const Dashboard = props => {
const isEditor = currentUser.auth.isGlobalEditor
const isScienceOfficer = currentUser.auth.isGlobalScienceOfficer
const options = [
{
label: 'Submitted- Needs Triage',
value: 'submitted- needs triage',
},
{
label: 'Datatype Selected',
value: 'datatype selected',
},
{
label: 'Submitted',
value: 'submitted',
},
{
label: 'Approved By Science Officer',
value: 'approved by science officer',
},
{
label: 'Not Approved By Science Officer',
value: 'not approved by science officer',
},
{
label: 'Reviewer Invited',
value: 'reviewer invited',
},
{
label: 'Reviewer Accepted',
value: 'reviewer accepted',
},
{
label: 'Review Submitted',
value: 'review submitted',
},
{
label: 'Under Revision',
value: 'under revision',
},
{
label: 'Accepted',
value: 'accepted',
},
{
label: 'Rejected',
value: 'rejected',
},
]
const headerActions = [
<SubmitButton
client={client}
......@@ -96,10 +144,21 @@ const Dashboard = props => {
/>,
]
const storedStatuses = localStorage.getItem('selectedStatuses')
? JSON.parse(localStorage.getItem('selectedStatuses'))
: []
return (
<State initial={{ previewData: null, showModal: false }}>
<State
initial={{
filteredArticles: editorArticles,
previewData: null,
savedStatuses: storedStatuses,
showModal: false,
}}
>
{({ state, setState }) => {
const { previewData, showModal } = state
const { previewData, showModal, savedStatuses } = state
const openModal = article =>
setState({
......@@ -118,6 +177,35 @@ const Dashboard = props => {
openModal(article)
}
const filterArticles = selectedStatuses => {
localStorage.setItem(
'selectedStatuses',
JSON.stringify(selectedStatuses),
)
setState({ savedStatuses: selectedStatuses })
if (selectedStatuses.length > 0) {
const filteredArticles = editorArticles.filter(article =>
selectedStatuses
.map(s => s.value)
.includes(article.displayStatus),
)
setState({ filteredArticles })
} else {
setState({ filteredArticles: editorArticles })
}
}
const editorActions = [
<Select
closeMenuOnSelect={false}
isMulti
onChange={filterArticles}
options={options}
placeholder="Filter By Status"
value={savedStatuses}
/>,
]
return (
<React.Fragment>
<DashboardWrapper>
......@@ -139,10 +227,11 @@ const Dashboard = props => {
{(isEditor || isAdmin) && (
<Section
actions={editorActions}
allEditors={allEditors}
allScienceOfficers={allScienceOfficers}
itemComponent={EditorSectionItem}
items={editorArticles}
items={state.filteredArticles}
label="Editor Section"
updateAssignedEditor={updateAssignedEditor}
updateAssignedScienceOfficer={updateAssignedScienceOfficer}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment