blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

better `generate all` forms #367

Closed Vandivier closed 2 years ago

Vandivier commented 2 years ago

What do you want and why?

As a developer, I would like appropriately detailed forms to be generated based on my model, so that I can save time!

Possible implementation(s)

when making new.tsx, add additional input fields based on the model. this could get complex quickly, but a simple starting point would be to do this only for string fields. So instead of a name input, there would be a LabeledTextField for each string field on the new model.

also the mutation could be updated appropriately, eg:

const CreateContact = z.object({
  name: z.string(),
})

Additional context

longer-term, it would be cool to automatically make a drop down so that I can pick a user. for example, consider a "Task" model or a "Contact" model like: blitz generate all contact firstName lastName phone address addressLine2 city state zip email belongsTo:user?

then a dropdown that is prepopulated with users could be provided so that I can pick a user by a readable name instead of having to look up ID in a DB

roshan-sama commented 2 years ago

Those are cool suggestions! Some of that is done in the linked PR.

When you mention the dropdown, I'm assuming this is for a form where we're creating a new record that belongs to a user, and we want a dropdown (and potentially a search filter in it) that shows a list of users that should be associated with the record right?

I'm actually not sure how we handle field relationships in the linked PR so gonna look into that actually, but it think it might be better to do that in a separate PR and ship what we have so far first, but up to Brandon and Aleksandra

beerose commented 2 years ago

but it think it might be better to do that in a separate PR and ship what we have so far first

Yep, agree!

@Vandivier I think this issue: https://github.com/blitz-js/blitz/issues/2038 covers some of your points. The additional thing would be the dropdown, right?

beerose commented 2 years ago

I marked it as blocked, so that we merge @Roesh's PR first.

beerose commented 2 years ago

I'm going to close this issue as a duplicate of: https://github.com/blitz-js/blitz/issues/2038. Feel free to open a new one for all the additional features that are not included in https://github.com/blitz-js/blitz/issues/2038.

Vandivier commented 2 years ago

yall rock, thank you!!