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

Abstract JSON saving React form components to have a common back-end #68

Open
NightJar opened this issue Jan 6, 2019 · 3 comments
Open

Comments

@NightJar
Copy link
Contributor

NightJar commented Jan 6, 2019

From point 6 in #57

@robbieaverill suggests

React component architecture: similarly to the PHP FormFields, these React components all read from initial JSON value prop or state values, and store the state value in a hidden input as serialised JSON. We could centralise some of this logic too, potentially with an HOC, helper functions in a separate file or even a parent component.

@ScopeyNZ thinks this is a good idea

Yeah that seems like a pretty quick win to me. Updating the value might be a little more ambiguous though I guess. It'll be a bit like redux-form where the HOC has to supply an onChange prop that can be used to mutate the value of the field somehow.

Summary
This module consists of a number of form fields that read, parse, and present JSON blobs in a view - which then has a number of operable elements that can configure that blob and save it back to the system as a form submission.

There are common elements in this in that there is

  • the initial load of JSON data
  • saving JSON data
  • interaction elements to configure that JSON blob

At least two of these three points could be abstracted to use the same logic (loading & saving), and perhaps helpers could be made for the third point if it is not already a part of the saving logic.

@robbieaverill
Copy link
Contributor

Do we still want to do this? I can happily close it TBH

@ScopeyNZ
Copy link
Contributor

As with the other issue. I'd like to see it on admin. Ambivalent about it being done here.

@NightJar
Copy link
Contributor Author

I think it's not necessary now, but I don't think it's worth closing either (unless as @ScopeyNZ says, it's moved to silverstripe/admin instead). It's certainly something that should be tracked.

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

No branches or pull requests

4 participants