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

Create dynamic form based off ScoutForm objects #7

Open
AM2i9 opened this issue May 13, 2022 · 0 comments
Open

Create dynamic form based off ScoutForm objects #7

AM2i9 opened this issue May 13, 2022 · 0 comments
Assignees
Labels
app App side

Comments

@AM2i9
Copy link
Contributor

AM2i9 commented May 13, 2022

The idea behind the "form" is to be able to configure what questions the person using the app will be asked when scouting. It's easier to receive this data from a central point (the server), interpret it, and then display it than it is to have to re-program the app every year.

Currently, when syncing, the server sends over a ScoutForm object, which can be imported from package:scoutingapp/components/common/form.dart, which contains objects that look like this:

InputType (enum)
- boolean: A yes or no, true or false input
- multiselect: A multiselect input, like a dropdown. Each option is a SelectOption
- text: A regular text input
- number: A number input box

SelectOption
- value: Value of the option, what is actually read and stored in the scout data
- label: Display value, what can be show in the app. Can be different or the same

Question
- id: ID for the question, which will be used to store the data. Should be unique.
- title: Title of the question, for example: "How many balls did they make in the upper hub?" (or something shorter, like "Upper hub")
- type: One of InputType. enums are used by doing InputType.<value>, for example: InputType.boolean
- options (optional): A list of SelectOptions. This only needs to be used if using InputType.multiselect

ScoutForm
- id: ID of the form, used to fetch it. Should be unique.
- name: Name of the form, can be used as a title
- questions: List of Question objects

The form will be recieved by the app as a ScoutForm object, meaning that to display the form, you need to loop over the questions attribute, and create an input on the app based off the values in each Question. Something similar to this.

You can use the below code to create a ScoutForm to test from, or you can feel free to write your own test.

ScoutForm form = ScoutForm(id: 'testform', name: 'Test Form', questions: [
  Question(id: "yn", title: "Yes or no question", type: InputType.boolean),
  Question(id:"multi", title: "Multi-select question", type: InputType.multiselect, options: [
    SelectOption(value: "1", label: "Option 1"),
    SelectOption(value: "2", label: "Option 2"),
    SelectOption(value: "3", label: "Option 3"),
  ]),
  Question(id: "text", title: "Text question", type: InputType.text),
  Question(id: "num", title: "Number question", type: InputType.number),
]);

// Can do something like this to loop over the questions
form.questions.map((e) => {...})

ScoutForm and other objects: form.dart

@AM2i9 AM2i9 added the app App side label May 13, 2022
@blcrdbob3 blcrdbob3 self-assigned this May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app App side
Projects
None yet
Development

No branches or pull requests

2 participants