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
6d0cb66c
Commit
6d0cb66c
authored
Apr 17, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] some refactoring in NgramsTable
parent
f142e8f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
102 deletions
+116
-102
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+116
-102
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
6d0cb66c
...
@@ -118,104 +118,110 @@ addNewNgramA ngram = CommitPatch $ addNewNgram ngram CandidateTerm
...
@@ -118,104 +118,110 @@ addNewNgramA ngram = CommitPatch $ addNewNgram ngram CandidateTerm
type Dispatch = Action -> Effect Unit
type Dispatch = Action -> Effect Unit
tableContainer :: { path :: R.State PageParams
type TableContainerProps =
, dispatch :: Dispatch
( dispatch :: Dispatch
, ngramsParent :: Maybe NgramsTerm
, ngramsChildren :: Map NgramsTerm Boolean
, ngramsChildren :: Map NgramsTerm Boolean
, ngramsParent :: Maybe NgramsTerm
, ngramsSelection :: Set NgramsTerm
, ngramsSelectAll :: Boolean
, ngramsTable :: NgramsTable
, ngramsSelection :: Set NgramsTerm
, tabNgramType :: CTabNgramType
, ngramsTable :: NgramsTable
, ngramsSelectAll :: Boolean
, path :: R.State PageParams
}
, tabNgramType :: CTabNgramType
-> Record T.TableContainerProps -> R.Element
)
tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
, dispatch
tableContainer :: Record TableContainerProps -> Record T.TableContainerProps -> R.Element
, ngramsParent
tableContainer p q = R.createElement (tableContainerCpt p) q []
, ngramsChildren
, ngramsSelection
tableContainerCpt :: Record TableContainerProps -> R.Component T.TableContainerProps
, ngramsTable: ngramsTableCache
tableContainerCpt { dispatch
, tabNgramType
, ngramsChildren
, ngramsSelectAll
, ngramsParent
} props =
, ngramsSelectAll
H.div {className: "container-fluid"}
, ngramsSelection
[ H.div {className: "jumbotron1"}
, ngramsTable: ngramsTableCache
[ R2.row
, path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
[ H.div {className: "panel panel-default"}
, tabNgramType
[ H.div {className: "panel-heading"}
} = R.hooksComponent "G.C.NT.tableContainer" cpt
[ H.h2 {className: "panel-title", style: {textAlign : "center"}}
where
[ H.span {className: "glyphicon glyphicon-hand-down"} []
cpt props _ =
, H.text "Extracted Terms"
pure $ H.div {className: "container-fluid"} [
]
H.div {className: "jumbotron1"}
, R2.row
[ R2.row
[ H.div {className: "col-md-3", style: {marginTop: "6px"}}
[ H.div {className: "panel panel-default"}
[ H.input { className: "form-control"
[ H.div {className: "panel-heading"}
, name: "search"
[ H.h2 {className: "panel-title", style: {textAlign : "center"}}
, placeholder: "Search"
[ H.span {className: "glyphicon glyphicon-hand-down"} []
, type: "value"
, H.text "Extracted Terms"
, defaultValue: searchQuery
, on: {input: setSearchQuery <<< R2.unsafeEventValue}}
, H.div {} (
if A.null props.tableBody && searchQuery /= "" then [
H.button { className: "btn btn-primary"
, on: {click: const $ dispatch
$ addNewNgramA
$ normNgram tabNgramType searchQuery
}
}
[ H.text ("Add " <> searchQuery) ]
] else [])]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: " list-group-item"}
[ R2.select { id: "picklistmenu"
, className: "form-control custom-select"
, defaultValue: (maybe "" show termListFilter)
, on: {change: setTermListFilter <<< readTermList <<< R2.unsafeEventValue}}
(map optps1 termLists)]]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: "list-group-item"}
[ R2.select {id: "picktermtype"
, className: "form-control custom-select"
, defaultValue: (maybe "" show termSizeFilter)
, on: {change: setTermSizeFilter <<< readTermSize <<< R2.unsafeEventValue}}
(map optps1 termSizes)]]
, H.div {className: "col-md-4", style: {marginTop : "6px", marginBottom : "1px"}}
[ H.li {className: " list-group-item"}
[ props.pageSizeDescription
, props.pageSizeControl
, H.text " items / "
, props.paginationLinks]]
]]
, H.div {}
(maybe [] (\ngrams ->
let
ngramsTable =
ngramsTableCache # at ngrams
<<< _Just
<<< _NgramsElement
<<< _children
%~ applyPatchSet (patchSetFromMap ngramsChildren)
ngramsClick {depth: 1, ngrams: child} =
Just $ dispatch $ ToggleChild false child
ngramsClick _ = Nothing
ngramsEdit _ = Nothing
in
[ H.p {} [H.text $ "Editing " <> ngramsTermText ngrams]
, renderNgramsTree { ngramsTable, ngrams, ngramsStyle: [], ngramsClick, ngramsEdit }
, H.button {className: "btn btn-primary", on: {click: (const $ dispatch AddTermChildren)}} [H.text "Save"]
, H.button {className: "btn btn-secondary", on: {click: (const $ dispatch $ SetParentResetChildren Nothing)}} [H.text "Cancel"]
]) ngramsParent)
, selectAllButtons ngramsSelectAll
, H.div {id: "terms_table", className: "panel-body"}
[ H.table {className: "table able"}
[ H.thead {className: "tableHeader"} [props.tableHead]
, H.tbody {} props.tableBody] ]
, selectAllButtons ngramsSelectAll
]
]
]
, R2.row
[ H.div {className: "col-md-3", style: {marginTop: "6px"}}
[ H.input { className: "form-control"
, name: "search"
, placeholder: "Search"
, type: "value"
, defaultValue: searchQuery
, on: {input: setSearchQuery <<< R2.unsafeEventValue}}
, H.div {} (
if A.null props.tableBody && searchQuery /= "" then [
H.button { className: "btn btn-primary"
, on: {click: const $ dispatch
$ addNewNgramA
$ normNgram tabNgramType searchQuery
}
}
[ H.text ("Add " <> searchQuery) ]
] else [])]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: " list-group-item"}
[ R2.select { id: "picklistmenu"
, className: "form-control custom-select"
, defaultValue: (maybe "" show termListFilter)
, on: {change: setTermListFilter <<< readTermList <<< R2.unsafeEventValue}}
(map optps1 termLists)]]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: "list-group-item"}
[ R2.select {id: "picktermtype"
, className: "form-control custom-select"
, defaultValue: (maybe "" show termSizeFilter)
, on: {change: setTermSizeFilter <<< readTermSize <<< R2.unsafeEventValue}}
(map optps1 termSizes)]]
, H.div {className: "col-md-4", style: {marginTop : "6px", marginBottom : "1px"}}
[ H.li {className: " list-group-item"}
[ props.pageSizeDescription
, props.pageSizeControl
, H.text " items / "
, props.paginationLinks]]
]]
, H.div {}
(maybe [] (\ngrams ->
let
ngramsTable =
ngramsTableCache # at ngrams
<<< _Just
<<< _NgramsElement
<<< _children
%~ applyPatchSet (patchSetFromMap ngramsChildren)
ngramsClick {depth: 1, ngrams: child} =
Just $ dispatch $ ToggleChild false child
ngramsClick _ = Nothing
ngramsEdit _ = Nothing
in
[ H.p {} [H.text $ "Editing " <> ngramsTermText ngrams]
, renderNgramsTree { ngramsTable, ngrams, ngramsStyle: [], ngramsClick, ngramsEdit }
, H.button {className: "btn btn-primary", on: {click: (const $ dispatch AddTermChildren)}} [H.text "Save"]
, H.button {className: "btn btn-secondary", on: {click: (const $ dispatch $ SetParentResetChildren Nothing)}} [H.text "Cancel"]
]) ngramsParent)
, selectAllButtons ngramsSelectAll
, H.div {id: "terms_table", className: "panel-body"}
[ H.table {className: "table able"}
[ H.thead {className: "tableHeader"} [props.tableHead]
, H.tbody {} props.tableBody] ]
, selectAllButtons ngramsSelectAll
]
]
]
]
where
]
]
-- WHY setPath f = origSetPageParams (const $ f path)
-- WHY setPath f = origSetPageParams (const $ f path)
setSearchQuery x = setPath $ _ { searchQuery = x }
setSearchQuery x = setPath $ _ { searchQuery = x }
setTermListFilter x = setPath $ _ { termListFilter = x }
setTermListFilter x = setPath $ _ { termListFilter = x }
...
@@ -226,14 +232,14 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
...
@@ -226,14 +232,14 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
selectAllButtons true =
selectAllButtons true =
H.li {className: " list-group-item"} [
H.li {className: " list-group-item"} [
H.button { className: "btn btn-primary"
H.button { className: "btn btn-primary"
, on: {click: const $ setSelection GraphTerm }
, on: {click: const $ setSelection GraphTerm }
} [ H.text "Map" ]
} [ H.text "Map" ]
, H.button { className: "btn btn-primary"
, H.button { className: "btn btn-primary"
, on: {click: const $ setSelection StopTerm }
, on: {click: const $ setSelection StopTerm }
} [ H.text "Stop" ]
} [ H.text "Stop" ]
, H.button { className: "btn btn-primary"
, H.button { className: "btn btn-primary"
, on: {click: const $ setSelection CandidateTerm }
, on: {click: const $ setSelection CandidateTerm }
} [ H.text "Candidate" ]
} [ H.text "Candidate" ]
]
]
toggleMaybe :: forall a. a -> Maybe a -> Maybe a
toggleMaybe :: forall a. a -> Maybe a -> Maybe a
...
@@ -362,7 +368,15 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
...
@@ -362,7 +368,15 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
wrapColElts (T.ColumnName "Select") = const [R2.buff selected]
wrapColElts (T.ColumnName "Select") = const [R2.buff selected]
wrapColElts (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts _ = identity
wrapColElts _ = identity
container = tableContainer {path, dispatch, ngramsParent, ngramsChildren, ngramsSelection, ngramsTable, tabNgramType, ngramsSelectAll}
container = tableContainer { dispatch
, ngramsChildren
, ngramsParent
, ngramsSelectAll
, ngramsSelection
, ngramsTable
, path
, tabNgramType
}
setParams f = setPath $ \p@{params: ps} -> p {params = f ps}
setParams f = setPath $ \p@{params: ps} -> p {params = f ps}
ngramsTable = applyNgramsPatches state initTable
ngramsTable = applyNgramsPatches state initTable
orderWith =
orderWith =
...
...
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