You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't think of a great way to handle this with like "first-class" support in Beam...
I believe the concept's we'd want would be:
Validation rules that are conditional on rpc.status (which form-state does support today, and where I'd nudged Dean and Craig at first)
"Dual valid-ness", to drive "only enable Save As Active if the conditional-on-rpc.status rules all pass", essentially separate form.validIfDraft / form.validIfActive flags
The "conditional on rpc.status=active" error messages should only ever show up if the user comes in to an already-active RPC and starts deleting fields.
The 2nd one, which is basically the useComputed they're writing by hand, is the tough one--b/c we don't want to actually set rpc.status=active, b/c that would show a bunch of errors in the UI like (First Name is required).
But we want to ask if we happened to set rpc.status=active, then would all of the rules be true?
...I dunno, like maybe something like:
constcanBeActive=useComputed(()=>{constoriginalStatus=rpc.status// quickly switch to activerpc.status.value=active// run all the form rulesconstcanBeActive=rpc.valid// okay, put it backrpc.status.value=originalStatus// and return our "probed" validnessreturncanBeActive});
That actually doesn't seem that bad, and maybe we could write a hook like:
That would internalize the "try flipping to active, record valid, put it back" dance.
But I'm not actually sure if the "flip to active, flip it back" would work in mobx...like, I'm 80% sure it "would technically work", but would be nuances around making sure the changes happened synchronously and ideally were not observed by anyone else.
...actually, I saw the phrase "transaction" in the mobx docs last night, so maybe that would be an approach...start a transaction, change the status, record the canBeActive = rpc.valid, and then rollback the transaction. Never used the mobx transactions before so not sure/don't know the API.
The text was updated successfully, but these errors were encountered:
Copy/pasted from https://github.com/homebound-team/internal-frontend/pull/3424#discussion_r1107253955
I couldn't think of a great way to handle this with like "first-class" support in Beam...
I believe the concept's we'd want would be:
The 2nd one, which is basically the useComputed they're writing by hand, is the tough one--b/c we don't want to actually set rpc.status=active, b/c that would show a bunch of errors in the UI like (First Name is required).
But we want to ask if we happened to set rpc.status=active, then would all of the rules be true?
...I dunno, like maybe something like:
That actually doesn't seem that bad, and maybe we could write a hook like:
That would internalize the "try flipping to active, record valid, put it back" dance.
But I'm not actually sure if the "flip to active, flip it back" would work in mobx...like, I'm 80% sure it "would technically work", but would be nuances around making sure the changes happened synchronously and ideally were not observed by anyone else.
...actually, I saw the phrase "transaction" in the mobx docs last night, so maybe that would be an approach...start a transaction, change the status, record the canBeActive = rpc.valid, and then rollback the transaction. Never used the mobx transactions before so not sure/don't know the API.
The text was updated successfully, but these errors were encountered: