Keep filter when returning to overview.
This commit is contained in:
parent
27a4ff0bbb
commit
92126cc98f
|
@ -5,6 +5,7 @@ module Views.DayPicker exposing (..)
|
|||
import Models exposing (..)
|
||||
import Messages exposing (Msg(..))
|
||||
import Routing exposing (routeToString)
|
||||
import Views.FilterView exposing (maybeFilteredOverviewRoute)
|
||||
|
||||
|
||||
-- Core modules
|
||||
|
@ -52,7 +53,7 @@ dayPicker model =
|
|||
, ( "btn-default", not isAllDaysActive )
|
||||
, ( "btn-primary", isAllDaysActive )
|
||||
]
|
||||
, href <| routeToString OverviewRoute
|
||||
, href <| routeToString <| maybeFilteredOverviewRoute model
|
||||
]
|
||||
[ text "All Days"
|
||||
]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module Views.FilterView exposing (filterSidebar, applyFilters, parseFilterFromQuery, filterToQuery)
|
||||
module Views.FilterView exposing (filterSidebar, applyFilters, parseFilterFromQuery, filterToQuery, maybeFilteredOverviewRoute)
|
||||
|
||||
-- Local modules
|
||||
|
||||
import Messages exposing (Msg(..))
|
||||
import Models exposing (Model, EventInstance, Filter, Day, FilterQuery, Route(OverviewFilteredRoute), VideoRecordingFilter, EventType, EventLocation)
|
||||
import Models exposing (Model, EventInstance, Filter, Day, FilterQuery, Route(OverviewRoute, OverviewFilteredRoute), VideoRecordingFilter, EventType, EventLocation)
|
||||
import Routing exposing (routeToString)
|
||||
|
||||
|
||||
|
@ -204,8 +204,8 @@ parseFilterFromQuery query model =
|
|||
}
|
||||
|
||||
|
||||
filterToQuery : Filter -> FilterQuery
|
||||
filterToQuery filter =
|
||||
filterToString : Filter -> String
|
||||
filterToString filter =
|
||||
let
|
||||
typePart =
|
||||
case String.join "," (List.map .slug filter.eventTypes) of
|
||||
|
@ -230,8 +230,24 @@ filterToQuery filter =
|
|||
|
||||
video ->
|
||||
"video=" ++ video
|
||||
in
|
||||
String.join "&" (List.filter (\x -> x /= "") [ typePart, locationPart, videoPart ])
|
||||
|
||||
|
||||
filterToQuery : Filter -> FilterQuery
|
||||
filterToQuery filter =
|
||||
let
|
||||
result =
|
||||
String.join "&" (List.filter (\x -> x /= "") [ typePart, locationPart, videoPart ])
|
||||
filterToString filter
|
||||
in
|
||||
routeToString <| OverviewFilteredRoute result
|
||||
|
||||
|
||||
maybeFilteredOverviewRoute : Model -> Route
|
||||
maybeFilteredOverviewRoute model =
|
||||
case filterToString model.filter of
|
||||
"" ->
|
||||
OverviewRoute
|
||||
|
||||
query ->
|
||||
OverviewFilteredRoute query
|
||||
|
|
Loading…
Reference in a new issue