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
Grégoire Locqueville
purescript-gargantext
Commits
91224ece
Commit
91224ece
authored
Apr 17, 2020
by
Przemyslaw Kaminski
Committed by
Alexandre Delanoë
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] some more refactoring
parent
8d2095b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
32 deletions
+40
-32
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+40
-32
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
91224ece
...
@@ -34,8 +34,8 @@ import Gargantext.Utils (queryMatchesLabel)
...
@@ -34,8 +34,8 @@ import Gargantext.Utils (queryMatchesLabel)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
import React (ReactClass, Children)
import React (ReactClass, Children)
import React.DOM (a,
input,
span, text)
import React.DOM (a, span, text)
import React.DOM.Props (
_type, checked, className, onChange,
onClick, style)
import React.DOM.Props (onClick, style)
import React.DOM.Props as DOM
import React.DOM.Props as DOM
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
...
@@ -170,7 +170,9 @@ tableContainerCpt { dispatch
...
@@ -170,7 +170,9 @@ tableContainerCpt { dispatch
}
}
}
}
[ H.text ("Add " <> searchQuery) ]
[ H.text ("Add " <> searchQuery) ]
] else [])]
] else []
)
]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: " list-group-item"}
[ H.li {className: " list-group-item"}
[ R2.select { id: "picklistmenu"
[ R2.select { id: "picklistmenu"
...
@@ -191,7 +193,8 @@ tableContainerCpt { dispatch
...
@@ -191,7 +193,8 @@ tableContainerCpt { dispatch
, props.pageSizeControl
, props.pageSizeControl
, H.text " items / "
, H.text " items / "
, props.paginationLinks]]
, props.paginationLinks]]
]]
]
]
, H.div {}
, H.div {}
(maybe [] (\ngrams ->
(maybe [] (\ngrams ->
let
let
...
@@ -337,35 +340,40 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
...
@@ -337,35 +340,40 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
state@{ ngramsParent, ngramsChildren, ngramsLocalPatch
state@{ ngramsParent, ngramsChildren, ngramsLocalPatch
, ngramsSelection, ngramsSelectAll }
, ngramsSelection, ngramsSelectAll }
_reactChildren =
_reactChildren =
(autoUpdate <> resetSaveButtons <> [
R2.scuff <$> (
R2.scuff $ T.table { colNames
autoUpdate <> resetSaveButtons <> [
T.table { colNames
, container
, container
, params: params /\ setParams -- TODO-LENS
, params: params /\ setParams -- TODO-LENS
, rows: filteredRows
, rows: filteredRows
, totalRecords
, totalRecords
, wrapColElts
, wrapColElts
}
}
])
]
)
where
where
autoUpdate = if withAutoUpdate then [ autoUpdateElt { duration: 5000, effect: dispatch Synchronize } ] else []
autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then [ R2.buff $ autoUpdateElt { duration: 5000, effect: dispatch Synchronize } ] else []
resetButton :: R.Element
resetButton = H.button { className: "btn btn-primary"
resetButton = H.button { className: "btn btn-primary"
, on: { click: \_ -> dispatch ResetPatches } } [ H.text "Reset" ]
, on: { click: \_ -> dispatch ResetPatches } } [ H.text "Reset" ]
saveButton :: R.Element
saveButton = H.button { className: "btn btn-primary"
saveButton = H.button { className: "btn btn-primary"
, on: { click: \_ -> dispatch Synchronize }} [ H.text "Save" ]
, on: { click: \_ -> dispatch Synchronize }} [ H.text "Save" ]
resetSaveButtons :: Array R.Element
resetSaveButtons = if ngramsLocalPatch == mempty then [] else
resetSaveButtons = if ngramsLocalPatch == mempty then [] else
[ R2.scuff $ H.div {} [ resetButton, saveButton ] ]
[ H.div {} [ resetButton, saveButton ] ]
totalRecords = A.length rows
totalRecords = A.length rows
filteredRows = T.filterRows { params } 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
H.input { checked: ngramsSelectAll
[ _type "checkbox"
, className: "checkbox"
, className "checkbox"
, on: { change: const $ dispatch $ ToggleSelectAll }
, checked ngramsSelectAll
, type: "checkbox" }
, onChange $ const $ dispatch $ ToggleSelectAll
]
-- This is used to *decorate* the Select header with the checkbox.
-- This is used to *decorate* the Select header with the checkbox.
wrapColElts (T.ColumnName "Select") = const [
R2.buff
selected]
wrapColElts (T.ColumnName "Select") = const [selected]
wrapColElts (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts _ = identity
wrapColElts _ = identity
container = tableContainer { dispatch
container = tableContainer { dispatch
...
@@ -454,8 +462,8 @@ mainNgramsTableCpt = R.hooksComponent "MainNgramsTable" cpt
...
@@ -454,8 +462,8 @@ mainNgramsTableCpt = R.hooksComponent "MainNgramsTable" cpt
cpt {nodeId, defaultListId, tabType, session, tabNgramType, withAutoUpdate} _ = do
cpt {nodeId, defaultListId, tabType, session, tabNgramType, withAutoUpdate} _ = do
path /\ setPath <- R.useState' $ initialPageParams session nodeId [defaultListId] tabType
path /\ setPath <- R.useState' $ initialPageParams session nodeId [defaultListId] tabType
let paint versioned = loadedNgramsTable' {
let paint versioned = loadedNgramsTable' {
tabNgramType
path: path /\ setPath
,
path: path /\ setPath
,
tabNgramType
, versioned
, versioned
, withAutoUpdate
, withAutoUpdate
}
}
...
...
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