Skip to content

Commit

Permalink
add repo name check to study reg form (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfshao authored Nov 4, 2024
1 parent 1e1aa83 commit 54a2b0a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/StudyRegistration/StudyRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const StudyRegistration: React.FunctionComponent<StudyRegistrationProps> = (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,
};
Expand Down Expand Up @@ -309,8 +309,22 @@ const StudyRegistration: React.FunctionComponent<StudyRegistrationProps> = (prop
<Form.Item
name='repository'
label='Study Data Repository'
hasFeedback
help={(
rules={[
{
message: '"Study Data ID from Repository" field has been filled with values. Please select a Study Data Repository name here.',
},
({ getFieldValue }) => ({
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={(
<React.Fragment> If you have already selected a data repository, indicate it here;
otherwise, leave empty.<br />
If you have deposited your data and you have a unique Study ID for the data at
Expand Down

0 comments on commit 54a2b0a

Please sign in to comment.