diff options
author | Yorhel <git@yorhel.nl> | 2021-07-28 14:01:49 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-07-28 14:01:49 +0200 |
commit | f36f1d90bb0b8a19219d0b08a9b597f02886679d (patch) | |
tree | 2f386dac67cf2db0bbee60e776b112aaed0033b4 | |
parent | 2644fe6bfcafa8489afae0ef1455cdeddb91c09b (diff) |
Elm: Less awkward month display
-rw-r--r-- | elm/AdvSearch/Birthday.elm | 5 | ||||
-rw-r--r-- | elm/CharEdit.elm | 3 | ||||
-rw-r--r-- | elm/Lib/RDate.elm | 30 |
3 files changed, 19 insertions, 19 deletions
diff --git a/elm/AdvSearch/Birthday.elm b/elm/AdvSearch/Birthday.elm index 6d8ae86f..a03b124f 100644 --- a/elm/AdvSearch/Birthday.elm +++ b/elm/AdvSearch/Birthday.elm @@ -53,14 +53,13 @@ view model = ( text <| showOp model.op ++ " " ++ (if model.month == 0 then "Unknown" else List.drop (model.month-1) RDate.monthList |> List.head |> Maybe.withDefault "") - ++ (if model.day == 0 then "" else " - " ++ String.fromInt model.day) + ++ (if model.day == 0 then "" else " " ++ String.fromInt model.day) , \() -> [ div [ class "advheader", style "width" "290px" ] [ h3 [] [ text "Birthday" ] , div [ class "opts" ] [ inputOp True model.op MOp ] ] - , inputSelect "" model.month Month [style "width" "128px"] - <| (0, "Unknown") :: List.indexedMap (\m s -> (m+1, s)) RDate.monthList + , inputSelect "" model.month Month [style "width" "128px"] <| (0, "Unknown") :: RDate.monthSelect , if model.month == 0 then text "" else inputSelect "" model.day Day [style "width" "70px"] <| (0, "- day -") :: List.map (\i -> (i, String.fromInt i)) (List.range 1 31) diff --git a/elm/CharEdit.elm b/elm/CharEdit.elm index 8d360146..031c2488 100644 --- a/elm/CharEdit.elm +++ b/elm/CharEdit.elm @@ -315,8 +315,7 @@ view model = , formField "desc::Description" [ TP.view "desc" model.desc Desc 600 (style "height" "150px" :: onInvalid (Invalid General) :: GCE.valDesc) [ b [ class "standout" ] [ text "English please!" ] ] ] , formField "bmonth::Birthday" - [ inputSelect "bmonth" model.bMonth BMonth [style "width" "128px"] - <| (0, "Unknown") :: List.indexedMap (\m s -> (m+1, s)) RDate.monthList + [ inputSelect "bmonth" model.bMonth BMonth [style "width" "128px"] <| (0, "Unknown") :: RDate.monthSelect , if model.bMonth == 0 then text "" else inputSelect "" model.bDay BDay [style "width" "70px"] <| List.map (\i -> (i, String.fromInt i)) <| List.range 1 31 ] diff --git a/elm/Lib/RDate.elm b/elm/Lib/RDate.elm index 0c616ef5..b0ff4604 100644 --- a/elm/Lib/RDate.elm +++ b/elm/Lib/RDate.elm @@ -78,20 +78,23 @@ display today d = monthList : List String monthList = - [ "1 (Jan)" - , "2 (Feb)" - , "3 (Mar)" - , "4 (Apr)" - , "5 (May)" - , "6 (Jun)" - , "7 (Jul)" - , "8 (Aug)" - , "9 (Sep)" - , "10 (Oct)" - , "11 (Nov)" - , "12 (Dec)" + [ "Jan" + , "Feb" + , "Mar" + , "Apr" + , "May" + , "Jun" + , "Jul" + , "Aug" + , "Sep" + , "Oct" + , "Nov" + , "Dec" ] +monthSelect : List (Int, String) +monthSelect = List.indexedMap (\m s -> (m+1, String.fromInt (m+1) ++ " (" ++ s ++ ")")) monthList + -- Input widget. view : RDate -> Bool -> Bool -> (RDate -> msg) -> Html msg view ro permitUnknown permitToday msg = @@ -101,8 +104,7 @@ view ro permitUnknown permitToday msg = ++ (if permitUnknown then [(0, "Unknown")] else []) ++ [(99999999, "TBA")] ++ List.reverse (range 1980 (GT.curYear + 5) (\n -> {r|y=n})) - mf m s = (compact (normalize {r|m=m+1}), s) - ml = ({r|m=99} |> normalize |> compact, "- month -") :: List.indexedMap mf monthList + ml = ({r|m=99} |> normalize |> compact, "- month -") :: List.map (\(m,s) -> (compact (normalize {r|m=m}), s)) monthSelect dl = ({r|d=99} |> normalize |> compact, "- day -") :: range 1 (maxDayInMonth r.y r.m) (\n -> {r|d=n}) in div [] [ inputSelect "" ro msg [ style "width" "100px" ] yl |