From 5e0aa613984a80bc44852aaa083cf73d94ddedca Mon Sep 17 00:00:00 2001 From: Natalia Luzuriaga Date: Tue, 7 Jan 2025 13:03:51 -0500 Subject: [PATCH 1/5] Added container component for field with object type Signed-off-by: Natalia Luzuriaga --- js/generateFormComponents.js | 49 ++++++++++++++++++++++++++++-------- schemas/schema-0.0.0.json | 2 ++ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/js/generateFormComponents.js b/js/generateFormComponents.js index d8174b9..b792fa8 100644 --- a/js/generateFormComponents.js +++ b/js/generateFormComponents.js @@ -23,7 +23,9 @@ function transformArrayToOptions(arr) { } function determineType(field) { - if (field.type === "array") { + if (field.type === "object") { + return "container"; + } else if (field.type === "array") { // Multi-select if (field.items.hasOwnProperty("enum")) { return "selectboxes"; @@ -148,7 +150,7 @@ function createComponent(fieldName, fieldObject) { "maxDate": null }, description: fieldObject["description"] - } + }; case "select-boolean": return { "label": fieldName, @@ -171,7 +173,17 @@ function createComponent(fieldName, fieldObject) { "type": "select", "input": true, description: fieldObject["description"] - } + }; + case "container": + return { + label: fieldName, + tableView: false, + validateWhenHidden: false, + key: fieldName, + type: "container", + input: true, + components: [] + }; default: break; } @@ -182,6 +194,28 @@ function createFormHeading(title, description) { container.innerHTML = `

${title}

\n

${description}

`; } +function createAllComponents(schema, prefix = ""){ + let components = []; + + console.log("checking schema", schema); + + if (schema.type === "object" && schema.properties) { + for (const [key, value] of Object.entries(schema.properties)) { + + const fullKey = prefix ? `${prefix}.${key}` : key; + + var fieldComponent = createComponent(key, value); + + if (fieldComponent.type === "container") { + fieldComponent.components = createAllComponents(value, fullKey); + } + components.push(fieldComponent); + } + } + + return components; +} + // Iterates through each json field and creates component array for Form.io async function createFormComponents() { let components = []; @@ -193,14 +227,7 @@ async function createFormComponents() { createFormHeading(jsonData["title"], jsonData["description"]); - formFields = jsonData["properties"]; - console.log("form Fields:", formFields); - - for (const key in formFields) { - console.log(`${key}:`, formFields[key]); - var fieldComponent = createComponent(key, formFields[key]); - components.push(fieldComponent); - } + components = createAllComponents(jsonData); // Add submit button to form components.push({ diff --git a/schemas/schema-0.0.0.json b/schemas/schema-0.0.0.json index 36955a1..ab8ebdb 100644 --- a/schemas/schema-0.0.0.json +++ b/schemas/schema-0.0.0.json @@ -182,6 +182,7 @@ }, "date": { "type": "object", + "description": "A date object describing the release", "properties": { "created": { "type": "string", @@ -209,6 +210,7 @@ }, "contact": { "type": "object", + "description": "Point of contact for the release", "properties": { "email": { "type": "string", From 81411e92351a0f9b26722d873908494592ac8104 Mon Sep 17 00:00:00 2001 From: Natalia Luzuriaga Date: Tue, 7 Jan 2025 14:21:26 -0500 Subject: [PATCH 2/5] Updated blank code.json to include fields now supported Signed-off-by: Natalia Luzuriaga --- schemas/template-code.json | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/schemas/template-code.json b/schemas/template-code.json index 6499a37..7a355ab 100644 --- a/schemas/template-code.json +++ b/schemas/template-code.json @@ -1,6 +1,7 @@ { "name": "", - "softwareDescription": "", + "description": "", + "longDescription": "", "status": "", "organization": "", "vcs": "", @@ -10,6 +11,19 @@ "softwareType": [""], "languages": [""], "maintenance": "", - "lastModified": "", - "localisation": "" + "date": [""], + "tags": [""], + "contact": { + "email": "", + "name": "" + }, + "localisation": "", + "repositoryType": "", + "userInput": "", + "fismaLevel": "", + "group": "", + "subsetInHealthcare": "", + "userType": "", + "repositoryHost": "", + "maturityModelTier": "" } From 716d3a627d3f6f8245fa6bc7ff73816985e4fa00 Mon Sep 17 00:00:00 2001 From: Natalia Luzuriaga Date: Tue, 7 Jan 2025 14:25:04 -0500 Subject: [PATCH 3/5] Added repositoryURL to schema Signed-off-by: Natalia Luzuriaga --- schemas/schema-0.0.0.json | 7 ++++++- schemas/template-code.json | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/schemas/schema-0.0.0.json b/schemas/schema-0.0.0.json index ab8ebdb..46f0317 100644 --- a/schemas/schema-0.0.0.json +++ b/schemas/schema-0.0.0.json @@ -42,7 +42,7 @@ "items": { "type": "object", "properties": { - "url": { + "URL": { "type": "string", "format": "uri", "description": "The URL of the release license" @@ -110,6 +110,11 @@ "Centers for Medicare & Medicaid Services" ] }, + "repositoryURL": { + "type": "string", + "format": "uri", + "description": "The URL of the public release repository for open source repositories. This field is not required for repositories that are only available as government-wide reuse or are closed (pursuant to one of the exemptions)." + }, "vcs": { "type": "string", "description": "Version control system used", diff --git a/schemas/template-code.json b/schemas/template-code.json index 7a355ab..e95dfec 100644 --- a/schemas/template-code.json +++ b/schemas/template-code.json @@ -4,6 +4,7 @@ "longDescription": "", "status": "", "organization": "", + "repositoryURL": "", "vcs": "", "laborHours": 0, "platforms": [""], From c50384922c8bde4da7e4c8622b424b3dd480e1b7 Mon Sep 17 00:00:00 2001 From: Natalia Luzuriaga Date: Tue, 7 Jan 2025 14:55:27 -0500 Subject: [PATCH 4/5] Add repositoryURL to required array Signed-off-by: Natalia Luzuriaga --- js/generateFormComponents.js | 3 +-- schemas/schema-0.0.0.json | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/generateFormComponents.js b/js/generateFormComponents.js index b792fa8..bd0d377 100644 --- a/js/generateFormComponents.js +++ b/js/generateFormComponents.js @@ -58,7 +58,7 @@ function createComponent(fieldName, fieldObject) { label: fieldName, input: true, tooltip: fieldObject["description"], - description: fieldObject["description"], + description: fieldObject["description"] }; case "tags": return { @@ -219,7 +219,6 @@ function createAllComponents(schema, prefix = ""){ // Iterates through each json field and creates component array for Form.io async function createFormComponents() { let components = []; - let formFields = {}; const filePath = "schemas/schema.json"; let jsonData = await retrieveFile(filePath); diff --git a/schemas/schema-0.0.0.json b/schemas/schema-0.0.0.json index 46f0317..45141eb 100644 --- a/schemas/schema-0.0.0.json +++ b/schemas/schema-0.0.0.json @@ -317,6 +317,7 @@ "status", "permissions", "organization", + "repositoryURL", "vcs", "laborHours", "platforms", From b8b485a6d3d9d0bd60f6ad4a2e8395709e86be21 Mon Sep 17 00:00:00 2001 From: Natalia Luzuriaga Date: Tue, 7 Jan 2025 15:04:22 -0500 Subject: [PATCH 5/5] Updated options for repositoryHost Signed-off-by: Natalia Luzuriaga --- js/generateFormComponents.js | 84 ++++++++++++++++++------------------ schemas/schema-0.0.0.json | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/js/generateFormComponents.js b/js/generateFormComponents.js index bd0d377..629798f 100644 --- a/js/generateFormComponents.js +++ b/js/generateFormComponents.js @@ -85,7 +85,7 @@ function createComponent(fieldName, fieldObject) { key: fieldName, type: "number", input: true, - description: fieldObject["description"], + description: fieldObject["description"] }; case "radio": var options = transformArrayToOptions(fieldObject.enum); @@ -119,59 +119,59 @@ function createComponent(fieldName, fieldObject) { }; case "datetime": return { - "label": fieldName, - "tableView": false, - "datePicker": { - "disableWeekends": false, - "disableWeekdays": false + label: fieldName, + tableView: false, + datePicker: { + disableWeekends: false, + disableWeekdays: false }, - "enableMinDateInput": false, - "enableMaxDateInput": false, - "validateWhenHidden": false, - "key": fieldName, - "type": "datetime", - "input": true, - "widget": { - "type": "calendar", - "displayInTimezone": "viewer", - "locale": "en", - "useLocaleSettings": false, - "allowInput": true, - "mode": "single", - "enableTime": true, - "noCalendar": false, - "format": "yyyy-MM-dd hh:mm a", - "hourIncrement": 1, - "minuteIncrement": 1, - "time_24hr": false, - "minDate": null, - "disableWeekends": false, - "disableWeekdays": false, - "maxDate": null + enableMinDateInput: false, + enableMaxDateInput: false, + validateWhenHidden: false, + key: fieldName, + type: "datetime", + input: true, + widget: { + type: "calendar", + displayInTimezone: "viewer", + locale: "en", + useLocaleSettings: false, + allowInput: true, + mode: "single", + enableTime: true, + noCalendar: false, + format: "yyyy-MM-dd hh:mm a", + hourIncrement: 1, + minuteIncrement: 1, + time_24hr: false, + minDate: null, + disableWeekends: false, + disableWeekdays: false, + maxDate: null }, description: fieldObject["description"] }; case "select-boolean": return { - "label": fieldName, - "widget": "html5", - "tableView": true, - "data": { - "values": [ + label: fieldName, + widget: "html5", + tableView: true, + data: { + values: [ { - "label": "True", - "value": "true" + label: "True", + value: "true" }, { - "label": "False", - "value": "false" + label: "False", + value: "false" } ] }, - "validateWhenHidden": false, - "key": fieldName, - "type": "select", - "input": true, + validateWhenHidden: false, + key: fieldName, + type: "select", + input: true, description: fieldObject["description"] }; case "container": diff --git a/schemas/schema-0.0.0.json b/schemas/schema-0.0.0.json index 45141eb..7f7a0ff 100644 --- a/schemas/schema-0.0.0.json +++ b/schemas/schema-0.0.0.json @@ -293,7 +293,7 @@ "description": "Location where source code is hosted", "enum": [ "github.com/CMSgov", - "github.com/CMSgov", + "github.com/CMS-Enterprise", "github.cms.gov", "CCSQ GitHub" ]