module InputTable.ExportTableRows exposing (..) import InputTable.Model exposing (..) import InputTable.RowFilter as RowFilter import InputTable.Messages as Messages import Json.Encode import InputTable.Ports as Ports run : TableState rowData sideRowData -> Cmd (Messages.TableMsg rowData focussedData) run tableState = Ports.headersAndRows <| getData tableState getData : TableState rowData sideRowData -> List (List String) getData tableState = let visibleColumns = List.filter .visible tableState.columns unfilteredRows = RowFilter.run tableState.rows visibleColumns tableState.searchText headerCells = List.map .name visibleColumns rowCells = List.map (\r -> List.map (getCellValue r) visibleColumns ) unfilteredRows in headerCells :: rowCells getCellValue : Row rowData -> Column rowData -> String getCellValue row column = case column.subType of DisplayColumn props -> props.get row.data LinkColumn props -> props.get row.data TextColumn props -> props.get row.data DropdownColumn props -> props.get row.data MenuDropdownColumn props -> props.get row.data SubDropdownColumn props -> let ( parent, child ) = props.get row.data in case child of Nothing -> parent Just child -> parent ++ ": " ++ child CheckboxColumn props -> if props.get row.data then "Yes" else "No" SideBarButtonColumn props -> props.get row.data