bornhack-website/schedule/src/Models.elm

185 lines
3.1 KiB
Elm
Raw Normal View History

module Models exposing (..)
-- Core modules
import Date exposing (Date, now)
-- External modules
import Navigation exposing (Location)
2017-08-02 20:20:38 +00:00
type alias EventSlug =
String
type alias EventInstanceSlug =
String
type alias SpeakerSlug =
String
type alias DaySlug =
String
type alias FilterQuery =
String
-- Route is defined here rather than in Routing.elm due to it being used in Model. If it were in Routing.elm we would have a circular dependency.
type Route
= OverviewRoute
2017-08-02 20:20:38 +00:00
| OverviewFilteredRoute FilterQuery
| DayRoute DaySlug
| EventRoute EventSlug
2017-08-02 20:20:38 +00:00
| SpeakerRoute SpeakerSlug
| NotFoundRoute
type alias Model =
{ days : List Day
, events : List Event
, eventInstances : List EventInstance
2017-08-16 16:08:34 +00:00
, eventLocations : List FilterType
, eventTypes : List FilterType
2018-05-20 18:08:25 +00:00
, eventTracks : List FilterType
2017-08-02 20:20:38 +00:00
, speakers : List Speaker
, flags : Flags
, filter : Filter
, location : Location
, route : Route
, dataLoaded : Bool
}
type alias Day =
{ day_name : String
, date : Date
, repr : String
}
type alias Speaker =
{ name : String
2017-08-02 20:20:38 +00:00
, slug : SpeakerSlug
, biography : String
}
type alias EventInstance =
{ title : String
, slug : EventInstanceSlug
, id : Int
, url : String
, eventSlug : EventSlug
, eventType : String
2018-05-20 18:08:25 +00:00
, eventTrack : String
, backgroundColor : String
, forgroundColor : String
, from : Date
, to : Date
, timeslots : Float
, location : String
, locationIcon : String
, videoState : String
, videoUrl : Maybe String
, isFavorited : Maybe Bool
}
type alias Event =
{ title : String
, slug : EventSlug
, abstract : String
2017-08-02 20:20:38 +00:00
, speakerSlugs : List SpeakerSlug
, videoState : String
, videoUrl : Maybe String
, eventType : String
}
type alias Flags =
{ schedule_timeslot_length_minutes : Int
, schedule_midnight_offset_hours : Int
, ics_button_href : String
, camp_slug : String
2017-07-20 09:18:14 +00:00
, websocket_server : String
}
2017-08-16 16:08:34 +00:00
-- FILTERS
type alias FilterName =
String
type alias FilterSlug =
String
type alias LocationIcon =
String
type alias TypeColor =
String
type alias TypeLightText =
Bool
type FilterType
= TypeFilter FilterName FilterSlug TypeColor TypeLightText
| LocationFilter FilterName FilterSlug LocationIcon
| VideoFilter FilterName FilterSlug
2018-05-20 18:08:25 +00:00
| TrackFilter FilterName FilterSlug
2017-08-16 16:08:34 +00:00
type alias Filter =
{ eventTypes : List FilterType
, eventLocations : List FilterType
2018-05-20 18:08:25 +00:00
, eventTracks : List FilterType
2017-08-16 16:08:34 +00:00
, videoRecording : List FilterType
}
unpackFilterType filter =
case filter of
TypeFilter name slug _ _ ->
( name, slug )
LocationFilter name slug _ ->
( name, slug )
VideoFilter name slug ->
( name, slug )
2018-05-20 18:08:25 +00:00
TrackFilter name slug ->
( name, slug )
2017-08-16 16:08:34 +00:00
getSlugFromFilterType filter =
let
( _, slug ) =
unpackFilterType filter
in
slug
getNameFromFilterType filter =
let
( name, slug ) =
unpackFilterType filter
in
name