From 84fe913e4d79f85eca1b337ccd2816a248e0ec05 Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Wed, 20 Jul 2016 19:10:52 -0700 Subject: [PATCH] Fix bug with unsortable columns --- src/Table.elm | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Table.elm b/src/Table.elm index 2a051ec..76cd6a9 100644 --- a/src/Table.elm +++ b/src/Table.elm @@ -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 sortName isReversed) toMsg { name, sorter } = - let - (status, newIsReversed) = - case sorter of - None -> - ( Unsortable, False ) + case sorter of + None -> + ( name, Unsortable, onClick sortName isReversed toMsg ) - Increasing _ -> - ( Sortable (name == sortName), False ) + Increasing _ -> + ( name, Sortable (name == sortName), onClick name False toMsg ) - Decreasing _ -> - ( Sortable (name == sortName), False ) + Decreasing _ -> + ( name, Sortable (name == sortName), onClick name False toMsg ) - IncOrDec _ -> - if name == sortName then - ( Reversible (Just isReversed), not isReversed ) - else - ( Reversible Nothing, False ) + IncOrDec _ -> + if name == sortName then + ( name, Reversible (Just isReversed), onClick name (not isReversed) toMsg ) + else + ( name, Reversible Nothing, onClick name False toMsg ) - DecOrInc _ -> - if name == sortName then - ( Reversible (Just isReversed), not isReversed ) - else - ( Reversible Nothing, False ) - in - ( name, status, onClick name newIsReversed toMsg ) + DecOrInc _ -> + if name == sortName then + ( name, Reversible (Just isReversed), onClick name (not isReversed) toMsg ) + else + ( name, Reversible Nothing, onClick name False toMsg ) onClick : String -> Bool -> (State -> msg) -> Attribute msg