No need for activeDay stuff. Also make back button in EventDetail more flexible.
This commit is contained in:
parent
725535d4a7
commit
27d90c8041
|
@ -107,7 +107,7 @@ eventTypeDecoder =
|
||||||
|> required "light_text" bool
|
|> required "light_text" bool
|
||||||
|
|
||||||
|
|
||||||
initDataDecoder : Decoder (Flags -> Maybe Day -> Filter -> Route -> Model)
|
initDataDecoder : Decoder (Flags -> Filter -> Route -> Model)
|
||||||
initDataDecoder =
|
initDataDecoder =
|
||||||
decode Model
|
decode Model
|
||||||
|> required "days" (list dayDecoder)
|
|> required "days" (list dayDecoder)
|
||||||
|
|
|
@ -38,7 +38,7 @@ init flags location =
|
||||||
Filter [] [] []
|
Filter [] [] []
|
||||||
|
|
||||||
initModel =
|
initModel =
|
||||||
(Model [] [] [] [] [] flags Nothing emptyFilter currentRoute)
|
Model [] [] [] [] [] flags emptyFilter currentRoute
|
||||||
in
|
in
|
||||||
initModel ! [ sendInitMessage flags.camp_slug ]
|
initModel ! [ sendInitMessage flags.camp_slug ]
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,8 @@ import Navigation exposing (Location)
|
||||||
type Msg
|
type Msg
|
||||||
= NoOp
|
= NoOp
|
||||||
| WebSocketPayload String
|
| WebSocketPayload String
|
||||||
| MakeActiveday Day
|
|
||||||
| RemoveActiveDay
|
|
||||||
| ToggleEventTypeFilter EventType
|
| ToggleEventTypeFilter EventType
|
||||||
| ToggleEventLocationFilter EventLocation
|
| ToggleEventLocationFilter EventLocation
|
||||||
| ToggleVideoRecordingFilter { name : String, filter : EventInstance -> Bool }
|
| ToggleVideoRecordingFilter { name : String, filter : EventInstance -> Bool }
|
||||||
| OnLocationChange Location
|
| OnLocationChange Location
|
||||||
|
| BackInHistory
|
||||||
|
|
|
@ -17,7 +17,6 @@ type alias Model =
|
||||||
, eventLocations : List EventLocation
|
, eventLocations : List EventLocation
|
||||||
, eventTypes : List EventType
|
, eventTypes : List EventType
|
||||||
, flags : Flags
|
, flags : Flags
|
||||||
, activeDay : Maybe Day
|
|
||||||
, filter : Filter
|
, filter : Filter
|
||||||
, route : Route
|
, route : Route
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,11 @@ import Routing exposing (parseLocation)
|
||||||
import Json.Decode
|
import Json.Decode
|
||||||
|
|
||||||
|
|
||||||
|
-- External modules
|
||||||
|
|
||||||
|
import Navigation
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
case msg of
|
case msg of
|
||||||
|
@ -28,7 +33,7 @@ update msg model =
|
||||||
"init" ->
|
"init" ->
|
||||||
case Json.Decode.decodeString initDataDecoder str of
|
case Json.Decode.decodeString initDataDecoder str of
|
||||||
Ok m ->
|
Ok m ->
|
||||||
m model.flags Nothing (Filter [] [] []) model.route
|
m model.flags (Filter [] [] []) model.route
|
||||||
|
|
||||||
Err error ->
|
Err error ->
|
||||||
model
|
model
|
||||||
|
@ -41,12 +46,6 @@ update msg model =
|
||||||
in
|
in
|
||||||
newModel ! []
|
newModel ! []
|
||||||
|
|
||||||
MakeActiveday day ->
|
|
||||||
{ model | activeDay = Just day } ! []
|
|
||||||
|
|
||||||
RemoveActiveDay ->
|
|
||||||
{ model | activeDay = Nothing } ! []
|
|
||||||
|
|
||||||
ToggleEventTypeFilter eventType ->
|
ToggleEventTypeFilter eventType ->
|
||||||
let
|
let
|
||||||
eventTypesFilter =
|
eventTypesFilter =
|
||||||
|
@ -101,3 +100,6 @@ update msg model =
|
||||||
parseLocation location
|
parseLocation location
|
||||||
in
|
in
|
||||||
{ model | route = newRoute } ! []
|
{ model | route = newRoute } ! []
|
||||||
|
|
||||||
|
BackInHistory ->
|
||||||
|
model ! [ Navigation.back 1 ]
|
||||||
|
|
|
@ -6,20 +6,33 @@ import Models exposing (..)
|
||||||
import Messages exposing (Msg(..))
|
import Messages exposing (Msg(..))
|
||||||
|
|
||||||
|
|
||||||
|
-- Core modules
|
||||||
|
|
||||||
|
import Date exposing (Date)
|
||||||
|
|
||||||
|
|
||||||
-- External modules
|
-- External modules
|
||||||
|
|
||||||
import Html exposing (Html, text, a, div)
|
import Html exposing (Html, text, a, div)
|
||||||
import Html.Attributes exposing (class, classList, href, id)
|
import Html.Attributes exposing (class, classList, href, id)
|
||||||
import Html.Events exposing (onClick)
|
import Html.Events exposing (onClick)
|
||||||
import Date.Extra as Date
|
import Date.Extra
|
||||||
|
|
||||||
|
|
||||||
dayPicker : Model -> Html Msg
|
dayPicker : Model -> Html Msg
|
||||||
dayPicker model =
|
dayPicker model =
|
||||||
let
|
let
|
||||||
|
activeDate =
|
||||||
|
case model.route of
|
||||||
|
DayRoute iso ->
|
||||||
|
Date.Extra.fromIsoString iso
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Nothing
|
||||||
|
|
||||||
isAllDaysActive =
|
isAllDaysActive =
|
||||||
case model.activeDay of
|
case activeDate of
|
||||||
Just activeDay ->
|
Just _ ->
|
||||||
False
|
False
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
|
@ -34,23 +47,22 @@ dayPicker model =
|
||||||
, ( "btn-primary", isAllDaysActive )
|
, ( "btn-primary", isAllDaysActive )
|
||||||
]
|
]
|
||||||
, href ("#")
|
, href ("#")
|
||||||
, onClick (RemoveActiveDay)
|
|
||||||
]
|
]
|
||||||
[ text "All Days"
|
[ text "All Days"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
++ (List.map (\day -> dayButton day model.activeDay) model.days)
|
++ (List.map (\day -> dayButton day activeDate) model.days)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
dayButton : Day -> Maybe Day -> Html Msg
|
dayButton : Day -> Maybe Date -> Html Msg
|
||||||
dayButton day activeDay =
|
dayButton day activeDate =
|
||||||
let
|
let
|
||||||
isActive =
|
isActive =
|
||||||
case activeDay of
|
case activeDate of
|
||||||
Just activeDay ->
|
Just activeDate ->
|
||||||
day == activeDay
|
day.date == activeDate
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
False
|
False
|
||||||
|
@ -61,8 +73,7 @@ dayButton day activeDay =
|
||||||
, ( "btn-default", not isActive )
|
, ( "btn-default", not isActive )
|
||||||
, ( "btn-primary", isActive )
|
, ( "btn-primary", isActive )
|
||||||
]
|
]
|
||||||
, href ("#day/" ++ (Date.toFormattedString "y-MM-dd" day.date))
|
, href ("#day/" ++ (Date.Extra.toFormattedString "y-MM-dd" day.date))
|
||||||
, onClick (MakeActiveday day)
|
|
||||||
]
|
]
|
||||||
[ text day.day_name
|
[ text day.day_name
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,8 +13,8 @@ import Date exposing (Date)
|
||||||
|
|
||||||
-- External modules
|
-- External modules
|
||||||
|
|
||||||
import Html exposing (Html, text, div, ul, li, span, i, h4, table, p)
|
import Html exposing (Html, text, div, ul, li, span, i, h4, table, p, a)
|
||||||
import Html.Attributes exposing (classList, style)
|
import Html.Attributes exposing (classList, style, href)
|
||||||
import Date.Extra
|
import Date.Extra
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ eventInstanceBlock eventInstance =
|
||||||
height =
|
height =
|
||||||
(toString (length * toFloat blockHeight)) ++ "px"
|
(toString (length * toFloat blockHeight)) ++ "px"
|
||||||
in
|
in
|
||||||
div
|
a
|
||||||
[ classList
|
[ classList
|
||||||
[ ( "event", True )
|
[ ( "event", True )
|
||||||
, ( "event-in-dayview", True )
|
, ( "event-in-dayview", True )
|
||||||
|
@ -129,7 +129,9 @@ eventInstanceBlock eventInstance =
|
||||||
, style
|
, style
|
||||||
[ ( "height", height )
|
[ ( "height", height )
|
||||||
, ( "background-color", eventInstance.backgroundColor )
|
, ( "background-color", eventInstance.backgroundColor )
|
||||||
|
, ( "color", eventInstance.forgroundColor )
|
||||||
]
|
]
|
||||||
|
, href ("#event/" ++ eventInstance.eventSlug)
|
||||||
]
|
]
|
||||||
[ p [] [ text ((Date.Extra.toFormattedString "HH:mm" eventInstance.from) ++ " " ++ eventInstance.title) ]
|
[ p [] [ text ((Date.Extra.toFormattedString "HH:mm" eventInstance.from) ++ " " ++ eventInstance.title) ]
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Models exposing (..)
|
||||||
|
|
||||||
import Html exposing (Html, text, div, ul, li, span, i, h4, a, p, hr)
|
import Html exposing (Html, text, div, ul, li, span, i, h4, a, p, hr)
|
||||||
import Html.Attributes exposing (class, classList, href)
|
import Html.Attributes exposing (class, classList, href)
|
||||||
|
import Html.Events exposing (onClick)
|
||||||
import Markdown
|
import Markdown
|
||||||
import Date.Extra
|
import Date.Extra
|
||||||
|
|
||||||
|
@ -27,8 +28,9 @@ eventDetailView eventSlug model =
|
||||||
in
|
in
|
||||||
div [ class "row" ]
|
div [ class "row" ]
|
||||||
[ div [ class "col-sm-9" ]
|
[ div [ class "col-sm-9" ]
|
||||||
[ a [ href "#" ]
|
[ a [ onClick BackInHistory, classList [ ( "btn", True ), ( "btn-default", True ) ] ]
|
||||||
[ text "Back"
|
[ i [ classList [ ( "fa", True ), ( "fa-chevron-left", True ) ] ] []
|
||||||
|
, text " Back"
|
||||||
]
|
]
|
||||||
, h4 [] [ text event.title ]
|
, h4 [] [ text event.title ]
|
||||||
, p [] [ Markdown.toHtml [] event.abstract ]
|
, p [] [ Markdown.toHtml [] event.abstract ]
|
||||||
|
|
Loading…
Reference in a new issue