Commit 68b65134 authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files
parent 1f0691d9
Pipeline #13459 failed with stages
in 33 seconds
...@@ -92,7 +92,7 @@ class CitationEdit extends React.Component { ...@@ -92,7 +92,7 @@ class CitationEdit extends React.Component {
} }
} }
render() { render() {
const { manuscript, change, close, linkAndDelete } = this.props const { manuscript, change, close } = this.props
const { journal, meta } = manuscript const { journal, meta } = manuscript
const { notes, articleIds: aids, unmatchedJournal } = meta const { notes, articleIds: aids, unmatchedJournal } = meta
const articleIds = aids ? aids.map(aid => omit(aid, '__typename')) : [] const articleIds = aids ? aids.map(aid => omit(aid, '__typename')) : []
...@@ -192,14 +192,14 @@ class CitationEdit extends React.Component { ...@@ -192,14 +192,14 @@ class CitationEdit extends React.Component {
{(deleteCitation, { data }) => ( {(deleteCitation, { data }) => (
<React.Fragment> <React.Fragment>
<PubMedSearch <PubMedSearch
adminRemove={linkAndDelete} adminRemove
citationData={async e => { citationData={async (e, d) => {
await deleteCitation({ await deleteCitation({
variables: { variables: {
manuscriptId: manuscript.id, manuscriptId: manuscript.id,
}, },
}) })
await change(e) await change(e, d)
close() close()
}} }}
search={meta.title} search={meta.title}
......
...@@ -99,7 +99,7 @@ const MetaEdit = withTheme( ...@@ -99,7 +99,7 @@ const MetaEdit = withTheme(
case 'citation': case 'citation':
return ( return (
<CitationEdit <CitationEdit
change={async e => { change={async (e, d) => {
await props.changeCitation(e) await props.changeCitation(e)
if (manuscript.status === 'xml-complete') { if (manuscript.status === 'xml-complete') {
const { const {
...@@ -119,9 +119,11 @@ const MetaEdit = withTheme( ...@@ -119,9 +119,11 @@ const MetaEdit = withTheme(
props.setStatus('ncbi-ready') props.setStatus('ncbi-ready')
} }
} }
if (d) {
await linkAndDelete(d)
}
}} }}
close={close} close={close}
linkAndDelete={linkAndDelete}
manuscript={manuscript} manuscript={manuscript}
/> />
) )
......
...@@ -72,13 +72,13 @@ export const EditIcon = () => ( ...@@ -72,13 +72,13 @@ export const EditIcon = () => (
) )
class MetaSec extends React.Component { class MetaSec extends React.Component {
state = { edit: null, linkDelete: null, notif: null } state = { edit: null, notif: null }
componentDidMount() { componentDidMount() {
this._mounted = true this._mounted = true
this.notifTimer = null this.notifTimer = null
} }
async componentDidUpdate() { async componentDidUpdate() {
const { notif, linkDelete } = this.state const { notif } = this.state
if (this.notifTimer) { if (this.notifTimer) {
clearTimeout(this.notifTimer) clearTimeout(this.notifTimer)
} }
...@@ -89,31 +89,6 @@ class MetaSec extends React.Component { ...@@ -89,31 +89,6 @@ class MetaSec extends React.Component {
} }
}, 3000) }, 3000)
} }
const { manuscript, linkDeleteManuscript } = this.props
const { articleIds } = manuscript.meta
const pmcid =
articleIds &&
articleIds.find(aid => aid.pubIdType === 'pmcid') &&
articleIds.find(aid => aid.pubIdType === 'pmcid').id
if (
linkDelete &&
linkDelete === pmcid &&
manuscript.status !== 'xml-complete'
) {
;(() =>
this.setState({ linkDelete: null }, async () => {
const { data } = await linkDeleteManuscript({
variables: { id: manuscript.id },
})
const result = data.linkDeleteManuscript
this.setState({
notif: {
type: result.success ? 'success' : 'error',
message: result.message,
},
})
}))()
}
} }
componentWillUnmount() { componentWillUnmount() {
this._mounted = false this._mounted = false
...@@ -122,7 +97,12 @@ class MetaSec extends React.Component { ...@@ -122,7 +97,12 @@ class MetaSec extends React.Component {
static contextType = UserContext static contextType = UserContext
render() { render() {
const currentUser = this.context const currentUser = this.context
const { manuscript, claimManuscript, unclaimManuscript } = this.props const {
manuscript,
claimManuscript,
unclaimManuscript,
linkDeleteManuscript,
} = this.props
const { teams, audits, meta, journal, claiming } = manuscript const { teams, audits, meta, journal, claiming } = manuscript
const { const {
fundingGroup, fundingGroup,
...@@ -390,7 +370,18 @@ class MetaSec extends React.Component { ...@@ -390,7 +370,18 @@ class MetaSec extends React.Component {
lastStatusChange.originalData && lastStatusChange.originalData &&
lastStatusChange.originalData.status lastStatusChange.originalData.status
} }
linkAndDelete={v => this.setState({ linkDelete: v })} linkAndDelete={async v => {
const { data } = await linkDeleteManuscript({
variables: { id: manuscript.id },
})
const result = data.linkDeleteManuscript
this.setState({
notif: {
type: result.success ? 'success' : 'error',
message: result.message,
},
})
}}
manuscript={manuscript} manuscript={manuscript}
refetch={[ refetch={[
{ {
......
...@@ -117,7 +117,7 @@ class PubMedSearch extends React.Component { ...@@ -117,7 +117,7 @@ class PubMedSearch extends React.Component {
this.props.citationData(citationData) this.props.citationData(citationData)
} }
} }
selectResult(result, journal) { selectResult(result, journal, removePMCID) {
const publicationDates = [] const publicationDates = []
const articleIds = [ const articleIds = [
{ {
...@@ -181,7 +181,7 @@ class PubMedSearch extends React.Component { ...@@ -181,7 +181,7 @@ class PubMedSearch extends React.Component {
articleIds, articleIds,
}, },
} }
this.props.citationData(citationData) this.props.citationData(citationData, removePMCID)
} }
onQueryChange(event) { onQueryChange(event) {
this.setState({ this.setState({
...@@ -373,8 +373,11 @@ class PubMedSearch extends React.Component { ...@@ -373,8 +373,11 @@ class PubMedSearch extends React.Component {
<FlexP> <FlexP>
<Button <Button
onClick={() => { onClick={() => {
this.selectResult(inPMC.result, inPMC.journal) this.selectResult(
adminRemove(inPMC.pmcid) inPMC.result,
inPMC.journal,
inPMC.pmcid,
)
}} }}
> >
Remove submission Remove submission
......
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