From 773a044bad9a77ae1ffc3da0523b65c880ef1e0b Mon Sep 17 00:00:00 2001 From: Greg Rushton Date: Tue, 7 Nov 2023 09:37:59 -0500 Subject: [PATCH] editability changes --- src/pages/StudyUpdateForm.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pages/StudyUpdateForm.js b/src/pages/StudyUpdateForm.js index 3bf65c9a7..a51216c33 100644 --- a/src/pages/StudyUpdateForm.js +++ b/src/pages/StudyUpdateForm.js @@ -151,7 +151,7 @@ export const StudyUpdateForm = (props) => { const formatForRegistration = (formData) => { for (const key of Object.keys(formData)) { - const illegalStudyFields = [formData.studyName, formData.dataSubmitterEmail, formData.dataSubmitterName]; + const illegalStudyFields = ['studyName', 'dataSubmitterEmail', 'dataSubmitterName', 'dataSubmitterUserId']; if (isNil(formData[key]) && illegalStudyFields.includes(formData[key])) { formData[key] = undefined; } @@ -159,10 +159,21 @@ export const StudyUpdateForm = (props) => { formData?.consentGroups?.forEach((cg) => { const validCgFields = [cg.dataLocation, cg.url, cg.fileTypes, cg.numberOfParticipants, cg.dataAccessCommitteeId]; + // In the case of missing/required fields, we need to be able to populate them on save + // TODO: This doesn't work as expected + if (isNil(cg.consentGroupName) || cg?.consentGroupName.length === 0) { + validCgFields.push(cg.consentGroupName); + } + if (isNil(cg.accessManagement)) { + validCgFields.push(cg.accessManagement); + } + if (isNil(cg.dataAccessCommitteeId) && cg?.accessManagement === 'controlled') { + validCgFields.push(cg.dataAccessCommitteeId); + } - if(!isNil(cg.datasetId)){ + if (!isNil(cg.datasetId)) { for (const key of Object.keys(cg)) { - if(cg[key]!==cg.datasetId && !validCgFields.includes(cg[key])){ + if (cg[key] !== cg.datasetId && !validCgFields.includes(cg[key])) { cg[key] = undefined; } }