snd
snd copied to clipboard
Add optional schema definitions to data skeleton
Currently the "schema" of a templates data is derived kinda vaguely from the data skeleton. This is a relic from S&D just being a small proof-of-concept type of application at the beginning. Defining a image in the data skeleton already introduced a additional syntax inside the JSON.
{
"icon": "!IMAGE"
}
it the future it should be possible to OPTIONALLY define what input should be shown for a field + some kind of default value for a preview while editing. A example to illustrate the idea:
{
"name": "!TEXT=Default Name",
"description": "!TEXTAREA=Some long default text",
"number": "!NUMBER=0",
"dropdown": "!DROPDOWN:A,B,C=A"
}
That way we can map custom components to the same data types and which should make entry creation and editing more pleasant.
Hi, I'm interested in this one. Could you assign this for me?
@carlosfrodrigues Thanks for your interest. Feel free to just fork the project and start hacking 😃 I'm always open to merging pull requests that seems reasonable. If any questions come up we can discuss them here or over discord.
Some thoughts
- The schema definitions should be optional, so if no definitions are included it should stick to the automatic detection like now
- The generator and global settings feature of S&D already has the typical components implemented. Would be great if we can re-use them. Some clues:
- The config components: https://github.com/BigJk/snd/tree/master/frontend/src/js/ui/components/config
- Where its used in the generator: https://github.com/BigJk/snd/blob/master/frontend/src/js/ui/components/generator-config.jsx
- Where its used in the template global config: https://github.com/BigJk/snd/blob/master/frontend/src/js/ui/components/template-config.jsx
- The
!IMAGEtag should maybe be extended to take a optional default url like!IMAGE=https://.../some_test_image.pngso that a test image can be shown while editing the template - The skeleton system over all is a bit clunky. Most of the "skeleton to editable entries" stuff is done here: https://github.com/BigJk/snd/blob/master/frontend/src/js/ui/components/entry-edit.jsx
Objects and Arrays of Objects
Something that should be thought about is how the handling of sub-objects, arrays of objects, arrays of objects in sub-objects... should be handled in regards to the schema. Imagine the following data:
{
"obj": { "field_a": "test", "field_b": 1234 },
"arr": [
{ "field_a": "test", "field_b": 1234 },
{ "field_a": "test", "field_c": ["a", "b", "c"] }
]
}
How should this be described by the schema?
{
"obj": { "field_a": "!TEXT=default", "field_b": "!NUMBER=1234" },
"arr": [
// Do we describe the schema of the elements in a array
// by inserting a single object with definitions?
{
"field_a": "!TEXT=default",
"field_b": "!NUMBER=1234",
"field_c": "!MULTI_OPT:a,b,c=a"
}
]
}
I feel like there are a lot of questions that might need to be investigated before actually implementing something.
- Is the syntax even adequate enough?
- What are other edge cases?
- Do we even want to try to squeeze 2 "systems" into one or would it be better to make the schema separate albeit optional so that we are not bound to the current JSON handling?
Feel free to share your thoughts 😃
Hi @BigJk ! 👋
I've just submitted a pull request (#50) for review. Please note that this PR is primarily for review purposes, and some functionalities, like the dropdown, are not yet fully functional.
I'd really appreciate it if you could take some time to review the changes I've made so far and provide feedback. Once we address the remaining issues, I'll ensure everything works smoothly.
Thank you for your attention and feedback! 🙏