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

Provide a ordered pretty print for formEditor.getSchema #881

Open
pinussilvestrus opened this issue Nov 3, 2023 · 1 comment
Open

Provide a ordered pretty print for formEditor.getSchema #881

pinussilvestrus opened this issue Nov 3, 2023 · 1 comment
Labels
backlog Queued in backlog enhancement New feature or request needs discussion Needs further discussion spring cleaning Could be cleaned up one day

Comments

@pinussilvestrus
Copy link
Contributor

pinussilvestrus commented Nov 3, 2023

Is your feature request related to a problem? Please describe.

As a user of our form editor, I might want to edit the form JSON manually, e.g. via my favorite IDE. In that case, it's hard for me to browse the schema as a form field properties are randomly ordered and don't follow the structure of the properties panel.

Example: The general properties like label, description and key comes first in the user interface, but sometimes last in the respective schema. This makes it harder to visually scan for a specific form field in the schema, where I'd rather look for a label instead of the values. This becomes even more important as forms tend to become more complex these days.

image
{
  "values": [
    {
      "label": "German",
      "value": "german"
    },
    {
      "label": "English",
      "value": "english"
    }
  ],
  "id": "Select_1",
  "key": "language",
  "label": "Language",
  "type": "select"
}

Describe the solution you'd like

Provide an option to export the schema by an ordered pretty print that follows the order of the properties panel.

We could consider making this the default behavior on export.

Describe alternatives you've considered

Decide that raw JSON editing is not a supported use case and do nothing.

Additional context

Cf. this slack thread from @falko.

@pinussilvestrus pinussilvestrus added enhancement New feature or request backlog Queued in backlog needs discussion Needs further discussion spring cleaning Could be cleaned up one day labels Nov 3, 2023
@Skaiir
Copy link
Contributor

Skaiir commented Nov 27, 2023

So, we can't really do this easily without defining the order that we want. And the order is currently programmatically defined in a way which is a bit challenging to extract.

I'm not against raw editing, after all that's not a concern of form-js, but rather whatever's implementing it. So I think the way to go would be to restructure our properties panel entries into a more flexible and descriptive format. Something like defining the entries in a structured array, and then building it up from the array (as opposed to what we currently do where we call a bunch of constructor functions, which doesn't really help us). Then we can have a utility which makes use of the structured away to build up the ordered printed schema, and finally offer an API to get said printed schema.

This does get a little more complicated when nesting is involved, but still programmatically shouldn't be a huge task. Anyways because this is going to create a ton of conflicts (and is low prio), let's leave this one to after a release, probably not the next :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog enhancement New feature or request needs discussion Needs further discussion spring cleaning Could be cleaned up one day
Projects
None yet
Development

No branches or pull requests

2 participants