1- // We wait for DOM to be fully loaded before initializing
21document . addEventListener ( "DOMContentLoaded" , function ( ) {
32 setupFormHandler ( ) ;
43 setupNotificationSystem ( ) ;
@@ -158,6 +157,20 @@ function preFillFields(repoData, languages) {
158157 }
159158
160159 try {
160+ const currentSubmission = { }
161+
162+ window . formIOInstance . components . forEach ( component => {
163+ if ( component . components ) {
164+ component . components . forEach ( nestedComp => {
165+ if ( nestedComp . key ) {
166+ currentSubmission [ nestedComp . key ] = nestedComp . getValue ( )
167+ }
168+ } ) ;
169+ } else if ( component . key ) {
170+ currentSubmission [ component . key ] = component . getValue ( )
171+ }
172+ } )
173+
161174 let licenses = [ ] ;
162175 if ( repoData . license && repoData . license . spdx_id ) {
163176 licenses . push ( {
@@ -166,38 +179,31 @@ function preFillFields(repoData, languages) {
166179 } ) ;
167180 }
168181
169- const submission = {
170- data : {
171- name : repoData . name || '' ,
172- description : repoData . description || '' ,
173-
174- repositoryURL : repoData . html_url || '' ,
175- repositoryVisibility : repoData . private ? "private" : "public" ,
176- vcs : 'git' ,
177-
178- permissions : {
179- licenses : licenses
180- } ,
181-
182- reuseFrequency : {
183- forks : repoData . forks_count || 0
184- } ,
185-
186- languages : Object . keys ( languages ) || [ ] ,
187-
188- date : {
189- created : repoData . created_at || '' ,
190- lastModified : repoData . updated_at || '' ,
191- metaDataLastUpdated : new Date ( ) . toISOString ( )
192- } ,
193-
194- tags : repoData . topics || [ ] ,
195-
196- feedbackMechanisms : [ repoData . html_url + "/issues" ]
197- }
198- } ;
182+ const newSubmission = {
183+ name : repoData . name || '' ,
184+ description : repoData . description || '' ,
185+ repositoryURL : repoData . html_url || '' ,
186+ repositoryVisibility : repoData . private ? "private" : "public" ,
187+ vcs : 'git' ,
188+ permissions : {
189+ licenses : licenses
190+ } ,
191+ reuseFrequency : {
192+ forks : repoData . forks_count || 0
193+ } ,
194+ languages : Object . keys ( languages ) || [ ] ,
195+ date : {
196+ created : repoData . created_at || '' ,
197+ lastModified : repoData . updated_at || '' ,
198+ metaDataLastUpdated : new Date ( ) . toISOString ( )
199+ } ,
200+ tags : repoData . topics || [ ] ,
201+ feedbackMechanisms : [ repoData . html_url + "/issues" ]
202+ }
199203
200- window . formIOInstance . setSubmission ( submission ) ;
204+ const mergedSubmission = { ...currentSubmission , ...newSubmission }
205+
206+ window . formIOInstance . setSubmission ( { data : mergedSubmission } )
201207
202208 } catch ( error ) {
203209 notificationSystem . error ( "Error filling form fields with repository data. Please refresh and try again" ) ;
0 commit comments