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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
62743a0e
Commit
62743a0e
authored
Dec 03, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Annuaire] fix pagination
parent
1c320e65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
26 deletions
+27
-26
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+23
-23
Table.purs
src/Gargantext/Components/Table.purs
+4
-3
No files found.
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
62743a0e
module Gargantext.Components.Nodes.Annuaire where
module Gargantext.Components.Nodes.Annuaire where
import Prelude (bind, identity, pure, const, ($), (<$>), (<>))
import Prelude (bind, identity, pure, const,
discard,
($), (<$>), (<>))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Array (head)
import Data.Array (head)
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe)
...
@@ -58,29 +58,31 @@ annuaire props = R.createElement annuaireCpt props []
...
@@ -58,29 +58,31 @@ annuaire props = R.createElement annuaireCpt props []
annuaireCpt :: R.Component AnnuaireProps
annuaireCpt :: R.Component AnnuaireProps
annuaireCpt = R.hooksComponent "G.P.Annuaire.annuaire" cpt
annuaireCpt = R.hooksComponent "G.P.Annuaire.annuaire" cpt
where
where
cpt {session, path, info: info@(AnnuaireInfo {name, date: date'}), frontends} _ =
cpt {session, path, info: info@(AnnuaireInfo {name, date: date'}), frontends} _ = do
pagePath <- R.useState' $ initialPagePath (fst path)
pure $ R.fragment
pure $ R.fragment
[ T.tableHeaderLayout headerProps
[ T.tableHeaderLayout headerProps
, H.p {} []
, H.p {} []
, H.div {className: "col-md-3"}
, H.div {className: "col-md-3"}
[ H.text " Filter ", H.input { className: "form-control", style } ]
[ H.text " Filter ", H.input { className: "form-control", style } ]
, H.br {}
, H.br {}
, pageLayout { info, session, annuairePath: p
ath, frontends} ]
, pageLayout { info, session, pageP
ath, frontends} ]
where
where
headerProps = { title: name, desc: name, query: "", date, user: ""}
headerProps = { title: name, desc: name, query: "", date, user: ""}
date = "Last update: " <> date'
date = "Last update: " <> date'
style = {width: "250px", display: "inline-block"}
style = {width: "250px", display: "inline-block"}
initialPagePath nodeId = {nodeId, params: T.initialParams}
type PagePath = { nodeId :: Int
type PagePath = { nodeId :: Int
, params :: T.Params
, params :: T.Params
, frontends :: Frontends
}
}
type PageLayoutProps =
type PageLayoutProps =
( session :: Session
( session :: Session
, annuairePath :: R.State Int
, info :: AnnuaireInfo
, frontends :: Frontends
, frontends :: Frontends
, info :: AnnuaireInfo
, pagePath :: R.State PagePath
)
)
pageLayout :: Record PageLayoutProps -> R.Element
pageLayout :: Record PageLayoutProps -> R.Element
...
@@ -89,15 +91,13 @@ pageLayout props = R.createElement pageLayoutCpt props []
...
@@ -89,15 +91,13 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponent "G.P.Annuaire.pageLayout" cpt
pageLayoutCpt = R.hooksComponent "G.P.Annuaire.pageLayout" cpt
where
where
cpt {annuairePath, info, session, frontends} _ = do
cpt {info, frontends, pagePath, session} _ = do
pagePath <- R.useState' (initialPagePath frontends (fst annuairePath))
useLoader (fst pagePath) (loadPage session) $
useLoader (fst pagePath) (loadPage session) $
\table -> page {session, table, pagePath, annuairePath}
\table -> page {session, table, frontends, pagePath}
initialPagePath frontends nodeId = {nodeId, params: T.initialParams, frontends}
type PageProps =
type PageProps =
( session :: Session
( session :: Session
,
annuairePath :: R.State Int
,
frontends :: Frontends
, pagePath :: R.State PagePath
, pagePath :: R.State PagePath
-- , info :: AnnuaireInfo
-- , info :: AnnuaireInfo
, table :: AnnuaireTable
, table :: AnnuaireTable
...
@@ -107,21 +107,21 @@ page :: Record PageProps -> R.Element
...
@@ -107,21 +107,21 @@ page :: Record PageProps -> R.Element
page props = R.createElement pageCpt props []
page props = R.createElement pageCpt props []
pageCpt :: R.Component PageProps
pageCpt :: R.Component PageProps
pageCpt = R.
static
Component "LoadedAnnuairePage" cpt
pageCpt = R.
hooks
Component "LoadedAnnuairePage" cpt
where
where
cpt { session,
annuairePath, pagePath
cpt { session,
pagePath, frontends
, table: (AnnuaireTable {annuaireTable})} _ = do
, table: (AnnuaireTable {annuaireTable})} _ = do
T.table { rows, params, container, colNames, totalRecords, wrapColElts }
pure $
T.table { rows, params, container, colNames, totalRecords, wrapColElts }
where
where
totalRecords = 4361 -- TODO
totalRecords = 4361 -- TODO
path = fst pagePath
path = fst pagePath
rows = (\c -> {row: contactCells session
path.frontends path
.nodeId c, delete: false}) <$> annuaireTable
rows = (\c -> {row: contactCells session
frontends (fst pagePath)
.nodeId c, delete: false}) <$> annuaireTable
container = T.defaultContainer { title: "Annuaire" } -- TODO
container = T.defaultContainer { title: "Annuaire" } -- TODO
colNames = T.ColumnName <$> [ "", "Name", "Company", "Service", "Role"]
colNames = T.ColumnName <$> [ "", "Name", "Company", "Service", "Role"]
wrapColElts = const identity
wrapColElts = const identity
setParams f = snd pagePath $ \pp@{
nodeId,
params: ps} ->
setParams f = snd pagePath $ \pp@{params: ps} ->
pp {params = f ps
, nodeId = fst annuairePath
}
pp {params = f ps}
params =
T.initialP
arams /\ setParams
params =
(fst pagePath).p
arams /\ setParams
type AnnuaireId = Int
type AnnuaireId = Int
...
...
src/Gargantext/Components/Table.purs
View file @
62743a0e
...
@@ -86,10 +86,10 @@ tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
...
@@ -86,10 +86,10 @@ tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.
static
Component "G.C.Table.tableHeaderLayout" cpt
tableHeaderLayoutCpt = R.
hooks
Component "G.C.Table.tableHeaderLayout" cpt
where
where
cpt {title, desc, query, date, user} _ =
cpt {title, desc, query, date, user} _ =
R.fragment
pure $
R.fragment
[ H.div {className: "row"}
[ H.div {className: "row"}
[ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ]
[ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ]
, H.div {className: "col-md-9"}
, H.div {className: "col-md-9"}
...
@@ -146,7 +146,8 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
...
@@ -146,7 +146,8 @@ 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)
R.useEffect2' params state do
when (fst params /= stateParams state) $ (snd params) (const $ stateParams state)
pure $ container
pure $ container
{ pageSizeControl: sizeDD pageSize
{ pageSizeControl: sizeDD pageSize
, pageSizeDescription: textDescription page pageSize' totalRecords
, pageSizeDescription: textDescription page pageSize' totalRecords
...
...
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