-
Notifications
You must be signed in to change notification settings - Fork 7
Form Input types v2
This document describes the various form input types available in the Chingu Dashboard and how to use them.
Input types are defined here https://github.com/chingu-x/chingu-dashboard-be/blob/dev/prisma/seed/data/input-types.ts
The parseConfig field in the database stores information on how questions and inputs should be rendered in the frontend. It is located in the question and option choices tables.
Multi-line text input default (textArea)

To add an icon to a text input, parseConfig would contain:
{
"icon": "iconName"
}[find an image]
one line text
URL input with validation

Single-choice radio button selection

In the question configuration, each option includes both a text template like {{greenRocket}} and a corresponding parseConfig object that specifies the icon name and URL. For example, an option might be configured as:
...
{
text: "{{greenRocket}} We have had a good start!",
parseConfig: {
icon: "greenRocket",
iconUrl: ".../greenRocket.png"
}
}When the input type is radio, the frontend can use the parseConfig to replace any template pattern {{iconName}} with the corresponding icon image. This allows for consistent icon mapping and easy icon asset management.

Group of radio buttons “radio group” is a group of questions (subQuestions in the database), they all have the same choices, and the same question ( question is saved in the “parent” question)

users Multiple-choice checkbox selection

checkboxes with team member, frontend to render the choices, and send selected as text back to the backend, e.g. Jane, Jackson

Numeric input
This could be a “yes/no”, “true/false” etc question. Each boolean question uses parseConfig to define the labels and their corresponding values.
The question is formatted with choice labels in a template string, followed by the question text:
{{yes,no}}Did you deploy to Production at the end of the sprint?
The parseConfig for this would look like:
...
parseConfig: {
yes: "Yes",
no: "No"
}Important
Note that in the parseConfig object:
- The
yesproperty defines the display text for the true value - The
noproperty defines the display text for the false value - The template labels (
{{yes,no}}) must match the parseConfig property names
This format allows you to customize how boolean choices are displayed to users while maintaining consistent true/false mapping in the backend.

Scale questions use parseConfig and optionGroup to create a numeric rating system with labeled endpoints. The question format combines scale labels within template brackets:
On a scale of 0-10, how likely are you to suggest Chingu to a friend or colleague?
The configuration includes:
{
"min": "Not Likely",
"max": "Extremely Likely"
}optionGroup: {
name: "chingu-scale",
optionChoices: [1,2,3,4,5,6,7,8,9,10]
}Important
The parseConfig defines the scale's endpoint labels, while the optionGroup creates the numeric choices available to users. The frontend uses this configuration to render a scale from 1-10 where:
- "Not Likely" labels the minimum end (1)
- "Extremely Likely" labels the maximum end (10)

Display-only image with no input

Display-only text with no input


This is a special type of dropdown, where choices do not come from the database. For country codes, they will come from the ISO-3166-1 package, populated by the frontend. The frontend will then send the selection to the backend as a "text". We will be able to use the same package to decode the country codes for display, search or sort.

This is similar to dropdown country, package used is date-fns-tz
To add an icon to an option:
[ find an image ]
The parseConfig would contain:
{
"icon": "checkIcon"
}add to the above after they are implemented
To hide a question for specific roles:
{{hidden-role: [1, 2]}} This question is hidden from roles 1 and 2
The parseConfig would contain:
{
"hidden-role": [1, 2]
}To show a question only for specific roles:
{{applicableForRoles: [3, 4]}} This question is only shown for roles 3 and 4
The parseConfig would contain:
{
"applicableForRoles": [3, 4]
}To create an "Other" option that allows user input:
{{icon: pencilIcon}} Other (please specify)
The parseConfig would contain:
{
"icon": "pencilIcon",
"followup": true
}When a user selects this option, they will be prompted to provide additional text input.
Options can be sorted using the order field in the OptionChoice model. Options will be displayed in ascending order based on this field.
Options can have descriptions using the description field in the OptionChoice model. These descriptions can provide additional context or explanation for each option.
Questions and options can be conditionally shown or hidden based on user roles. This is implemented using the parseConfig field with either hidden-role or applicableForRoles properties.
Instead of having separate radio and radioIcon input types, we now use the radio input type with parse options to specify icons:
{{icon: iconName}} Option Text
The icon information is stored in the parseConfig field of the OptionChoice model.