1
- // We wait for DOM to be fully loaded before initializing
2
1
document . addEventListener ( "DOMContentLoaded" , function ( ) {
3
2
setupFormHandler ( ) ;
4
3
setupNotificationSystem ( ) ;
@@ -158,6 +157,20 @@ function preFillFields(repoData, languages) {
158
157
}
159
158
160
159
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
+
161
174
let licenses = [ ] ;
162
175
if ( repoData . license && repoData . license . spdx_id ) {
163
176
licenses . push ( {
@@ -166,38 +179,31 @@ function preFillFields(repoData, languages) {
166
179
} ) ;
167
180
}
168
181
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
+ }
199
203
200
- window . formIOInstance . setSubmission ( submission ) ;
204
+ const mergedSubmission = { ...currentSubmission , ...newSubmission }
205
+
206
+ window . formIOInstance . setSubmission ( { data : mergedSubmission } )
201
207
202
208
} catch ( error ) {
203
209
notificationSystem . error ( "Error filling form fields with repository data. Please refresh and try again" ) ;
0 commit comments