Skip to content

Generate Pub Forms#118

Merged
gabestein merged 52 commits into
mainfrom
gs/pubvalue-types
Oct 2, 2023
Merged

Generate Pub Forms#118
gabestein merged 52 commits into
mainfrom
gs/pubvalue-types

Conversation

@gabestein
Copy link
Copy Markdown
Member

@gabestein gabestein commented Sep 27, 2023

Issue(s) Resolved

Resolves #108 #57

Caveats:

  • There's a big merge that's needed that I may need some help with to use field slugs, primarily.
  • I have not yet switched validators from ajv because, with one small typescript warning, this just seems to work for now.
  • There's some work to do to make it more type-safe.
  • We should probably be doing some server-side validation of submitted values against fields.
  • To get the pubTypeId, I had to re-add the evaluate action to the seed (see comment).
  • It only handles string and number inputs so far (but adding additional form handlers is trivial).

Description:
At the base, this adds a few functions to @pubpub/sdk that takes a pubType, concatenates all of its pubFieldSchemas into a JSONSchema, and generates form fields from that schema.

There's a new database table for this, pubFieldSchema, which allows anyone to define a schema that can then be associated with a field. At the moment, these schemas are not associated with a community, with the idea that they should be reusable. But they could optionally be associated with one if we wanted to have private schemas.

To accomplish this with the evaluations integration, this also adds an integrations API route to fetch a pub type, and rewrites the evaluation form slightly to accommodate any set of values to stuff into a pub, rather than specific ones. It also adds automated form validation by using ajv's react-hooks-former resolver against the generated schema.

Test Plan

  • Submit a new pub
  • Move to Under Evaluation
  • Write evaluation
  • Submit evaluation

Screenshots (if applicable)

Optional

Notes/Context/Gotchas

Supporting Docs

@isTravis isTravis temporarily deployed to gs/pubvalue-types - integration-evaluations PR #118 September 28, 2023 22:58 — with Render Destroyed
@isTravis isTravis temporarily deployed to gs/pubvalue-types - core PR #118 September 28, 2023 22:58 — with Render Destroyed
@gabestein
Copy link
Copy Markdown
Member Author

ok @3mcd, got this back to working, so it's ready to look at/discuss on Monday! Have a great weekend.

@isTravis isTravis temporarily deployed to gs/pubvalue-types - core PR #118 October 2, 2023 20:05 — with Render Destroyed
@isTravis isTravis temporarily deployed to gs/pubvalue-types - integration-evaluations PR #118 October 2, 2023 20:05 — with Render Destroyed
@isTravis isTravis temporarily deployed to gs/pubvalue-types - integration-submissions PR #118 October 2, 2023 20:05 — with Render Destroyed
@gabestein gabestein merged commit d13107f into main Oct 2, 2023
@gabestein gabestein deleted the gs/pubvalue-types branch October 2, 2023 20:06
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

Successfully merging this pull request may close these issues.

Spike: Form generators / (de)serializers

4 participants