Commit d0f21e9b authored by Audrey Hamelers's avatar Audrey Hamelers
parent 56c199f1
Pipeline #12977 passed with stages
in 5 minutes and 47 seconds
......@@ -8,6 +8,7 @@ import { Portal, Buttons, CloseModal, Notification } from '../ui'
import { ManuscriptMutations, NoteMutations } from '../SubmissionMutations'
import SubmissionCancel from '../SubmissionCancel'
import ResolveDuplicates from '../ResolveDuplicates'
import ReviewerEdit from './ReviewerEdit'
import CitationEdit from './CitationEdit'
import GrantsEdit from './GrantsEdit'
import EmbargoEdit from './EmbargoEdit'
......@@ -48,11 +49,13 @@ const RecoverButton = ({ callback, recoverMan }) => (
)
const DuplicatesWithMutations = NoteMutations(ResolveDuplicates)
const ReviewerWithMutations = NoteMutations(ReviewerEdit)
const MetaEdit = withTheme(
({
theme,
close,
currentUser,
duplicates,
lastStatus,
linkAndDelete,
......@@ -80,6 +83,12 @@ const MetaEdit = withTheme(
duplicates={duplicates}
manuscript={manuscript}
note={notes ? notes.find(n => n.notesType === 'notDuplicates') : null}
refetch={[
{
query: QUERY_ACTIVITY_INFO,
variables: { id: manuscript.id },
},
]}
/>
)
}
......@@ -106,6 +115,20 @@ const MetaEdit = withTheme(
embargo={releaseDelay}
/>
)
case 'reviewer':
return (
<ReviewerWithMutations
close={close}
currentUser={currentUser}
manuscript={manuscript}
refetch={[
{
query: QUERY_ACTIVITY_INFO,
variables: { id: manuscript.id },
},
]}
/>
)
case 'citation':
return (
<CitationEdit
......
......@@ -146,6 +146,11 @@ class MetaSec extends React.Component {
const { title: rt, givenNames: rg, surname: rs } = reviewer
? reviewer.teamMembers[0].alias.name
: ''
const reviewerNote =
notes &&
notes.find(n => n.notesType === 'selectedReviewer') &&
JSON.parse(notes.find(n => n.notesType === 'selectedReviewer').content)
const rnName = reviewerNote && reviewerNote.name
const auditInfo = audits.reduce((info, audit) => {
if (!info.timeInProcess) {
info.timeInProcess = moment(audit.created).fromNow(true)
......@@ -227,26 +232,60 @@ class MetaSec extends React.Component {
)}
</Heading>
<Container>
{reviewer &&
reviewer.teamMembers[0].user.id ===
submitter.teamMembers[0].user.id ? (
<DL>
<dt>Submitter/Reviewer:</dt>
<dd>{`${st ? `${st} ` : ''}${sg} ${ss}`}</dd>
</DL>
) : (
{reviewerNote ? (
<React.Fragment>
<DL>
<dt>Submitter:</dt>
<dd>{`${st ? `${st} ` : ''}${sg} ${ss}`}</dd>
</DL>
{reviewer && (
{rnName && (
<DL>
<dt>Reviewer:</dt>
<dd>{`${rt ? `${rt} ` : ''}${rg} ${rs}`}</dd>
<dt>Invited reviewer:</dt>
<dd>
{`${rnName.givenNames} ${rnName.surname}`}
<Action onClick={() => this.setState({ edit: 'reviewer' })}>
<EditIcon />
</Action>
</dd>
</DL>
)}
</React.Fragment>
) : (
<React.Fragment>
{reviewer &&
reviewer.teamMembers[0].user.id ===
submitter.teamMembers[0].user.id ? (
<DL>
<dt>Submitter/Reviewer:</dt>
<dd>
{`${st ? `${st} ` : ''}${sg} ${ss}`}
<Action onClick={() => this.setState({ edit: 'reviewer' })}>
<EditIcon />
</Action>
</dd>
</DL>
) : (
<React.Fragment>
<DL>
<dt>Submitter:</dt>
<dd>{`${st ? `${st} ` : ''}${sg} ${ss}`}</dd>
</DL>
{reviewer && (
<DL>
<dt>Reviewer:</dt>
<dd>
{`${rt ? `${rt} ` : ''}${rg} ${rs}`}
<Action
onClick={() => this.setState({ edit: 'reviewer' })}
>
<EditIcon />
</Action>
</dd>
</DL>
)}
</React.Fragment>
)}
</React.Fragment>
)}
<DL>
<dt>Time in process:</dt>
......@@ -341,6 +380,7 @@ class MetaSec extends React.Component {
{edit && (
<MetaEdit
close={() => this.setState({ edit: null })}
currentUser={currentUser}
duplicates={duplicates}
lastStatus={
lastStatusChange &&
......
import React from 'react'
import { Button } from '@pubsweet/ui'
import { Buttons } from '../ui'
import SelectReviewer from '../SelectReviewer'
class ReviewerEdit extends React.Component {
state = { newReviewer: null }
render() {
const { newReviewer } = this.state
const {
currentUser,
manuscript,
close,
changeNote,
deleteNote,
newNote,
} = this.props
const { teams, meta } = manuscript
const { fundingGroup, notes } = meta
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 submitter =
teams && teams.find(team => team.role === 'submitter')
? teams.find(team => team.role === 'submitter').teamMembers[0]
: null
return (
<React.Fragment>
<SelectReviewer
currentUser={currentUser}
funding={fundingGroup}
reviewer={reviewer}
reviewerNote={reviewerNote}
setReviewerNote={v => this.setState({ newReviewer: v })}
submitter={submitter}
/>
<Buttons right>
<Button
disabled={!newReviewer}
onClick={async () => {
let result = false
if (reviewerNote && newReviewer) {
if (newReviewer === 'delete') {
result = await deleteNote(reviewerNote.id)
} else {
result = await changeNote({
id: reviewerNote.id,
notesType: 'selectedReviewer',
content: JSON.stringify(newReviewer),
})
}
} else {
result = await newNote({
notesType: 'selectedReviewer',
content: JSON.stringify(newReviewer),
})
}
if (result) {
close()
}
}}
primary
>
Save
</Button>
<Button onClick={close}>Exit</Button>
</Buttons>
</React.Fragment>
)
}
}
export default ReviewerEdit
......@@ -403,6 +403,12 @@ class Manuscript extends EpmcBaseModel {
const manuscripts = await Manuscript.query()
.where('manuscript.id', id)
.eager('[journal, notes, claiming, teams.users, audits.user.identities]')
.modifyEager('notes', builder => {
builder.whereNull('deleted')
})
.modifyEager('teams', builder => {
builder.whereNull('deleted')
})
.modifyEager('audits', q => {
q.orderBy('audit_log.created', 'asc')
})
......
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