diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-03-28 14:45:07 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-03-28 14:45:07 +0100 |
| commit | ad6284a2040837e7373b4d89644a01306f181dd5 (patch) | |
| tree | 9fde7c1669ee92004cd990496634221dda42e8dd /scraper/client/paper/paper.verify.js | |
| parent | 1c25e681184dd3c61a6296d5cebb4e5883b072f0 (diff) | |
fetch papers by single dataset
Diffstat (limited to 'scraper/client/paper/paper.verify.js')
| -rw-r--r-- | scraper/client/paper/paper.verify.js | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/scraper/client/paper/paper.verify.js b/scraper/client/paper/paper.verify.js index 65342adf..1b55186a 100644 --- a/scraper/client/paper/paper.verify.js +++ b/scraper/client/paper/paper.verify.js @@ -9,13 +9,16 @@ import { USES_DATASET } from '../types' const initialState = { citation: null, + address: {}, uses_dataset: USES_DATASET.UNKNOWN, images_in_paper: "FALSE", used_as_model: "FALSE", verified_by: localStorage.getItem('verify.username') || '', reference: '', notes: '', + location: '', pdf_index: 0, + isUnknown: false, } class PaperVerify extends Component { @@ -26,6 +29,7 @@ class PaperVerify extends Component { componentDidMount() { const { sha256 } = this.props.match.params this.props.actions.getInstitutions() + this.props.actions.getAddress(sha256) this.props.actions.getVerification(sha256) const citationState = this.getCitationState(sha256) console.log('DID MOUNT') @@ -34,52 +38,66 @@ class PaperVerify extends Component { componentDidUpdate(oldProps) { const { sha256 } = this.props.match.params - const { verify } = this.props.api + const { address, verify } = this.props.api const { sha256: oldSha256 } = oldProps.match.params - const { verify: oldVerify } = oldProps.api + const { verify: oldVerify, address: oldAddress } = oldProps.api const oldPaper = oldVerify ? oldVerify.paper : null const paper = verify ? verify.paper : null + let newState = {} if (oldSha256 && sha256 !== oldSha256) { console.log('update verification') + this.props.actions.getAddress(sha256) this.props.actions.getVerification(sha256) const citationState = this.getCitationState(sha256) - this.setState({ + newState = { ...initialState, ...citationState, - }) + ...address.paper, + } + this.setState(newState) } else if (verify && !verify.loading && verify.paper && (!oldPaper || oldPaper !== verify.paper)) { if (paper.error) { console.log('USING PAPER VERIFICATION') const citationState = this.getCitationState(sha256) - this.setState({ + newState = { ...initialState, ...citationState, - }) + ...address.paper, + } + this.setState(newState) } else { // console.log(paper) console.log('GOT CUSTOM CITATION STATE', paper) const citationState = this.getCitationState(sha256) - this.setState({ + newState = { ...citationState, + ...address.paper, uses_dataset: paper.uses_dataset === "TRUE", images_in_paper: paper.images_in_paper === "TRUE", verified_by: paper.verified_by, reference: paper.reference, notes: paper.notes, - }) + } + this.setState(newState) } } else if (oldProps.api.unknownCitations !== this.props.api.unknownCitations) { const citationState = this.getCitationState(sha256) - this.setState(citationState) + newState = citationState + this.setState(newState) } } getCitationState(sha256) { const { paperInfo, unknownCitations } = this.props.api let citation = (unknownCitations.citations || []).find(f => f.id === sha256) - if (!citation) { + if (citation) { + citation.isUnknown = true + } else { citation = (paperInfo.citations || []).find(f => f.id === sha256) + if (citation) { + citation.isUnknown = false + } } // console.log(sha256, citation) let state = { citation } @@ -148,7 +166,7 @@ class PaperVerify extends Component { } render() { - let { paperInfo } = this.props.api + const { paperInfo, unknownCitations } = this.props.api if (paperInfo.loading) return <Loader /> // console.log(this.state) const { citation } = this.state @@ -185,6 +203,8 @@ class PaperVerify extends Component { </a> </div> + {this.renderLocationForm()} + <div className='row vettingRow'> <div className='rowHeading'> {'Uses dataset'} @@ -194,7 +214,7 @@ class PaperVerify extends Component { className='vetting' type='radio' name='uses_dataset' - checked={this.state.uses_dataset === USES_DATASET.YES || this.state.uses_dataset === "FALSE"} + checked={parseInt(this.state.uses_dataset) === USES_DATASET.YES || this.state.uses_dataset === "FALSE"} onChange={e => this.setState({ uses_dataset: USES_DATASET.YES, })} @@ -207,7 +227,7 @@ class PaperVerify extends Component { className='vetting' type='radio' name='uses_dataset' - checked={this.state.uses_dataset === USES_DATASET.NO || this.state.uses_dataset === "FALSE"} + checked={parseInt(this.state.uses_dataset) === USES_DATASET.NO || this.state.uses_dataset === "FALSE"} onChange={e => this.setState({ uses_dataset: USES_DATASET.NO, })} @@ -220,7 +240,7 @@ class PaperVerify extends Component { className='vetting' type='radio' name='uses_dataset' - checked={this.state.uses_dataset === USES_DATASET.UNKNOWN || this.state.uses_dataset === "FALSE"} + checked={parseInt(this.state.uses_dataset) === USES_DATASET.UNKNOWN || this.state.uses_dataset === "FALSE"} onChange={e => this.setState({ uses_dataset: USES_DATASET.UNKNOWN, })} @@ -230,8 +250,8 @@ class PaperVerify extends Component { </div> <div - className={this.state.uses_dataset === USES_DATASET.YES ? 'row vettingRow' : 'row vettingRow disabled'} - disabled={this.state.uses_dataset === USES_DATASET.YES ? false : true} + className={parseInt(this.state.uses_dataset) === USES_DATASET.YES ? 'row vettingRow' : 'row vettingRow disabled'} + disabled={parseInt(this.state.uses_dataset) === USES_DATASET.YES ? false : true} > <div className='rowHeading'> {'Paper shows images'} @@ -355,6 +375,22 @@ class PaperVerify extends Component { </div> ) } + renderLocationForm() { + if (!this.state.citation.isUnknown) return + return ( + <div> + <div className='param'> + <label>Institution</label> + <input + type='text' + value={this.state.address.institution_1} + placeholder='Institution' + onChange={e => this.setState({ institution_1: e.target.value })} + /> + </div> + </div> + ) + } } /* |
