bornhack-website/schedule/src/Views/ScheduleOverview.elm

105 lines
3.1 KiB
Elm
Raw Normal View History

module Views.ScheduleOverview exposing (scheduleOverviewView)
-- Local modules
import Messages exposing (Msg(..))
2017-08-02 20:20:38 +00:00
import Models exposing (Model, Day, EventInstance, Filter, Route(EventRoute))
import Views.FilterView exposing (filterSidebar, applyFilters, parseFilterFromQuery)
2017-08-02 20:20:38 +00:00
import Routing exposing (routeToString)
-- External modules
import Html exposing (Html, text, div, ul, li, span, i, h4, p, small, a)
import Html.Lazy exposing (lazy, lazy2)
import Html.Attributes exposing (class, classList, href, style)
2017-07-19 14:12:12 +00:00
import Date.Extra
scheduleOverviewView : Model -> Html Msg
scheduleOverviewView model =
div [ class "row" ]
[ filterSidebar model
, div
[ classList
[ ( "col-sm-9", True )
, ( "col-sm-pull-3", True )
]
]
(List.map (\day -> lazy2 dayRowView day model) model.days)
]
dayRowView : Day -> Model -> Html Msg
dayRowView day model =
let
filteredEventInstances =
2017-07-19 14:12:12 +00:00
applyFilters day model
in
div []
[ h4 []
[ text day.repr ]
, div [ class "schedule-day-row" ]
(List.map (lazy dayEventInstanceView) filteredEventInstances)
]
dayEventInstanceView : EventInstance -> Html Msg
dayEventInstanceView eventInstance =
a
2017-07-19 14:12:12 +00:00
[ classList
[ ( "event", True )
, ( "event-in-overview", True )
]
2017-08-02 20:20:38 +00:00
, href <| routeToString <| EventRoute eventInstance.eventSlug
, style
[ ( "background-color", eventInstance.backgroundColor )
, ( "color", eventInstance.forgroundColor )
]
]
([ small []
[ text
2017-07-19 14:12:12 +00:00
((Date.Extra.toFormattedString "HH:mm" eventInstance.from)
++ " - "
2017-07-19 14:12:12 +00:00
++ (Date.Extra.toFormattedString "HH:mm" eventInstance.to)
)
]
]
++ (dayEventInstanceIcons eventInstance)
++ [ p
[]
[ text eventInstance.title ]
]
)
dayEventInstanceIcons : EventInstance -> List (Html Msg)
dayEventInstanceIcons eventInstance =
let
videoIcon =
case eventInstance.videoState of
"has-recording" ->
[ i
[ classList [ ( "fa", True ), ( "fa-film", True ), ( "pull-right", True ) ] ]
[]
]
"to-be-recorded" ->
[ i
[ classList [ ( "fa", True ), ( "fa-video-camera", True ), ( "pull-right", True ) ] ]
[]
]
2017-08-16 17:39:30 +00:00
"not-to-be-recorded" ->
[ i
[ classList [ ( "fa", True ), ( "fa-ban", True ), ( "pull-right", True ) ] ]
[]
]
_ ->
[]
in
[ i [ classList [ ( "fa", True ), ( "fa-" ++ eventInstance.locationIcon, True ), ( "pull-right", True ) ] ] []
]
++ videoIcon