Commit 69255c9e authored by Cédric F.'s avatar Cédric F.

Rename unproductive years to non-adult years

[References https://github.com/infertux/lifechart/issues/3]
parent ca8ea4c4
Pipeline #6501465 passed with stage
in 1 minute and 53 seconds
......@@ -13,7 +13,7 @@ base64 =
"life-expectancy": 80,
"kid-until": 18,
"old-from": 70,
"hide-unproductive-years": false,
"only-adult-years": false,
"events": [
{
"from": "2010-09-14",
......
......@@ -15,7 +15,7 @@ type alias Model =
, oldFrom : Int
, lifeExpectancy : Int
, lifeExpectancyString : String
, hideUnproductiveYears : Bool
, onlyAdultYears : Bool
, events : List Event
, eventFormOpen : Int
, eventForm : EventForm
......@@ -29,7 +29,7 @@ type alias JsonModel =
, kidUntil : Int
, oldFrom : Int
, lifeExpectancy : Int
, hideUnproductiveYears : Bool
, onlyAdultYears : Bool
, events : List Event
}
......@@ -60,7 +60,7 @@ initialModel =
, oldFrom = 70
, lifeExpectancy = 80
, lifeExpectancyString = "80"
, hideUnproductiveYears = False
, onlyAdultYears = False
, events = []
, eventFormOpen = -1
, eventForm = EventForm "" "" "" "" False
......@@ -78,7 +78,7 @@ mergeJsonModel jsonModel =
, oldFrom = jsonModel.oldFrom
, lifeExpectancy = jsonModel.lifeExpectancy
, lifeExpectancyString = toString jsonModel.lifeExpectancy
, hideUnproductiveYears = jsonModel.hideUnproductiveYears
, onlyAdultYears = jsonModel.onlyAdultYears
, events = jsonModel.events
}
......@@ -130,7 +130,7 @@ type Msg
| NewUrl Navigation.Location
| NewBirthDate String
| NewLifeExpectancy String
| HideUnproductiveYears Bool
| OnlyAdultYears Bool
| ShowEventForm Int
| UpdateEvent NewEventField String
| UpdateEventOverlay Bool
......@@ -142,7 +142,7 @@ type Msg
relativeBirthDate : Model -> Date
relativeBirthDate model =
if model.hideUnproductiveYears then
if model.onlyAdultYears then
partialDate model (Date.year model.birthDate + model.kidUntil)
else
model.birthDate
......@@ -150,7 +150,7 @@ relativeBirthDate model =
relativeDeathDate : Model -> Date
relativeDeathDate model =
if model.hideUnproductiveYears then
if model.onlyAdultYears then
partialDate model (Date.year model.birthDate + maxOldFrom model)
else
partialDate model (Date.year model.birthDate + model.lifeExpectancy)
......
......@@ -44,7 +44,7 @@ serializeJson model =
, "life-expectancy" => Encode.int model.lifeExpectancy
, "kid-until" => Encode.int model.kidUntil
, "old-from" => Encode.int model.oldFrom
, "hide-unproductive-years" => Encode.bool model.hideUnproductiveYears
, "only-adult-years" => Encode.bool model.onlyAdultYears
, "events" => (Encode.list <| List.map encodeEvent model.events)
]
......@@ -56,7 +56,7 @@ jsonDecoder =
(Decode.field "kid-until" Decode.int)
(Decode.field "old-from" Decode.int)
(Decode.field "life-expectancy" Decode.int)
(Decode.field "hide-unproductive-years" Decode.bool)
(Decode.field "only-adult-years" Decode.bool)
(Decode.field "events" <| Decode.list eventDecoder)
......
......@@ -82,11 +82,11 @@ update msg model =
in
( newModel, updateUrl newModel )
HideUnproductiveYears bool ->
OnlyAdultYears bool ->
let
-- TODO: fix this dirty hack somehow
tempModel =
{ model | hideUnproductiveYears = bool }
{ model | onlyAdultYears = bool }
newModel =
{ tempModel
......@@ -229,7 +229,7 @@ updateUrl model =
minLifeExpectancy : Model -> Int
minLifeExpectancy model =
if model.hideUnproductiveYears then
if model.onlyAdultYears then
model.kidUntil
else
1
......
......@@ -73,7 +73,7 @@ canvas model =
|> Collage.moveX (canvasWidth / 2 - legendWidth + lineHeight)
form =
if model.hideUnproductiveYears then
if model.onlyAdultYears then
Collage.group [ grid ]
else
Collage.group [ grid, theLegend ]
......@@ -116,11 +116,11 @@ legend model =
maxOldFrom =
Model.maxOldFrom model |> toFloat
productive =
adult =
if maxOldFrom - kidUntil < 8 then
makeText ""
else
makeText "productive years"
makeText "adult years"
|> Collage.moveY
(canvasHeight (lifeExpectancy / 2 - (kidUntil + maxOldFrom) / 2) - textOffset)
......@@ -139,7 +139,7 @@ legend model =
|> Collage.moveY
-(canvasHeight ((lifeExpectancy + oldFrom) / 2 - lifeExpectancy / 2) + textOffset)
in
Collage.group [ kid, kidMark, productive, oldMark, old ]
Collage.group [ kid, kidMark, adult, oldMark, old ]
years : Model -> List Form
......@@ -151,7 +151,7 @@ years model =
((0 - toFloat (i - from + 1)) * (weekWidth + weekBorder * 2) - lineHeight)
( from, to ) =
if model.hideUnproductiveYears then
if model.onlyAdultYears then
( model.kidUntil, maxOldFrom model )
else
( 0, model.lifeExpectancy )
......@@ -308,7 +308,7 @@ isKid model time =
kidDate =
partialDate model (Date.year (relativeBirthDate model) + model.kidUntil)
in
if model.hideUnproductiveYears then
if model.onlyAdultYears then
False
else
Date.toTime kidDate >= time
......@@ -320,7 +320,7 @@ isOld model time =
oldDate =
partialDate model (Date.year (relativeBirthDate model) + model.oldFrom)
in
if model.hideUnproductiveYears then
if model.onlyAdultYears then
False
else
Date.toTime oldDate <= time
......
......@@ -130,7 +130,7 @@ config model =
]
, div [ class "row form-group" ]
[ label [ class "col-xs-5 col-form-label col-form-label-lg" ]
[ text "Unproductive years "
[ text "Non-Adult Years "
, a
[ href
"https://www.reddit.com/r/GetMotivated/comments/1vyf9r/made_for_myself_thought_of_you_weeks_left/cexas8u/"
......@@ -144,8 +144,8 @@ config model =
[ input
[ class "form-check-input"
, type_ "radio"
, checked <| not model.hideUnproductiveYears
, onClick <| HideUnproductiveYears False
, checked <| not model.onlyAdultYears
, onClick <| OnlyAdultYears False
]
[]
, text " Show"
......@@ -154,8 +154,8 @@ config model =
[ input
[ class "form-check-input"
, type_ "radio"
, checked model.hideUnproductiveYears
, onClick <| HideUnproductiveYears True
, checked model.onlyAdultYears
, onClick <| OnlyAdultYears True
]
[]
, text " Hide"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment