Fix bug with unsortable columns

This commit is contained in:
Evan Czaplicki 2016-07-20 19:10:52 -07:00
parent cf9ceb18d1
commit 84fe913e4d
1 changed files with 17 additions and 21 deletions

View File

@ -450,31 +450,27 @@ view (Config { toId, toMsg, columns, customizations }) state data =
toHeaderInfo : State -> (State -> msg) -> ColumnData data msg -> ( String, Status, Attribute msg ) toHeaderInfo : State -> (State -> msg) -> ColumnData data msg -> ( String, Status, Attribute msg )
toHeaderInfo (State sortName isReversed) toMsg { name, sorter } = toHeaderInfo (State sortName isReversed) toMsg { name, sorter } =
let
(status, newIsReversed) =
case sorter of case sorter of
None -> None ->
( Unsortable, False ) ( name, Unsortable, onClick sortName isReversed toMsg )
Increasing _ -> Increasing _ ->
( Sortable (name == sortName), False ) ( name, Sortable (name == sortName), onClick name False toMsg )
Decreasing _ -> Decreasing _ ->
( Sortable (name == sortName), False ) ( name, Sortable (name == sortName), onClick name False toMsg )
IncOrDec _ -> IncOrDec _ ->
if name == sortName then if name == sortName then
( Reversible (Just isReversed), not isReversed ) ( name, Reversible (Just isReversed), onClick name (not isReversed) toMsg )
else else
( Reversible Nothing, False ) ( name, Reversible Nothing, onClick name False toMsg )
DecOrInc _ -> DecOrInc _ ->
if name == sortName then if name == sortName then
( Reversible (Just isReversed), not isReversed ) ( name, Reversible (Just isReversed), onClick name (not isReversed) toMsg )
else else
( Reversible Nothing, False ) ( name, Reversible Nothing, onClick name False toMsg )
in
( name, status, onClick name newIsReversed toMsg )
onClick : String -> Bool -> (State -> msg) -> Attribute msg onClick : String -> Bool -> (State -> msg) -> Attribute msg