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

Derive title from property name in case it is missing #9

Open
kutyel opened this issue Mar 14, 2024 · 2 comments
Open

Derive title from property name in case it is missing #9

kutyel opened this issue Mar 14, 2024 · 2 comments

Comments

@kutyel
Copy link

kutyel commented Mar 14, 2024

Hello again! I just wonder if I should open this issue here or in the json-schema repo.

According to some specification here:

If there is no UI schema label and no JSON Schema title, the label will be derived from the property name

Is this easily implementable here in a decoder or should it be handled by the json-schema decoder?

Let me know your thoughts and thanks for the quick responses! 🙇🏻

@kutyel
Copy link
Author

kutyel commented Mar 15, 2024

Managed to do it by refactoring the fieldTitle function:

fieldTitle : SubSchema -> Path -> Maybe (Html F.Msg)
fieldTitle schema path =
    schema.title
        -- If it does not have a title, derive from property name, unCamelCasing it
        |> Maybe.orElse (List.last path |> Maybe.map (String.Case.convertCase " " True True))
        |> Maybe.map (\str -> span [ class "label-text" ] [ text str ])

I can provide a PR if you think this is correct 😉

(I was unsure if Path could be more than a list with one element, so I used List.last instead of List.head but maybe that is wrong and it is safe to just use List.head here? 🤔 )

@niho
Copy link
Owner

niho commented Mar 20, 2024

I emailed Tomáš the other day with a consulting proposal where I can help you guys out with adapting the json-schema-form package to work with the JSON Form standard (implement all the layout stuff, etc.) and perhaps help you out with how to best use/integrate the package and how to design your forms to be user friendly etc. I have quite a lot of deep experience in building and designing declarative data driven forms in Elm.

Is this something you guys would be interested in? I don't know if Tomáš is the right person to reach out to about this, since I haven't gotten a reply yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants