Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Send the row index into a rowFilter function #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Table.elm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ type alias Customizations data msg =
, tfoot : Maybe (HtmlDetails msg)
, tbodyAttrs : List (Attribute msg)
, rowAttrs : data -> List (Attribute msg)
, rowFilter : Int -> data -> Bool
}


Expand All @@ -209,6 +210,7 @@ defaultCustomizations =
, tfoot = Nothing
, tbodyAttrs = []
, rowAttrs = simpleRowAttrs
, rowFilter = \_ _ -> True
}


Expand Down Expand Up @@ -427,9 +429,17 @@ view (Config { toId, toMsg, columns, customizations }) state data =
thead =
Html.thead theadDetails.attributes theadDetails.children

filterSortedData ( sortIndex, data ) =
if customizations.rowFilter sortIndex data then
Just data
else
Nothing

tbody =
Keyed.node "tbody" customizations.tbodyAttrs <|
List.map (viewRow toId columns customizations.rowAttrs) sortedData
List.map (viewRow toId columns customizations.rowAttrs) <|
List.filterMap filterSortedData <|
List.indexedMap (\i -> (,) i) sortedData

withFoot =
case customizations.tfoot of
Expand Down