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

Add optional schema definitions to data skeleton #25

Open
BigJk opened this issue Dec 22, 2022 · 3 comments
Open

Add optional schema definitions to data skeleton #25

BigJk opened this issue Dec 22, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@BigJk
Copy link
Owner

BigJk commented Dec 22, 2022

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.

@carlosfrodrigues
Copy link

Hi, I'm interested in this one. Could you assign this for me?

@BigJk
Copy link
Owner Author

BigJk commented Jun 1, 2023

@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

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 😃

@carlosfrodrigues
Copy link

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! 🙏

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

No branches or pull requests

2 participants