From 54a2b0a555a822e874cfa35dacf00ef64ab5b32f Mon Sep 17 00:00:00 2001 From: Mingfei Shao <2475897+mfshao@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:35:40 -0600 Subject: [PATCH] add repo name check to study reg form (#1630) --- src/StudyRegistration/StudyRegistration.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/StudyRegistration/StudyRegistration.tsx b/src/StudyRegistration/StudyRegistration.tsx index afdfee7ce..851273885 100644 --- a/src/StudyRegistration/StudyRegistration.tsx +++ b/src/StudyRegistration/StudyRegistration.tsx @@ -168,7 +168,7 @@ const StudyRegistration: React.FunctionComponent = (prop const ctgovID = formValues.clinical_trials_id; const valuesToUpdate = { repository: formValues.repository || '', - repository_study_ids: ((!formValues.repository_study_ids || formValues.repository_study_ids[0] === '') ? [] : formValues.repository_study_ids), + repository_study_ids: ((!formValues.repository_study_ids || (formValues.repository_study_ids.length === 1 && formValues.repository_study_ids[0] === '')) ? [] : formValues.repository_study_ids), clinical_trials_id: ctgovID || '', clinicaltrials_gov: ctgovID ? await getClinicalTrialMetadata(ctgovID) : undefined, }; @@ -309,8 +309,22 @@ const StudyRegistration: React.FunctionComponent = (prop ({ + validator(_, value) { + const repositoryStudyIDs = getFieldValue('repository_study_ids'); + const doesRepositoryStudyIDsHaveValue = repositoryStudyIDs && !(repositoryStudyIDs.length === 1 && repositoryStudyIDs[0] === ''); + if (!doesRepositoryStudyIDsHaveValue || (doesRepositoryStudyIDsHaveValue && value)) { + return Promise.resolve(); + } + return Promise.reject(new Error('"Study Data ID from Repository" field has been filled with values. Please select a Study Data Repository name here.')); + }, + }), + ]} + extra={( If you have already selected a data repository, indicate it here; otherwise, leave empty.
If you have deposited your data and you have a unique Study ID for the data at