2017-07-17 10:53:38 +00:00
|
|
|
module Views.DayPicker exposing (..)
|
|
|
|
|
|
|
|
-- Local modules
|
|
|
|
|
|
|
|
import Models exposing (..)
|
|
|
|
import Messages exposing (Msg(..))
|
|
|
|
|
|
|
|
|
|
|
|
-- External modules
|
|
|
|
|
|
|
|
import Html exposing (Html, text, a, div)
|
|
|
|
import Html.Attributes exposing (class, classList, href, id)
|
|
|
|
import Html.Events exposing (onClick)
|
2017-07-17 19:48:56 +00:00
|
|
|
import Date.Extra as Date
|
2017-07-17 10:53:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
dayPicker : Model -> Html Msg
|
|
|
|
dayPicker model =
|
2017-07-17 19:48:56 +00:00
|
|
|
let
|
|
|
|
isAllDaysActive =
|
|
|
|
case model.activeDay of
|
|
|
|
Just activeDay ->
|
|
|
|
False
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
True
|
|
|
|
in
|
|
|
|
div [ class "row" ]
|
|
|
|
[ div [ id "schedule-days", class "btn-group" ]
|
|
|
|
([ a
|
|
|
|
[ classList
|
|
|
|
[ ( "btn", True )
|
|
|
|
, ( "btn-default", not isAllDaysActive )
|
|
|
|
, ( "btn-primary", isAllDaysActive )
|
|
|
|
]
|
|
|
|
, href ("#")
|
|
|
|
]
|
|
|
|
[ text "All Days"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
++ (List.map (\day -> dayButton day model.activeDay) model.days)
|
|
|
|
)
|
|
|
|
]
|
2017-07-17 10:53:38 +00:00
|
|
|
|
|
|
|
|
2017-07-17 19:48:56 +00:00
|
|
|
dayButton : Day -> Maybe Day -> Html Msg
|
2017-07-17 10:53:38 +00:00
|
|
|
dayButton day activeDay =
|
2017-07-17 19:48:56 +00:00
|
|
|
let
|
|
|
|
isActive =
|
|
|
|
case activeDay of
|
|
|
|
Just activeDay ->
|
|
|
|
day == activeDay
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
False
|
|
|
|
in
|
|
|
|
a
|
|
|
|
[ classList
|
|
|
|
[ ( "btn", True )
|
|
|
|
, ( "btn-default", not isActive )
|
|
|
|
, ( "btn-primary", isActive )
|
|
|
|
]
|
|
|
|
, href ("#day/" ++ (Date.toFormattedString "y-M-d" day.date))
|
|
|
|
, onClick (MakeActiveday day)
|
|
|
|
]
|
|
|
|
[ text day.day_name
|
2017-07-17 10:53:38 +00:00
|
|
|
]
|