type alias Employee = { firstName: String, lastName: String, salary: Double }
type alias Company = { name: String, employees: List Employee }
type alias EditableEmployee = { firstName: String, lastName: String, salary: Double, warningsAndErrors: List String, isInEditMode: Boolean } type Model = Model Company (List EditableEmployee)When you edit an employee, the ID goes with it. Dict.update (for ID keys) will nicely let you "upsert" to either the old employee or create a new one.
I wouldn't worry too much about duplicated state since until the employee edit is saved you need the old version. That said if Editable Employee could have an Employee record as a subfield that might allow you to change them more easily.
Well, instead of all of those copies of employees, could you store the ID instead, and then look up the employee in a dictionary? This gives you a single point of truth, but you have to handle a Maybe Employee from the lookup.
--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/DPuz9Ky6EDs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
That's what came up with at least. Not fully satisfied, still thinking about improvements
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 elm-discuss...@googlegroups.com.
See the analysis action here, it also refers to an analysisform component lower down
https://github.com/mmport80/Lazy-PCA/blob/master/web/elm/Router.elm
The problem is that, in my actual problem, the Employees are located rather deep in the model, and might even be duplicated multiple times (suppose, for instance, Company also has a Dict (Month, Year) Employee for the employee of the month).
type alias Employee =
{ name :string
,age : integer
..
awards : List Award
.. }type alias Award = {description : string, month : int, year : int}myCo.myEmp.salary <- 25