2017-07-17 10:53:38 +00:00
|
|
|
module Views.ScheduleOverview exposing (scheduleOverviewView)
|
|
|
|
|
|
|
|
-- Local modules
|
|
|
|
|
|
|
|
import Messages exposing (Msg(..))
|
|
|
|
import Models exposing (Model, Day, EventInstance)
|
|
|
|
import Views.FilterView exposing (filterSidebar)
|
|
|
|
|
|
|
|
|
|
|
|
-- External modules
|
|
|
|
|
|
|
|
import Html exposing (Html, text, div, ul, li, span, i, h4, p, small, a)
|
2017-07-17 15:59:38 +00:00
|
|
|
import Html.Lazy exposing (lazy, lazy2)
|
2017-07-17 10:53:38 +00:00
|
|
|
import Html.Attributes exposing (class, classList, href, style)
|
2017-07-17 19:48:56 +00:00
|
|
|
import Date.Extra as Date exposing (Interval(..), equalBy)
|
2017-07-17 10:53:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
scheduleOverviewView : Model -> Html Msg
|
|
|
|
scheduleOverviewView model =
|
|
|
|
div [ class "row" ]
|
|
|
|
[ filterSidebar model
|
|
|
|
, div
|
|
|
|
[ classList
|
|
|
|
[ ( "col-sm-9", True )
|
|
|
|
, ( "col-sm-pull-3", True )
|
|
|
|
]
|
|
|
|
]
|
2017-07-17 15:59:38 +00:00
|
|
|
(List.map (\day -> lazy2 dayRowView day model) model.days)
|
2017-07-17 10:53:38 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
dayRowView : Day -> Model -> Html Msg
|
|
|
|
dayRowView day model =
|
|
|
|
let
|
|
|
|
types =
|
|
|
|
List.map (\eventType -> eventType.slug)
|
|
|
|
(if List.isEmpty model.filter.eventTypes then
|
|
|
|
model.eventTypes
|
|
|
|
else
|
|
|
|
model.filter.eventTypes
|
|
|
|
)
|
|
|
|
|
|
|
|
locations =
|
|
|
|
List.map (\eventLocation -> eventLocation.slug)
|
|
|
|
(if List.isEmpty model.filter.eventLocations then
|
|
|
|
model.eventLocations
|
|
|
|
else
|
|
|
|
model.filter.eventLocations
|
|
|
|
)
|
|
|
|
|
|
|
|
filteredEventInstances =
|
|
|
|
List.filter
|
|
|
|
(\eventInstance ->
|
2017-07-17 19:48:56 +00:00
|
|
|
(Date.equalBy Month eventInstance.from day.date)
|
|
|
|
&& (Date.equalBy Date.Day eventInstance.from day.date)
|
2017-07-17 10:53:38 +00:00
|
|
|
&& List.member eventInstance.location locations
|
|
|
|
&& List.member eventInstance.eventType types
|
|
|
|
)
|
|
|
|
model.eventInstances
|
|
|
|
in
|
|
|
|
div []
|
|
|
|
[ h4 []
|
|
|
|
[ text day.repr ]
|
|
|
|
, div [ class "schedule-day-row" ]
|
2017-07-17 15:59:38 +00:00
|
|
|
(List.map (lazy dayEventInstanceView) filteredEventInstances)
|
2017-07-17 10:53:38 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
dayEventInstanceView : EventInstance -> Html Msg
|
|
|
|
dayEventInstanceView eventInstance =
|
|
|
|
a
|
|
|
|
[ class "event"
|
2017-07-17 14:05:38 +00:00
|
|
|
, href ("#event/" ++ eventInstance.eventSlug)
|
2017-07-17 10:53:38 +00:00
|
|
|
, style
|
|
|
|
[ ( "background-color", eventInstance.backgroundColor )
|
|
|
|
, ( "color", eventInstance.forgroundColor )
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[ small []
|
2017-07-17 19:48:56 +00:00
|
|
|
[ text
|
|
|
|
((Date.toFormattedString "H:m" eventInstance.from)
|
|
|
|
++ " - "
|
|
|
|
++ (Date.toFormattedString "H:m" eventInstance.to)
|
|
|
|
)
|
|
|
|
]
|
2017-07-17 10:53:38 +00:00
|
|
|
, i [ classList [ ( "fa", True ), ( "fa-" ++ eventInstance.locationIcon, True ), ( "pull-right", True ) ] ] []
|
|
|
|
, p
|
|
|
|
[]
|
|
|
|
[ text eventInstance.title ]
|
|
|
|
]
|