Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<!-- <script src="https://cdn.form.io/formiojs/formio.full.js"></script> -->
<!-- <script src="https://cdn.form.io/js/formio.embed.js"></script> -->

<link rel="icon" type="image/x-icon" href="favicon.ico">

<!-- Uses bootstrap for now -->
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel="stylesheet" href="css/styles.css">
Expand Down
70 changes: 38 additions & 32 deletions js/autoGenerateFields.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// We wait for DOM to be fully loaded before initializing
document.addEventListener("DOMContentLoaded", function() {
setupFormHandler();
setupNotificationSystem();
Expand Down Expand Up @@ -158,6 +157,20 @@ function preFillFields(repoData, languages) {
}

try {
const currentSubmission = {}

window.formIOInstance.components.forEach(component => {
if (component.components) {
component.components.forEach(nestedComp => {
if (nestedComp.key) {
currentSubmission[nestedComp.key] = nestedComp.getValue()
}
});
} else if (component.key) {
currentSubmission[component.key] = component.getValue()
}
})

let licenses = [];
if (repoData.license && repoData.license.spdx_id) {
licenses.push({
Expand All @@ -166,38 +179,31 @@ function preFillFields(repoData, languages) {
});
}

const submission = {
data: {
name: repoData.name || '',
description: repoData.description || '',

repositoryURL: repoData.html_url || '',
repositoryVisibility: repoData.private ? "private" : "public",
vcs: 'git',

permissions: {
licenses: licenses
},

reuseFrequency: {
forks: repoData.forks_count || 0
},

languages: Object.keys(languages) || [],

date: {
created: repoData.created_at || '',
lastModified: repoData.updated_at || '',
metaDataLastUpdated: new Date().toISOString()
},

tags: repoData.topics || [],

feedbackMechanisms: [repoData.html_url + "/issues"]
}
};
const newSubmission = {
name: repoData.name || '',
description: repoData.description || '',
repositoryURL: repoData.html_url || '',
repositoryVisibility: repoData.private ? "private" : "public",
vcs: 'git',
permissions: {
licenses: licenses
},
reuseFrequency: {
forks: repoData.forks_count || 0
},
languages: Object.keys(languages) || [],
date: {
created: repoData.created_at || '',
lastModified: repoData.updated_at || '',
metaDataLastUpdated: new Date().toISOString()
},
tags: repoData.topics || [],
feedbackMechanisms: [repoData.html_url + "/issues"]
}

window.formIOInstance.setSubmission(submission);
const mergedSubmission = { ...currentSubmission, ...newSubmission}

window.formIOInstance.setSubmission({ data: mergedSubmission })

} catch (error) {
notificationSystem.error("Error filling form fields with repository data. Please refresh and try again");
Expand Down