Hey guys! 8-)
I’m playing with an app for bailiffs. For the data entry UI I need a
PersonSection widget to enter the data for a party that participates in a
case. So a person can be either an individual or a company, so I’m
imagining this as: a “Person type” dropdown + a set of person-type-specific
fields.
So, the model looks like this:
type alias Model =
{ personType : PersonType
, personTypeSpecificFieldValues : PersonTypeSpecificValues
}
type PersonType =
= Individual
| Company
type PersonTypeSpecificValues
= IndividualFieldValues IndividualFields.Model
| CompanyFieldValues CompanyFields.Model
I have extracted the corresponding pieces of model structure and view into
IndividualFields.elm and CompanyFields.elm, but I don’t know how to extract
the model updates. The code here:
https://github.com/gurdiga/elm-play/blob/master/Main.elm.
I have checked a similar example from the “Elm Beyond The Basics” course
here:
https://github.com/knowthen/elm-beyond-basics/blob/master/01The-Elm-Architecture/Main.elm
but my case is a bit different: depending on personType I’m trying to
alternatively store any of the two field value sets (IndividualFieldValues
or CompanyFieldValues) into a single model member (
personTypeSpecificFieldValues), although I’m not sure this is a good idea.
I’m wondering what’d be an idiomatic approach to build this widget.
Cheers!
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.