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
b60d2351
Commit
b60d2351
authored
Mar 18, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[toestand] more R.State refactoring
parent
7e57b345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
57 deletions
+57
-57
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+17
-12
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+40
-45
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
b60d2351
...
...
@@ -289,7 +289,7 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, renderer: paint
}
NT.CacheOff -> do
localCategories <-
R.useState'
(mempty :: LocalUserScore)
localCategories <-
T.useBox
(mempty :: LocalUserScore)
paramsS <- T.useBox params
paramsS' <- T.useLive T.unequal paramsS
let loader p = do
...
...
@@ -337,7 +337,7 @@ pagePaintCpt = here.component "pagePaintCpt" cpt
cpt { documents, layout, params } _ = do
params' <- T.useLive T.unequal params
localCategories <-
R.useState'
(mempty :: LocalUserScore)
localCategories <-
T.useBox
(mempty :: LocalUserScore)
pure $ pagePaintRaw { documents: A.fromFoldable (filteredRows params')
, layout
, localCategories
...
...
@@ -356,10 +356,10 @@ pagePaintCpt = here.component "pagePaintCpt" cpt
type PagePaintRawProps = (
documents :: Array DocumentsView
, layout :: Record PageLayoutProps
, localCategories ::
R.State
LocalUserScore
, params :: T.Box TT.Params
documents
:: Array DocumentsView
, layout
:: Record PageLayoutProps
, localCategories ::
T.Box
LocalUserScore
, params
:: T.Box TT.Params
)
pagePaintRaw :: R2.Component PagePaintRawProps
...
...
@@ -380,12 +380,14 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
reload <- T.useBox T2.newReload
localCategories' <- T.useLive T.unequal localCategories
pure $ TT.table
{ syncResetButton : [ H.div {} [] ]
, colNames
, container: TT.defaultContainer { title: "Documents" }
, params
, rows: rows reload localCategories
, rows: rows reload localCategories
'
, totalRecords
, wrapColElts
}
...
...
@@ -401,10 +403,9 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
| otherwise = Routes.Document sid listId
colNames = TT.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source", "Score" ]
wrapColElts = const identity
getCategory (lc /\ _) {_id, category} = fromMaybe category (lc ^. at _id)
rows reload lc@(_ /\ setLocalCategories) = row <$> A.toUnfoldable documents
rows reload localCategories' = row <$> A.toUnfoldable documents
where
row dv@(DocumentsView r) =
row dv@(DocumentsView r
@{ _id, category }
) =
{ row:
TT.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "" }
...
...
@@ -412,7 +413,11 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
]
--, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ]
, H.div { className: "column-tag flex" }
[ rating { score: cat, nodeId, row: dv, session, setLocalCategories } [] ]
[ rating { nodeId
, row: dv
, score: cat
, setLocalCategories: \lc -> T.modify_ lc localCategories
, session } [] ]
--, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} }
-- TODO show date: Year-Month-Day only
, H.div { className: tClassName } [ R2.showText r.date ]
...
...
@@ -425,7 +430,7 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
]
, delete: true }
where
cat =
getCategory lc r
cat =
fromMaybe category (localCategories' ^. at _id)
-- checked = Star_1 == cat
tClassName = trashClassName cat selected
className = gi cat
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
b60d2351
...
...
@@ -128,7 +128,7 @@ docViewCpt :: R.Component Props
docViewCpt = here.component "docView" cpt
where
cpt {frontends, session, nodeId, listId, query, totalRecords, chart, container} _ = do
deletions <-
R.useState'
initialDeletions
deletions <-
T.useBox
initialDeletions
path <- T.useBox $ initialPagePath {nodeId, listId, query, session}
path' <- T.useLive T.unequal path
...
...
@@ -143,28 +143,29 @@ docViewCpt = here.component "docView" cpt
[ R2.row
[ chart
, H.div { className: "col-md-12" }
[ pageLayout {
deletions, frontends, totalRecords, container, session, path }
]
{- , H.div { className: "col-md-12" }
[ pageLayout {
container, deletions, frontends, path, session, totalRecords } []
]
{- , H.div { className: "col-md-12" }
[ H.button { style: buttonStyle, on: { click: trashClick deletions } }
[ H.i { className: "glyphitem fa fa-trash"
, style: { marginRight : "9px" }} []
, H.text "Delete document!" ]
]
-} ]
]
where
buttonStyle =
{ backgroundColor: "peru", padding: "9px", color: "white"
, border: "white", float: "right" }
trashClick deletions _ = performDeletions session nodeId deletions
performDeletions :: Session -> Int -> R.State Deletions -> Effect Unit
performDeletions session nodeId (deletions /\ setDeletions) =
launchAff_ call *> setDeletions del
]
where
buttonStyle = { backgroundColor: "peru"
, border: "white"
, color: "white"
, float: "right"
, padding: "9px" }
performDeletions :: Session -> Int -> T.Box Deletions -> Deletions -> Effect Unit
performDeletions session nodeId deletions deletions' = do
launchAff_ $ deleteDocuments session nodeId (DeleteDocumentQuery q)
T.modify_ del deletions
where
q = {documents: Set.toUnfoldable deletions.pending}
call = deleteDocuments session nodeId (DeleteDocumentQuery q)
del {pending, deleted} = {pending: mempty, deleted: deleted <> pending}
q = { documents: Set.toUnfoldable deletions'.pending }
del { deleted, pending } = { deleted: deleted <> pending, pending: mempty }
markCategory :: Session -> NodeID -> Category -> Array NodeID -> Effect Unit
markCategory session nodeId category nids =
...
...
@@ -183,10 +184,11 @@ docViewGraphCpt :: R.Component Props
docViewGraphCpt = here.component "docViewGraph" cpt
where
cpt {frontends, session, nodeId, listId, query, totalRecords, chart, container} _ = do
deletions <- R.useState' initialDeletions
deletions <- T.useBox initialDeletions
deletions' <- T.useLive T.unequal deletions
let buttonStyle = { backgroundColor: "peru", padding : "9px"
, color : "white", border : "white", float: "right"}
let performClick = \_ -> performDeletions session nodeId deletions
let performClick = \_ -> performDeletions session nodeId deletions
deletions'
path <- T.useBox $ initialPagePath { nodeId, listId, query, session }
pure $ R.fragment
...
...
@@ -197,7 +199,7 @@ docViewGraphCpt = here.component "docViewGraph" cpt
[ R2.row
[ chart
, H.div { className: "col-md-12" }
[ pageLayout {
frontends, totalRecords, deletions, container, session, path }
[ pageLayout {
container, deletions, frontends, path, session, totalRecords } []
, H.button { style: buttonStyle, on: { click: performClick } }
[ H.i { className: "glyphitem fa fa-trash"
, style: { marginRight : "9px" } } []
...
...
@@ -298,7 +300,7 @@ err2view message =
type PageLayoutProps =
( frontends :: Frontends
, totalRecords :: Int
, deletions ::
R.State
Deletions
, deletions ::
T.Box
Deletions
, container :: Record T.TableContainerProps -> R.Element
, session :: Session
, path :: T.Box PagePath
...
...
@@ -307,33 +309,41 @@ type PageLayoutProps =
type PageProps = ( rowsLoaded :: Rows | PageLayoutProps )
-- | Loads and renders a page
pageLayout :: R
ecord PageLayoutProps -> R.Element
pageLayout
props = R.createElement pageLayoutCpt props []
pageLayout :: R
2.Component PageLayoutProps
pageLayout
= R.createElement pageLayoutCpt
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = here.component "pageLayout" cpt
where
cpt {
frontends, totalRecords, deletions, container, session, path
} _ = do
cpt {
container, deletions, frontends, path, session, totalRecords
} _ = do
path' <- T.useLive T.unequal path
useLoader path' loadPage $ \rowsLoaded ->
page {
frontends, totalRecords, deletions, container, session, path, rowsLoaded}
page {
container, deletions, frontends, path, rowsLoaded, session, totalRecords } []
page :: R
ecord PageProps -> R.Element
page
props = R.createElement pageCpt props []
page :: R
2.Component PageProps
page
= R.createElement pageCpt
pageCpt :: R.Component PageProps
pageCpt = here.component "page" cpt
where
cpt { frontends
, totalRecords
, container
cpt { container
, deletions
, frontends
, path
, rowsLoaded
, session
,
path
} _ = do
,
totalRecords
} _ = do
path'@{ nodeId, listId, query } <- T.useLive T.unequal path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path
deletions' <- T.useLive T.unequal deletions
let isChecked id = Set.member id deletions'.pending
isDeleted (DocumentsView {id}) = Set.member id deletions'.deleted
rows path' = case rowsLoaded of
Docs {docs} -> docRow path' <$> Seq.filter (not <<< isDeleted) docs
Contacts {contacts} -> contactRow path' <$> contacts
pure $ T.table { colNames
, container
...
...
@@ -353,9 +363,6 @@ pageCpt = here.component "page" cpt
gi Trash = "fa fa-star-empty"
gi _ = "fa fa-star"
isChecked id = Set.member id (fst deletions).pending
isDeleted (DocumentsView {id}) = Set.member id (fst deletions).deleted
documentUrl id { listId, nodeId } =
url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id
...
...
@@ -364,10 +371,6 @@ pageCpt = here.component "page" cpt
where href = url session $ NodePath (sessionId session) NodeContact (Just id)
| otherwise = H.text label
rows path' = case rowsLoaded of
Docs {docs} -> docRow path' <$> Seq.filter (not <<< isDeleted) docs
Contacts {contacts} -> contactRow path' <$> contacts
contactRow path' (ContactsView { id, hyperdata: HyperdataRowContact { firstname, lastname, labs }
, score, annuaireId, delete
}) =
...
...
@@ -390,18 +393,10 @@ pageCpt = here.component "page" cpt
, maybeStricken delete [ H.text $ publicationDate dv ]
, maybeStricken delete [ H.a {target: "_blank", href: documentUrl id path'} [ H.text title ] ]
, maybeStricken delete [ H.text source ]
-- , maybeStricken delete [ H.text authors ]
-- , maybeStricken $ intercalate [comma] (pairUrl <$> pairs)
{-, H.input { defaultChecked: isChecked id
, on: { click: toggleClick }
, type: "checkbox"
}
-}
]
, delete: true }
where
markClick { nodeId } _ = markCategory session nodeId category [id]
toggleClick _ = togglePendingDeletion deletions id
-- comma = H.span {} [ H.text ", " ]
maybeStricken delete
...
...
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