Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created MVP #2

Merged
merged 7 commits into from
Dec 11, 2024
Merged

Created MVP #2

merged 7 commits into from
Dec 11, 2024

Conversation

natalialuzuriaga
Copy link
Contributor

@natalialuzuriaga natalialuzuriaga commented Dec 3, 2024

Created MVP

Problem

We would like to generate a form based on a given json schema. We plan to use this to create a form website where users can input information about their project to create code.json for their repository.

Solution

This PR is an MVP of the form generator! We use Form.io to create the form. On a high level, this does the following:

  • form.html contains the form. USWDS does not work at the moment (see: Problems running HTML code locally formio/uswds#260) so we are temporarily using bootstrap.
  • Uses schemas/schema.json as the input json schema
  • js/generateFormComponents.js reads the input schema and creates Form.io components for each field. For now, text fields / string types are only supported.
  • To create the output file, a blank code.json file is needed: schemas/template-code.json
  • js/formDataToJson.js reads the blank json file, converts it to an object, populates the object with form data, and downloads file to the user's machine

Result

Users can generate forms using json schemas that only have fields with type: string. As a result, the form only contains text fields.

When users fill out the form and click submit, the code.json is generated and downloaded onto their machine.

Test Plan

  1. Start up a HTTP server using python: python3 -m http.server 8000
  2. Click on form.html
  3. Here is the form! Right click -> Inspect to open dev tools
  4. Fill out the form
  5. Click submit and downloads code.json. File contents should match what was submitted in the form!

Will create unit tests in a separate PR after OSAB

Signed-off-by: Natalia Luzuriaga <[email protected]>
Signed-off-by: Natalia Luzuriaga <[email protected]>
Copy link

@DinneK DinneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm able to click form, fill in and I receive a code.json file.

@natalialuzuriaga natalialuzuriaga merged commit 3ef95dc into main Dec 11, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants