Commit 6d0cb66c authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] some refactoring in NgramsTable

parent f142e8f1
...@@ -118,27 +118,34 @@ addNewNgramA ngram = CommitPatch $ addNewNgram ngram CandidateTerm ...@@ -118,27 +118,34 @@ 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
, ngramsSelectAll :: Boolean
, ngramsSelection :: Set NgramsTerm , ngramsSelection :: Set NgramsTerm
, ngramsTable :: NgramsTable , ngramsTable :: NgramsTable
, path :: R.State PageParams
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, ngramsSelectAll :: Boolean )
}
-> Record T.TableContainerProps -> R.Element tableContainer :: Record TableContainerProps -> Record T.TableContainerProps -> R.Element
tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath tableContainer p q = R.createElement (tableContainerCpt p) q []
, dispatch
, ngramsParent tableContainerCpt :: Record TableContainerProps -> R.Component T.TableContainerProps
tableContainerCpt { dispatch
, ngramsChildren , ngramsChildren
, ngramsParent
, ngramsSelectAll
, ngramsSelection , ngramsSelection
, ngramsTable: ngramsTableCache , ngramsTable: ngramsTableCache
, path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
, tabNgramType , tabNgramType
, ngramsSelectAll } = R.hooksComponent "G.C.NT.tableContainer" cpt
} props = where
H.div {className: "container-fluid"} cpt props _ =
[ H.div {className: "jumbotron1"} pure $ H.div {className: "container-fluid"} [
H.div {className: "jumbotron1"}
[ R2.row [ R2.row
[ H.div {className: "panel panel-default"} [ H.div {className: "panel panel-default"}
[ H.div {className: "panel-heading"} [ H.div {className: "panel-heading"}
...@@ -215,7 +222,6 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath ...@@ -215,7 +222,6 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
] ]
] ]
] ]
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 }
...@@ -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 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment