Commit 9538a92f authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] fix table pagination

parent e13b7804
...@@ -323,12 +323,17 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -323,12 +323,17 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
, ngramsSelection, ngramsSelectAll } , ngramsSelection, ngramsSelectAll }
_reactChildren = _reactChildren =
[ autoUpdateElt { duration: 5000, effect: dispatch Synchronize } [ autoUpdateElt { duration: 5000, effect: dispatch Synchronize }
, R2.scuff $ T.table { params: params /\ setParams -- TODO-LENS , R2.scuff $ T.table { colNames
, rows, container, colNames, wrapColElts, totalRecords , container
, params: params /\ setParams -- TODO-LENS
, rows: filteredRows
, totalRecords
, wrapColElts
} }
] ]
where where
totalRecords = 0 -- TODO, 0 to show first users that it is fake (until it is fixed) totalRecords = A.length rows
filteredRows = T.filterRows { params } rows
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
selected = selected =
input input
......
module Gargantext.Components.Table where module Gargantext.Components.Table where
import Prelude import Prelude
import Data.Array (filter) import Data.Array as A
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
...@@ -156,6 +156,17 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt ...@@ -156,6 +156,17 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
, tableBody: map (H.tr {} <<< map (\c -> H.td {} [c]) <<< _.row) rows , tableBody: map (H.tr {} <<< map (\c -> H.td {} [c]) <<< _.row) rows
} }
type FilterRowsParams =
(
params :: Params
)
filterRows :: Record FilterRowsParams -> Rows -> Rows
filterRows { params: { limit, offset, orderBy } } rs = newRs
where
newRs = A.take limit $ A.drop offset $ rs
defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element
defaultContainer {title} props = R.fragment defaultContainer {title} props = R.fragment
[ R2.row [ R2.row
...@@ -238,8 +249,8 @@ pagination changePage tp cp = ...@@ -238,8 +249,8 @@ pagination changePage tp cp =
H.text " ... " H.text " ... "
else else
H.text "" H.text ""
lnums = map changePageLink' $ filter (1 < _) [cp - 2, cp - 1] lnums = map changePageLink' $ A.filter (1 < _) [cp - 2, cp - 1]
rnums = map changePageLink' $ filter (tp > _) [cp + 1, cp + 2] rnums = map changePageLink' $ A.filter (tp > _) [cp + 1, cp + 2]
changePageLink :: Int -> String -> R.Element changePageLink :: Int -> String -> R.Element
changePageLink i s = changePageLink i s =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment