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