diff --git a/app/components/component-formbuilder/src/components/builderComponents/RadioBox.js b/app/components/component-formbuilder/src/components/builderComponents/RadioBox.js index cd1e92ece70b72b6194266ec6cc3ebfa4c365096..b6055ddd106245e1e7ee2949ace148acdf47c87e 100644 --- a/app/components/component-formbuilder/src/components/builderComponents/RadioBox.js +++ b/app/components/component-formbuilder/src/components/builderComponents/RadioBox.js @@ -3,7 +3,7 @@ import styled from 'styled-components' import { RadioGroup as UnstableRadioGroup } from '@pubsweet/ui' const RadioGroup = styled(UnstableRadioGroup)` - position: relative + position: relative; ` const RadioboxFieldBuilder = input => <RadioGroup {...input} /> diff --git a/app/components/component-submit/src/components/FormTemplate.js b/app/components/component-submit/src/components/FormTemplate.js index 84e52cae8155ccbc98db368e85be9a3f6b8f3a35..d8d84d88b7b5c97ee8cc6487a538d218dc51de4c 100644 --- a/app/components/component-submit/src/components/FormTemplate.js +++ b/app/components/component-submit/src/components/FormTemplate.js @@ -12,6 +12,7 @@ import { import * as validators from 'xpub-validators' import { AbstractEditor } from 'xpub-edit' import config from 'config' +import { useApolloClient } from '@apollo/client' import { Section as Container, Select, FilesUpload } from '../../../shared' import { Heading1, Section, Legend, SubNote } from '../style' import AuthorsInput from './AuthorsInput' @@ -20,7 +21,6 @@ import ValidatedFieldFormik from './ValidatedField' import Confirm from './Confirm' import { articleStatuses } from '../../../../globals' import { VALIDATE_DOI } from '../../../../queries/index' -import { useApolloClient } from '@apollo/client' const Intro = styled.div` font-style: italic; @@ -112,7 +112,12 @@ const createMarkup = encodedHtml => ({ __html: unescape(encodedHtml), }) -const composeValidate = (vld = [], valueField = {}, fieldName, client) => value => { +const composeValidate = ( + vld = [], + valueField = {}, + fieldName, + client, +) => value => { const validator = vld || [] if (validator.length === 0) return undefined @@ -132,19 +137,23 @@ const composeValidate = (vld = [], valueField = {}, fieldName, client) => value return validatorFn }) - if(errors.length === 0 && fieldName === 'submission.articleURL') { - return client.query({ - query: VALIDATE_DOI, + if (errors.length === 0 && fieldName === 'submission.articleURL') { + return client + .query({ + query: VALIDATE_DOI, variables: { - articleURL: value - } - }).then(res => { + articleURL: value, + }, + }) + .then(res => { if (!res.data.validateDOI.isDOIValid) { return 'DOI is invalid' } + return undefined }) - } + } + return errors.length > 0 ? errors[0] : undefined } @@ -167,6 +176,7 @@ const FormTemplate = ({ match, }) => { const client = useApolloClient() + const submitButton = text => ( <div> <Button @@ -274,7 +284,7 @@ const FormTemplate = ({ element.validate, element.validateValue, element.name, - client + client, )} values={values} /> diff --git a/app/queries/index.js b/app/queries/index.js index 8b36453fbb992089937e1b520c04b4836217a40e..8d21835e33f2e25a17b0547a47475453d66531e8 100644 --- a/app/queries/index.js +++ b/app/queries/index.js @@ -84,12 +84,8 @@ export const SEARCH_USERS = gql` ` export const VALIDATE_DOI = gql` - query Manuscripts( - $articleURL: String - ) { - validateDOI( - articleURL: $articleURL - ){ + query Manuscripts($articleURL: String) { + validateDOI(articleURL: $articleURL) { isDOIValid } } diff --git a/app/storage/forms-ncrc/submit.json b/app/storage/forms-ncrc/submit.json index cba65b43a009367cf62364c9fdc24bf1b12e3b1a..d6e5d3f9c311400cb246fd5b2b100e4b0bcf614c 100644 --- a/app/storage/forms-ncrc/submit.json +++ b/app/storage/forms-ncrc/submit.json @@ -1,231 +1,231 @@ { - "children": [ - { - "title": "Article URL", - "id": "1617195421539", - "component": "TextField", - "name": "submission.articleURL", - "description": "<p></p>", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Article Description", - "id": "1617195483503", - "component": "TextField", - "name": "submission.articleDescription", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Our take", - "id": "1617195546630", - "component": "AbstractEditor", - "name": "submission.ourTake", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "options": [ - { - "label": "Case-series", - "value": "caseSeries" - }, - { - "label": "Case-control", - "value": "caseControl" - }, - { - "label": "Cross-sectional", - "value": "crossSectional" - }, - { - "label": "Prospective cohort", - "value": "prospectiveCohort" - }, - { - "label": "Retrospective cohort", - "value": "retrospectiveCohort" - }, - { - "label": "Ecological", - "value": "ecological" - }, - { - "label": "Randomized Control Trial", - "value": "randomizedControlTrial" - }, - { - "label": "Non-Randomized Trial", - "value": "nonRandomizedTrial" - }, - { - "label": "Modeling/Simulation", - "value": "modelingSimulation" - }, - { - "label": "Other", - "value": "other" - } - ], - "title": "Study design", - "id": "1617195606326", - "component": "Select", - "name": "submission.studyDesign", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Study population and setting", - "id": "1617196039750", - "component": "AbstractEditor", - "name": "submission.studyPopulationAndSetting", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Summary of main findings", - "id": "1617196078810", - "component": "AbstractEditor", - "name": "submission.summaryOfMainFindings", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Study strengths", - "id": "1617196181149", - "component": "AbstractEditor", - "name": "submission.studyStrengths", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Limitations", - "id": "1617196237717", - "component": "AbstractEditor", - "name": "submission.limitations", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "title": "Value added", - "id": "1617196283857", - "component": "AbstractEditor", - "name": "submission.valueAdded", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "options": [ - { - "label": "Ready to evaluate", - "value": "readyToEvaluate" - }, - { - "label": "Evaluated", - "value": "evaluated" - }, - { - "label": "Ready to publish", - "value": "readyToPublish" - } - ], - "title": "Labels", - "id": "1617196325513", - "component": "Select", - "name": "submission.labels", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - }, - { - "options": [ - { - "label": "ecology and spillover", - "value": "ecologyAndSpillover" - }, - { - "label": "vaccines", - "value": "vaccines" - }, - { - "label": "non-pharmaceutical and pharmaceutical interventions", - "value": "nonPharmaceuticalAndPharmaceuticalInterventions" - }, - { - "label": "epidemiology", - "value": "epidemiology" - }, - { - "label": "diagnostics", - "value": "diagnostics" - }, - { - "label": "modeling", - "value": "modeling" - }, - { - "label": "clinical presentation", - "value": "clinicalPresentation" - }, - { - "label": "prognostic risk factors", - "value": "prognosticRiskFactors" - } - ], - "title": "Topics", - "id": "1617196386967", - "component": "CheckboxGroup", - "name": "submission.topics", - "validate": [ - { - "value": "required", - "label": "Required" - } - ] - } - ], - "id": "submit", - "name": "NCRC Submission Form", - "description": "<p>NCRC Form</p>", - "haspopup": "false" - } \ No newline at end of file + "children": [ + { + "title": "Article URL", + "id": "1617195421539", + "component": "TextField", + "name": "submission.articleURL", + "description": "<p></p>", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Article Description", + "id": "1617195483503", + "component": "TextField", + "name": "submission.articleDescription", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Our take", + "id": "1617195546630", + "component": "AbstractEditor", + "name": "submission.ourTake", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "options": [ + { + "label": "Case-series", + "value": "caseSeries" + }, + { + "label": "Case-control", + "value": "caseControl" + }, + { + "label": "Cross-sectional", + "value": "crossSectional" + }, + { + "label": "Prospective cohort", + "value": "prospectiveCohort" + }, + { + "label": "Retrospective cohort", + "value": "retrospectiveCohort" + }, + { + "label": "Ecological", + "value": "ecological" + }, + { + "label": "Randomized Control Trial", + "value": "randomizedControlTrial" + }, + { + "label": "Non-Randomized Trial", + "value": "nonRandomizedTrial" + }, + { + "label": "Modeling/Simulation", + "value": "modelingSimulation" + }, + { + "label": "Other", + "value": "other" + } + ], + "title": "Study design", + "id": "1617195606326", + "component": "Select", + "name": "submission.studyDesign", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Study population and setting", + "id": "1617196039750", + "component": "AbstractEditor", + "name": "submission.studyPopulationAndSetting", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Summary of main findings", + "id": "1617196078810", + "component": "AbstractEditor", + "name": "submission.summaryOfMainFindings", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Study strengths", + "id": "1617196181149", + "component": "AbstractEditor", + "name": "submission.studyStrengths", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Limitations", + "id": "1617196237717", + "component": "AbstractEditor", + "name": "submission.limitations", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "title": "Value added", + "id": "1617196283857", + "component": "AbstractEditor", + "name": "submission.valueAdded", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "options": [ + { + "label": "Ready to evaluate", + "value": "readyToEvaluate" + }, + { + "label": "Evaluated", + "value": "evaluated" + }, + { + "label": "Ready to publish", + "value": "readyToPublish" + } + ], + "title": "Labels", + "id": "1617196325513", + "component": "Select", + "name": "submission.labels", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + }, + { + "options": [ + { + "label": "ecology and spillover", + "value": "ecologyAndSpillover" + }, + { + "label": "vaccines", + "value": "vaccines" + }, + { + "label": "non-pharmaceutical and pharmaceutical interventions", + "value": "nonPharmaceuticalAndPharmaceuticalInterventions" + }, + { + "label": "epidemiology", + "value": "epidemiology" + }, + { + "label": "diagnostics", + "value": "diagnostics" + }, + { + "label": "modeling", + "value": "modeling" + }, + { + "label": "clinical presentation", + "value": "clinicalPresentation" + }, + { + "label": "prognostic risk factors", + "value": "prognosticRiskFactors" + } + ], + "title": "Topics", + "id": "1617196386967", + "component": "CheckboxGroup", + "name": "submission.topics", + "validate": [ + { + "value": "required", + "label": "Required" + } + ] + } + ], + "id": "submit", + "name": "NCRC Submission Form", + "description": "<p>NCRC Form</p>", + "haspopup": "false" +} diff --git a/server/model-manuscript/src/graphql.js b/server/model-manuscript/src/graphql.js index 7435cc6b387afa5fc4c5bf695cd154b6c8d12299..a9a028c8a1be861cf5c28e4b1b00e32a31eb4b75 100644 --- a/server/model-manuscript/src/graphql.js +++ b/server/model-manuscript/src/graphql.js @@ -62,7 +62,7 @@ const commonUpdateManuscript = async (_, { id, input }, ctx) => { ...manuscriptDelta.submission, }, } - + // if (manuscript.status === 'revise') { // return manuscript.createNewVersion(update) // } @@ -510,20 +510,21 @@ const resolvers = { async validateDOI(_, { articleURL }, ctx) { const DOI = encodeURI(articleURL.split('.org/')[1]) + try { await axios.get(`https://api.crossref.org/works/${DOI}/agency`) return { - isDOIValid: true + isDOIValid: true, } - } catch(err) { + } catch (err) { // eslint-disable-next-line console.log(err) return { - isDOIValid: false + isDOIValid: false, } } - } + }, }, // We want submission into to come out as a stringified JSON, so that we don't have to // change our queries if the submission form changes. We still want to store it as JSONB