From 202652433f699cf9691c23713519040e235fea76 Mon Sep 17 00:00:00 2001
From: ahamelers <audrey@ahamelers.com>
Date: Sun, 8 Jul 2018 18:05:59 +0100
Subject: [PATCH] #98 show previously entered journal and title for editing

---
 app/components/Create.jsx            |  2 +-
 app/components/PubMedSearch.jsx      | 19 +++++++++++++------
 app/components/UnmatchedCitation.jsx |  9 ++++-----
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/app/components/Create.jsx b/app/components/Create.jsx
index 95a8f0c1a..beede632a 100644
--- a/app/components/Create.jsx
+++ b/app/components/Create.jsx
@@ -195,7 +195,7 @@ class EPMCCreated extends React.Component {
             <Buttons>
               <div>
                 {!this.state.showSearch && (
-                  <Button onClick={this.goPrev}>Back</Button>
+                  <Button onClick={this.goPrev}>Previous</Button>
                 )}
                 <Button
                   disabled={this.getDisableNext(currentStep)}
diff --git a/app/components/PubMedSearch.jsx b/app/components/PubMedSearch.jsx
index cbcf71c29..4ec6789b1 100644
--- a/app/components/PubMedSearch.jsx
+++ b/app/components/PubMedSearch.jsx
@@ -46,7 +46,10 @@ class PubMedSearch extends React.Component {
       hitcount: null,
       inPMC: null,
       pmcid: null,
-      unmatched: false,
+      unmatched:
+        this.props.metadata &&
+        (!this.props.metadata.articleId ||
+          this.props.metadata.articleId.length === 0),
       // pubProvided: null,
     }
     this.onSearch = this.onSearch.bind(this)
@@ -149,9 +152,13 @@ class PubMedSearch extends React.Component {
   }
   render() {
     const { metadata } = this.props
-    const { title, journalMeta } = metadata || {}
-    const { title: journalTitle } = journalMeta || {}
-
+    const { title, journalMeta, customMeta } = metadata || {}
+    let journal = journalMeta
+    if (!journal && customMeta && customMeta.unmatchedJournal) {
+      journal = {
+        title: customMeta.unmatchedJournal,
+      }
+    }
     if (this.state.unmatched) {
       return ReactDOM.createPortal(
         <Cover>
@@ -160,8 +167,8 @@ class PubMedSearch extends React.Component {
               <CloseIcon onClick={() => this.setState({ unmatched: false })} />
             </Close>
             <UnmatchedCitation
-              journal={title}
-              title={journalTitle}
+              journal={journal}
+              title={title}
               unmatchedInfo={this.handleUnmatchedInfo}
             />
           </Page>
diff --git a/app/components/UnmatchedCitation.jsx b/app/components/UnmatchedCitation.jsx
index 97d6bbc82..2702b1bb0 100644
--- a/app/components/UnmatchedCitation.jsx
+++ b/app/components/UnmatchedCitation.jsx
@@ -8,11 +8,11 @@ export default class UnmatchedCitation extends React.Component {
   constructor(props) {
     super(props)
     this.state = {
-      title: '',
-      query: '',
-      journal: null,
+      title: this.props.title,
+      query: this.props.journal ? this.props.journal.title : '',
+      journal: this.props.journal,
       note: this.props.note,
-      enabled: false,
+      enabled: this.props.title && this.props.journal,
       journals: [],
       titleMessage: '',
       journalMessage: '',
@@ -146,7 +146,6 @@ export default class UnmatchedCitation extends React.Component {
           optionsOnChange={this.onJournalChange}
           placeholder="Journal title abbreviation"
           query={this.state.query}
-          selectedOptions={this.props.journal}
           singleSelect
         >
           {this.state.journals.map(journal => (
-- 
GitLab