Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Merten
purescript-gargantext
Commits
ed3127bc
Commit
ed3127bc
authored
Oct 22, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Table: minor refactoring
parent
7e558a0b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
Table.purs
src/Gargantext/Components/Table.purs
+15
-15
No files found.
src/Gargantext/Components/Table.purs
View file @
ed3127bc
...
@@ -130,20 +130,12 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
...
@@ -130,20 +130,12 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
pageSize@(pageSize' /\ setPageSize) <- R.useState' PS10
pageSize@(pageSize' /\ setPageSize) <- R.useState' PS10
(page /\ setPage) <- R.useState' 1
(page /\ setPage) <- R.useState' 1
(orderBy /\ setOrderBy) <- R.useState' Nothing
(orderBy /\ setOrderBy) <- R.useState' Nothing
let state = {pageSize: pageSize', orderBy, page}
let
let ps = pageSizes2Int pageSize'
state = {pageSize: pageSize', orderBy, page}
let totalPages = (totalRecords / ps) + min 1 (totalRecords `mod` ps)
ps = pageSizes2Int pageSize'
R.useEffect1' state $ when (fst params /= stateParams state) $ (snd params) (const $ stateParams state)
totalPages = (totalRecords / ps) + min 1 (totalRecords `mod` ps)
pure $ container
colHeader :: ColumnName -> R.Element
{ pageSizeControl: sizeDD pageSize
colHeader c = H.th {scope: "col"} [ H.b {} cs ]
, pageSizeDescription: textDescription page pageSize' totalRecords
, paginationLinks: pagination setPage totalPages page
, tableHead: H.tr {} (colHeader setOrderBy orderBy <$> colNames)
, tableBody: map (H.tr {} <<< map (\c -> H.td {} [c]) <<< _.row) rows
}
where
colHeader :: (R2.Setter OrderBy) -> OrderBy -> ColumnName -> R.Element
colHeader setOrderBy orderBy c = H.th {scope: "col"} [ H.b {} cs ]
where
where
lnk mc = effectLink (setOrderBy (const mc))
lnk mc = effectLink (setOrderBy (const mc))
cs :: Array R.Element
cs :: Array R.Element
...
@@ -152,6 +144,14 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
...
@@ -152,6 +144,14 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
Just (ASC d) | c == d -> [lnk (Just (DESC c)) "DESC ", lnk Nothing (columnName c)]
Just (ASC d) | c == d -> [lnk (Just (DESC c)) "DESC ", lnk Nothing (columnName c)]
Just (DESC d) | c == d -> [lnk (Just (ASC c)) "ASC ", lnk Nothing (columnName c)]
Just (DESC d) | c == d -> [lnk (Just (ASC c)) "ASC ", lnk Nothing (columnName c)]
_ -> [lnk (Just (ASC c)) (columnName c)]
_ -> [lnk (Just (ASC c)) (columnName c)]
R.useEffect1' state $ when (fst params /= stateParams state) $ (snd params) (const $ stateParams state)
pure $ container
{ pageSizeControl: sizeDD pageSize
, pageSizeDescription: textDescription page pageSize' totalRecords
, paginationLinks: pagination setPage totalPages page
, tableHead: H.tr {} (colHeader <$> colNames)
, tableBody: map (H.tr {} <<< map (\c -> H.td {} [c]) <<< _.row) rows
}
defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element
defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element
defaultContainer {title} props = R.fragment
defaultContainer {title} props = R.fragment
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment