Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import React from 'react'
import { omit } from 'lodash'
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
import { Button, H3, Icon } from '@pubsweet/ui'
import { B } from '../ui'
import { SubmissionTypes } from '../upload-files'
import PubMedSearch from '../citation-search'
import { FileThumbnails } from '../preview-files'
import { NoteMutations } from '../SubmissionMutations'
import GrantSearch from '../GrantSearch'
import Citation from './Citation'
import SelectReviewer from './SelectReviewer'
import SubmitHighlights from './SubmitHighlights'
const ReviewerWithMutations = NoteMutations(SelectReviewer)
const PubMedWithMutations = NoteMutations(PubMedSearch)
const ErrorMessage = styled.p`
color: ${th('colorError')};
font-size: ${th('fontSizeBaseSmall')};
display: flex;
align-items: flex-start;
margin-left: calc(-${th('gridUnit')} / 2);
`
const formatName = name =>
`${name.title ? `${name.title} ` : ''}${name.givenNames} ${name.surname}`
const submitSections = (
manuscript,
checkDupes,
changeCitation,
currentUser,
highlights,
pruneDupes,
updateEmbargo,
updateGrants,
) => {
const { id: mId, meta, journal, files: allfiles, status, teams } = manuscript
if (teams && allfiles) {
const {
fundingGroup: grants,
releaseDelay = '',
unmatchedJournal,
notes,
} = meta
const fundingGroup = grants
? grants.map(g => {
const n = omit(g, '__typename')
n.pi = omit(g.pi, '__typename')
return n
})
: []
const files = allfiles
? allfiles.filter(
file =>
!file.type ||
file.type === 'manuscript' ||
SubmissionTypes.some(t => t.value === file.type),
)
: []
const reviewerNote = notes
? notes.find(n => n.notesType === 'selectedReviewer')
: null
let reviewer = null
if (teams && teams.find(team => team.role === 'reviewer')) {
const rev = teams.find(team => team.role === 'reviewer').teamMembers[0]
reviewer = {
id: rev.user.id,
name: rev.alias.name,
}
}
const selectedReviewer = reviewerNote
? JSON.parse(reviewerNote.content)
: reviewer
const submitter =
teams && teams.find(team => team.role === 'submitter')
? teams.find(team => team.role === 'submitter').teamMembers[0]
: null
const dupeNote = notes
? notes.find(n => n.notesType === 'notDuplicates')
: null
const notDupes = dupeNote ? JSON.parse(dupeNote.content) : []
const duplicates = checkDupes.filter(d => !notDupes.includes(d.id))
const citationInformation = {
title: 'Citation',
content: <Citation journal={journal} metadata={meta} />,
edit: (
<div data-citation>
<H3>Citation</H3>
<PubMedWithMutations
citationData={changeCitation}
manuscript={manuscript}
/>
</div>
),
error:
(currentUser.admin && status === 'submitted' && unmatchedJournal) ||
duplicates.length > 0 ? (
<React.Fragment>
{unmatchedJournal && (
<ErrorMessage>
<Icon color="currentColor" size={2}>
alert_circle
</Icon>
Journal is not in the NLM Catalog.
</ErrorMessage>
)}
{duplicates.length > 0 && (
<React.Fragment>
<Button onClick={() => pruneDupes()} primary>
Resolve duplicates
</Button>
<ErrorMessage>
<Icon color="currentColor" size={2}>
alert_circle
</Icon>
Submission is likely a duplicate.
</ErrorMessage>
</React.Fragment>
)}
</React.Fragment>
) : null,
}
const manuscriptFiles = {
title: 'Files',
content: <FileThumbnails files={files} />,
edit: <div data-upload />,
error:
files &&
files
.filter(
file =>
!file.type || SubmissionTypes.some(s => s.value === file.type),
)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
.some(file => !file.label || !file.type) ? (
<ErrorMessage>
<Icon color="currentColor" size={2}>
alert_circle
</Icon>
All files must have a type and a label.
</ErrorMessage>
) : null,
}
const fundingInfo = {
title: 'Funding',
content: (
<div>
{fundingGroup && fundingGroup.length > 0 && (
<p>
<B>Grants: </B>
{fundingGroup.map((f, t) => (
<span key={f.awardId}>
{`${f.fundingSource} ${f.awardId}`}
{t !== fundingGroup.length - 1 && ', '}
</span>
))}
</p>
)}
{(releaseDelay || typeof releaseDelay === 'number') && (
<p>
<B>Embargo: </B>
{`${releaseDelay} month${
parseInt(releaseDelay, 10) === 1 ? '' : 's'
}`}
</p>
)}
</div>
),
edit: (
<GrantSearch
changedEmbargo={updateEmbargo}
changedGrants={updateGrants}
selectedEmbargo={releaseDelay}
selectedGrants={fundingGroup}
/>
),
error:
!fundingGroup || fundingGroup.length === 0 || !releaseDelay ? (
<ErrorMessage>
<Icon color="currentColor" size={2}>
alert_circle
</Icon>
{(!fundingGroup || fundingGroup.length === 0) &&
'Grants from Europe PMC Funders must be listed.'}
{(!fundingGroup || fundingGroup.length === 0) && !releaseDelay && (
<br />
)}
{!releaseDelay && 'Embargo period must be set.'}
</ErrorMessage>
) : null,
}
const reviewerSelect = {
title: 'Reviewer',
content: selectedReviewer && (
<p>
{selectedReviewer.id && submitter.user.id === selectedReviewer.id ? (
`Manuscript Submitter (${formatName(submitter.alias.name)})`
) : (
<React.Fragment>
{formatName(selectedReviewer.name)}
{selectedReviewer.id &&
currentUser.id === selectedReviewer.id &&
' (Me)'}
</React.Fragment>
)}
</p>
),
edit:
!reviewer || currentUser.id !== reviewer.id ? (
<ReviewerWithMutations
currentUser={currentUser}
funding={fundingGroup}
manuscriptId={mId}
reviewer={reviewer}
reviewerNote={reviewerNote}
submitter={submitter}
/>
) : null,
error: !selectedReviewer && (
<ErrorMessage>
<Icon color="currentColor" size={2}>
alert_circle
</Icon>
Reviewer must be indicated.
</ErrorMessage>
),
}
const sections = [
citationInformation,
manuscriptFiles,
fundingInfo,
reviewerSelect,
]
const highlightTerms = {
title: 'Referenced attachments',
content: <SubmitHighlights highlights={highlights} />,
edit: '',
error: '',
}
if (currentUser.admin && status === 'submitted') {
sections.splice(2, 0, highlightTerms)
}
return sections
}
}
export default submitSections