Skip to content
Snippets Groups Projects
Commit 3a29bed8 authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files

Merge branch 'dev' into 'master'

Dev

See merge request xpub/xpub-epmc!172
parents 3e0e7047 795455ac
No related branches found
No related tags found
1 merge request!172Dev
import moment from 'moment'
import { omit } from 'lodash' import { omit } from 'lodash'
import { compose } from 'recompose' import { compose } from 'recompose'
import { withFormik } from 'formik' import { withFormik } from 'formik'
...@@ -36,9 +37,14 @@ const handleSubmit = async ( ...@@ -36,9 +37,14 @@ const handleSubmit = async (
} }
if (values.printseason) { if (values.printseason) {
ppub.jatsDate.season = values.printseason ppub.jatsDate.season = values.printseason
ppub.date = moment.utc(values.printyear, 'YYYY')
} else { } else {
ppub.jatsDate.month = values.printmonth ppub.jatsDate.month = values.printmonth
ppub.jatsDate.day = values.printday ppub.jatsDate.day = values.printday
ppub.date = moment.utc(
`${values.printyear} ${values.printmonth} ${values.printday}`,
'YYYY MMM DD',
)
} }
meta.publicationDates.push(ppub) meta.publicationDates.push(ppub)
} }
...@@ -51,9 +57,16 @@ const handleSubmit = async ( ...@@ -51,9 +57,16 @@ const handleSubmit = async (
} }
if (values.electronicseason) { if (values.electronicseason) {
epub.jatsDate.season = values.electronicseason epub.jatsDate.season = values.electronicseason
epub.date = moment.utc(values.electronicyear, 'YYYY')
} else { } else {
epub.jatsDate.month = values.electronicmonth epub.jatsDate.month = values.electronicmonth
epub.jatsDate.day = values.electronicday epub.jatsDate.day = values.electronicday
epub.date = moment.utc(
`${values.electronicyear} ${values.electronicmonth} ${
values.electronicday
}`,
'YYYY MMM DD',
)
} }
meta.publicationDates.push(epub) meta.publicationDates.push(epub)
} }
......
...@@ -110,6 +110,7 @@ class PubMedSearch extends React.Component { ...@@ -110,6 +110,7 @@ class PubMedSearch extends React.Component {
if (isDate(result.pubdate)) { if (isDate(result.pubdate)) {
ppub.date = isDate(result.pubdate) ppub.date = isDate(result.pubdate)
} else { } else {
ppub.date = moment.utc(result.pubdate.substring(0, 4), 'YYYY')
ppub.jatsDate = { ppub.jatsDate = {
year: result.pubdate.substring(0, 4), year: result.pubdate.substring(0, 4),
season: result.pubdate.substring(5), season: result.pubdate.substring(5),
...@@ -122,6 +123,7 @@ class PubMedSearch extends React.Component { ...@@ -122,6 +123,7 @@ class PubMedSearch extends React.Component {
if (isDate(result.epubdate)) { if (isDate(result.epubdate)) {
epub.date = isDate(result.epubdate) epub.date = isDate(result.epubdate)
} else { } else {
epub.date = moment.utc(result.pubdate.substring(0, 4), 'YYYY')
epub.jatsDate = { epub.jatsDate = {
year: result.pubdate.substring(0, 4), year: result.pubdate.substring(0, 4),
season: result.epubdate.substring(5), season: result.epubdate.substring(5),
......
...@@ -96,10 +96,6 @@ const DashboardFragment = gql` ...@@ -96,10 +96,6 @@ const DashboardFragment = gql`
type type
date date
} }
notes {
notesType
content
}
fundingGroup { fundingGroup {
fundingSource fundingSource
awardId awardId
......
...@@ -73,19 +73,6 @@ class Created extends React.Component { ...@@ -73,19 +73,6 @@ class Created extends React.Component {
newReviewer: null, newReviewer: null,
} }
} }
componentDidUpdate(prevProps, prevState) {
const { newReviewer } = prevState
const { notes } = prevProps.manuscript.meta
const reviewerNote = notes
? notes.find(n => n.notesType === 'selectedReviewer')
: null
if (reviewerNote && reviewerNote.content === JSON.stringify(newReviewer)) {
const { id } = this.props.manuscript
this.props.setStatus('READY', () => {
this.props.history.push(`/submission/${id}/submit`)
})
}
}
static contextType = UserContext static contextType = UserContext
getCurrentStep = () => { getCurrentStep = () => {
const { meta, files } = this.props.manuscript const { meta, files } = this.props.manuscript
...@@ -186,6 +173,11 @@ class Created extends React.Component { ...@@ -186,6 +173,11 @@ class Created extends React.Component {
newState.showSearch = false newState.showSearch = false
} else if (this.state.currentStep < 3) { } else if (this.state.currentStep < 3) {
newState.currentStep = this.state.currentStep + 1 newState.currentStep = this.state.currentStep + 1
} else {
const { id } = this.props.manuscript
this.props.setStatus('READY', () => {
this.props.history.push(`/submission/${id}/submit`)
})
} }
this.setState(newState) this.setState(newState)
window.scrollY = 0 window.scrollY = 0
...@@ -310,9 +302,8 @@ class Created extends React.Component { ...@@ -310,9 +302,8 @@ class Created extends React.Component {
content: JSON.stringify(newReviewer), content: JSON.stringify(newReviewer),
}) })
} }
} else {
this.goNext()
} }
this.goNext()
}} }}
primary={!this.state.showSearch} primary={!this.state.showSearch}
title={ title={
...@@ -359,10 +350,9 @@ class Created extends React.Component { ...@@ -359,10 +350,9 @@ class Created extends React.Component {
</InfoPanel> </InfoPanel>
{cancel && ( {cancel && (
<SubmissionCancel <SubmissionCancel
cancel={() => callback={() => this.props.history.push('/')}
this.props.deleteMan(() => this.props.history.push('/'))
}
close={() => this.setState({ cancel: false })} close={() => this.setState({ cancel: false })}
manuscriptId={manuscript.id}
/> />
)} )}
</SplitPage> </SplitPage>
......
...@@ -170,12 +170,13 @@ class Submit extends React.Component { ...@@ -170,12 +170,13 @@ class Submit extends React.Component {
<React.Fragment> <React.Fragment>
{(() => { {(() => {
if ( if (
(reviewer && !currentUser.admin &&
((reviewer &&
reviewer.id === currentUser.id && reviewer.id === currentUser.id &&
!['in-review', 'submission-error'].includes(status)) || !['in-review', 'submission-error'].includes(status)) ||
(submitter && (submitter &&
submitter.user.id === currentUser.id && submitter.user.id === currentUser.id &&
!['INITIAL', 'READY', 'submission-error'].includes(status)) !['INITIAL', 'READY', 'submission-error'].includes(status)))
) { ) {
window.scrollY = 0 window.scrollY = 0
window.pageYOffset = 0 window.pageYOffset = 0
......
...@@ -93,7 +93,7 @@ CREATE TABLE manuscript ( ...@@ -93,7 +93,7 @@ CREATE TABLE manuscript (
); );
-- ALTER SEQUENCE manuscript_id_seq RESTART WITH 80000; -- ALTER SEQUENCE manuscript_id_seq RESTART WITH 80000;
CREATE SEQUENCE manuscript_emsid_seq START 90000; CREATE SEQUENCE manuscript_emsid_seq START 82777;
CREATE INDEX pdfState_idx ON manuscript (pdf_deposit_state); CREATE INDEX pdfState_idx ON manuscript (pdf_deposit_state);
......
const moment = require('moment')
const logger = require('@pubsweet/logger') const logger = require('@pubsweet/logger')
const path = require('path') const path = require('path')
const { exec } = require('child_process') const { exec } = require('child_process')
...@@ -164,12 +165,19 @@ function createManifest(tmpPath, manuscript, funders) { ...@@ -164,12 +165,19 @@ function createManifest(tmpPath, manuscript, funders) {
const pmId = manuscript['meta,articleIds'].find(id => id.pubIdType === 'pmid') const pmId = manuscript['meta,articleIds'].find(id => id.pubIdType === 'pmid')
? manuscript['meta,articleIds'].find(id => id.pubIdType === 'pmid').id ? manuscript['meta,articleIds'].find(id => id.pubIdType === 'pmid').id
: 0 : 0
const createdDate = new Date(manuscript.created).toISOString().split('T')[0] const createdDate = moment(manuscript.created).format('YYYY-MM-DD')
const publishDate = new Date( const pubDates = manuscript['meta,publicationDates']
manuscript['meta,publicationDates'].find(date => date.type === 'ppub').date, const releaseDelay = manuscript['meta,releaseDelay']
) ? parseInt(manuscript['meta,releaseDelay'], 10)
.toISOString() : 0
.split('T')[0] const startDate =
(pubDates.find(date => date.type === 'ppub') &&
pubDates.find(date => date.type === 'ppub').date) ||
(pubDates.find(date => date.type === 'epub') &&
pubDates.find(date => date.type === 'epub').date)
const publishDate = moment(startDate)
.add(releaseDelay, 'M')
.format('YYYY-MM-DD')
const hasPubPdf = manuscript.files.find(file => file.type === 'pdf4load') const hasPubPdf = manuscript.files.find(file => file.type === 'pdf4load')
? '1' ? '1'
: '0' : '0'
...@@ -280,8 +288,9 @@ function getFilesPrefix(manuscript) { ...@@ -280,8 +288,9 @@ function getFilesPrefix(manuscript) {
} }
function getNcbiFiles(manuscript) { function getNcbiFiles(manuscript) {
return manuscript.files.filter(file => return manuscript.files.filter(
ncbiFileTypes.find(type => type.value === file.type), file =>
!file.deleted && ncbiFileTypes.some(type => type.value === file.type),
) )
} }
......
const { Model } = require('objection') const { Model } = require('objection')
const logger = require('@pubsweet/logger')
const uuid = require('uuid') const uuid = require('uuid')
const EpmcBaseModel = require('../epmc-base-model') const EpmcBaseModel = require('../epmc-base-model')
const { rowToEntity, entityToRow, buildQuery, runQuery } = require('../util') const { rowToEntity, entityToRow, buildQuery, runQuery } = require('../util')
...@@ -114,11 +115,18 @@ class Note extends EpmcBaseModel { ...@@ -114,11 +115,18 @@ class Note extends EpmcBaseModel {
return manuscript return manuscript
} }
static delete(id, userId) { static async delete(id, userId) {
return Note.query().updateAndFetchById(id, { try {
deleted: new Date().toISOString(), await Note.query().updateAndFetchById(id, {
updatedBy: userId, deleted: new Date().toISOString(),
}) updatedBy: userId,
})
logger.info('Note deleted')
return true
} catch (err) {
logger.error('Note delete error: ', err)
return false
}
} }
static async deleteByManuscriptId(id, userId, trx) { static async deleteByManuscriptId(id, userId, trx) {
......
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