Commit 9df95838 authored by Yannis Barlas's avatar Yannis Barlas

feat(dashboard): order articles by last updated

parent 1f556f20
...@@ -10,6 +10,7 @@ const GET_DASHBOARD_ARTICLES = gql` ...@@ -10,6 +10,7 @@ const GET_DASHBOARD_ARTICLES = gql`
query GetDashboardArticles($currentUserId: ID!) { query GetDashboardArticles($currentUserId: ID!) {
dashboardArticles(currentUserId: $currentUserId) { dashboardArticles(currentUserId: $currentUserId) {
author { author {
created
id id
status { status {
decision { decision {
...@@ -33,12 +34,14 @@ const GET_DASHBOARD_ARTICLES = gql` ...@@ -33,12 +34,14 @@ const GET_DASHBOARD_ARTICLES = gql`
} }
} }
title title
updated
} }
editor { editor {
assignedEditor { assignedEditor {
id id
username username
} }
created
id id
status { status {
decision { decision {
...@@ -62,6 +65,7 @@ const GET_DASHBOARD_ARTICLES = gql` ...@@ -62,6 +65,7 @@ const GET_DASHBOARD_ARTICLES = gql`
} }
} }
title title
updated
} }
isGlobal isGlobal
reviewer { reviewer {
...@@ -71,6 +75,7 @@ const GET_DASHBOARD_ARTICLES = gql` ...@@ -71,6 +75,7 @@ const GET_DASHBOARD_ARTICLES = gql`
name name
} }
comments comments
created
datatype datatype
funding funding
geneExpression { geneExpression {
...@@ -176,6 +181,7 @@ const GET_DASHBOARD_ARTICLES = gql` ...@@ -176,6 +181,7 @@ const GET_DASHBOARD_ARTICLES = gql`
references references
reviewerStatus reviewerStatus
title title
updated
} }
} }
} }
......
/* eslint-disable react/prop-types */
import React from 'react'
import styled from 'styled-components'
import { DateParser } from '@pubsweet/ui'
import { th } from '@pubsweet/ui-toolkit'
const Wrapper = styled.span`
font-family: ${th('fontInterface')};
font-size: ${th('fontSizeBaseSmall')};
line-height: ${th('lineHeighBaseSmall')};
`
const Label = styled.span`
color: ${th('colorBorder')};
margin-right: calc(${th('gridUnit')} / 2);
text-transform: capitalize;
&:before {
content: '\\2014';
padding: 0 ${th('gridUnit')};
}
&:after {
content: ':';
}
`
const Date = props => {
const { label, value } = props
return (
<Wrapper>
<Label>{label}</Label>
<DateParser humanizeThreshold={3} timestamp={value}>
{timestamp => <span>{timestamp}</span>}
</DateParser>
</Wrapper>
)
}
export default Date
...@@ -2,34 +2,35 @@ ...@@ -2,34 +2,35 @@
import React from 'react' import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { uniqueId } from 'lodash'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
import { SectionItem, StatusItem } from './index' import DashboardItemDate from './DashboardItemDate'
import StatusItem from './StatusItem'
import SectionItem from './SectionItem'
const StatusRow = styled.div` const StatusRowWrapper = styled.div`
display: flex; display: flex;
margin-bottom: calc(${th('gridUnit')}); margin-bottom: calc(${th('gridUnit')});
` `
const SectionItemWithStatus = props => { const StatusRow = props => {
const { actionsComponent, status, title } = props const { status, updated } = props
// const event = { date: new Date() } return (
const event = null <StatusRowWrapper>
const statusItems = [status, event] <StatusItem status={status} />
{updated && <DashboardItemDate label="Last updated" value={updated} />}
</StatusRowWrapper>
)
}
const SectionItemWithStatus = props => {
const { actionsComponent, status, title, updated } = props
return ( return (
<React.Fragment> <React.Fragment>
<StatusRow> <StatusRow status={status} updated={updated} />
{statusItems.map(i => {
if (!i) return null
if (!i.date) return <StatusItem key={uniqueId()} status={i} />
return <StatusItem key={uniqueId()} label={i.date.toString()} />
})}
</StatusRow>
<SectionItem rightComponent={actionsComponent} title={title} /> <SectionItem rightComponent={actionsComponent} title={title} />
</React.Fragment> </React.Fragment>
) )
......
...@@ -7,6 +7,7 @@ import { th } from '@pubsweet/ui-toolkit' ...@@ -7,6 +7,7 @@ import { th } from '@pubsweet/ui-toolkit'
import { getCurrentStatus } from '../../helpers/status' import { getCurrentStatus } from '../../helpers/status'
const StatusLabel = styled.span` const StatusLabel = styled.span`
align-self: center;
color: ${props => { color: ${props => {
if (props.decision) { if (props.decision) {
const { accepted, rejected, revise } = props.decision const { accepted, rejected, revise } = props.decision
...@@ -17,10 +18,8 @@ const StatusLabel = styled.span` ...@@ -17,10 +18,8 @@ const StatusLabel = styled.span`
return th('colorFurniture') return th('colorFurniture')
}}; }};
font-size: ${th('fontSizeBaseSmall')}; font-size: ${th('fontSizeBaseSmall')};
line-height: ${th('lineHeightBaseSmall')}; line-height: ${th('lineHeightBaseSmall')};
margin: 0 calc(${th('gridUnit')}) 0 0;
text-transform: uppercase; text-transform: uppercase;
` `
......
...@@ -162,7 +162,7 @@ const resolvers = { ...@@ -162,7 +162,7 @@ const resolvers = {
async dashboardArticles(_, { currentUserId }, context) { async dashboardArticles(_, { currentUserId }, context) {
const { connectors } = context const { connectors } = context
const articles = await Manuscript.query() const articles = await Manuscript.query().orderBy('updated', 'desc')
const currentUser = await User.find(currentUserId) const currentUser = await User.find(currentUserId)
const reviews = await Review.all() const reviews = await Review.all()
const teams = await Team.all() const teams = await Team.all()
......
...@@ -21,16 +21,20 @@ const typeDefs = ` ...@@ -21,16 +21,20 @@ const typeDefs = `
} }
type AuthorArticle { type AuthorArticle {
created: String
id: ID id: ID
status: Status status: Status
title: String title: String
updated: String
} }
type EditorArticle { type EditorArticle {
assignedEditor: User assignedEditor: User
created: String
id: ID id: ID
status: Status status: Status
title: String title: String
updated: String
} }
type HistoryEntry { type HistoryEntry {
......
...@@ -46,6 +46,7 @@ const typeDefs = ` ...@@ -46,6 +46,7 @@ const typeDefs = `
acknowledgements: String acknowledgements: String
authors: [Author] authors: [Author]
comments: String comments: String
created: String
datatype: String datatype: String
funding: String funding: String
geneExpression: GeneExpression geneExpression: GeneExpression
...@@ -57,6 +58,7 @@ const typeDefs = ` ...@@ -57,6 +58,7 @@ const typeDefs = `
references: String references: String
reviewerStatus: String reviewerStatus: String
title: String title: String
updated: String
} }
extend type DashboardArticles { extend type DashboardArticles {
......
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