Open emmavray opened 4 years ago
I know how to add custom types pretty easily, but there are a few problems:
I thought of two different ways to add custom data types to the JSON schema, one way made everything harder to use, the other way made custom types look strange and ugly compared to existing fields.
I could just have a question settings tacked onto everything and pass it to all the render callbacks, and let people put whatever extra fields in there that they want to.
questionSettings: {
/** existing fields **/
customSettings: {
/** anything imaginable **/
}
}
Super flexible, but hard to explain what is going on to first time users, though they probably wouldn't care.
My larger concern is numeric fields, there is some extra special stupid that goes on to make everything work cross-plat when fields are erased.
There'd also have to be a way to specify numeric or non-numeric results in the output JSON.
I don't believe TextInput cares if it is given actual text, so ignoring the issues above I could use the same logic.
How I'd do all of this is just allow any random prop render<CUSTOM>
and if I encounter a `questionType:<CUSTOM>
in the JSON I'd just call render<CUSTOM>
.
Also have to have a field saying if it is a SelectionGroup.
And it is about here where the JSON schema gets ugly. I guess I'd be ok with
questionSettings: {
/** existing fields **/
customSettings: {
fieldType: string||integer||double||object||selectionGroup
}
}
so maybe I'll go and do that. :)
At the same time I add support for non-integer numeric inputs.
Has any work been done on a questionType that would support date or time entry? In my use case it's fairly common for surveys to ask for a time of day (usually in 5 or 15min intervals), or sometimes a day of the month.
I might send pull request to add this type -- or maybe there's a better way to handle it? Maybe an API for custom types would be appropriate.