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

Add support for setting / modifying all fields of a form at once #35

Merged
merged 5 commits into from
Oct 20, 2018

Conversation

thomashoneyman
Copy link
Owner

@thomashoneyman thomashoneyman commented Oct 20, 2018

What does this pull request do?

Solves #31 by adding SetAll and ModifyAll queries, so a user can provide a new set of input values to overwrite the current ones, or a new set of input functions to modify existing inputs.

In addition, Formless now exports query / action functions for every query, instead of only the modify / validate variants, so a user can use F.setAll_, F.reset_, etc, and adds documentation for each one. This is because a) it's necessary to provide some helpers for creating queries for things like Modify which require injecting a variant; and b) there are more helper queries than actual queries in the component, to keep the component simpler. There was also some confusion in Slack recently over why some queries were just data constructors and others were functions.

Other Notes:

As implemented, I require that you use wrapInputFields or wrapInputFunctions to wrap your new record of inputs / input functions rather than supply a plain record. This is due to needing to prove that you are providing a form Record InputField or form Record InputFunction that is identical to the current form in the component.

Example:

H.query unit $ F.setValidateAll_ $ F.wrapInputFields { foo: 1, bar: "x", baz: false }
H.query unit $ F.modifyAll_ $ F.wrapInputFunctions { foo: (+) 1, bar: (<>) "x", baz: not }

@thomashoneyman thomashoneyman added this to the 0.3.0 milestone Oct 20, 2018
@thomashoneyman thomashoneyman self-assigned this Oct 20, 2018
@thomashoneyman thomashoneyman merged commit 0fbdfe8 into modify-set Oct 20, 2018
@thomashoneyman thomashoneyman deleted the setall-modifyall branch October 20, 2018 18:43
. Query pq cq cs form m Unit
-> Query pq cq cs form m Unit
-> Query pq cq cs form m Unit
andThen_ a b = AndThen a b unit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just playin

Copy link
Owner Author

@thomashoneyman thomashoneyman Oct 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just absolutely ludicrous. The sort of thing I'd expect from @crcornwell. How did you even find that?

@dariooddenino
Copy link

I'm not sure if I missed something, but I couldn't find setValidateAll and modifyValidateAll anywhere! 😄

F.setAll_ $ F.wrapInputFields { ... } `F.andThen_` F.validateAll_ is still better than what I was doing before anyways though!

@thomashoneyman
Copy link
Owner Author

@dariooddenino 🤦‍♂️ I didn't include it as I was working because you could easily do it with the code you wrote above. But then I forgot to include the query helper at the end, which would simply combine the two like that!

setValidateAll_ fields = andThen_ (setAll_ fields) validateAll_

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.

3 participants