Commit f485f3cd authored by Nicolas Pouillard's avatar Nicolas Pouillard

Fix haskell-gargantext issue #87

parent 0b5b7644
...@@ -314,8 +314,8 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -314,8 +314,8 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
path'@{ scoreType, termListFilter, termSizeFilter } <- T.useLive T.unequal path path'@{ scoreType, termListFilter, termSizeFilter } <- T.useLive T.unequal path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path params <- T.useFocused (_.params) (\a b -> b { params = a }) path
params'@{ orderBy } <- T.useLive T.unequal params params'@{ orderBy } <- T.useLive T.unequal params
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path searchQueryFocused <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
searchQuery' <- T.useLive T.unequal searchQuery searchQuery <- T.useLive T.unequal searchQueryFocused
let ngramsTable = applyNgramsPatches state' initTable let ngramsTable = applyNgramsPatches state' initTable
rowMap (Tuple ng nre) = rowMap (Tuple ng nre) =
...@@ -328,15 +328,18 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -328,15 +328,18 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
in in
addOcc <$> rowsFilter (ngramsRepoElementToNgramsElement ng s nre) addOcc <$> rowsFilter (ngramsRepoElementToNgramsElement ng s nre)
rows :: PreConversionRows rows :: PreConversionRows
rows = ngramsTableOrderWith orderBy ( rows = ngramsTableOrderWith orderBy (Seq.mapMaybe rowMap nres)
Seq.mapMaybe rowMap $ nres = Map.toUnfoldable (ngramsTable ^. _NgramsTable <<< _ngrams_repo_elements)
Map.toUnfoldable (ngramsTable ^. _NgramsTable <<< _ngrams_repo_elements) rootOfMatch (Tuple ng nre) =
) if queryMatchesLabel searchQuery (ngramsTermText ng)
then Just (fromMaybe ng (nre ^. _NgramsRepoElement <<< _root))
else Nothing
rootsWithMatches = Set.fromFoldable (Seq.mapMaybe rootOfMatch nres)
rowsFilter :: NgramsElement -> Maybe NgramsElement rowsFilter :: NgramsElement -> Maybe NgramsElement
rowsFilter ngramsElement = rowsFilter ngramsElement =
if displayRow { ngramsElement if displayRow { ngramsElement
, ngramsParentRoot , ngramsParentRoot
, searchQuery: searchQuery' , rootsWithMatches
, state: state' , state: state'
, termListFilter , termListFilter
, termSizeFilter } then , termSizeFilter } then
...@@ -487,7 +490,7 @@ mkDispatch { filteredRows ...@@ -487,7 +490,7 @@ mkDispatch { filteredRows
displayRow :: { ngramsElement :: NgramsElement displayRow :: { ngramsElement :: NgramsElement
, ngramsParentRoot :: Maybe NgramsTerm , ngramsParentRoot :: Maybe NgramsTerm
, searchQuery :: SearchQuery , rootsWithMatches :: Set NgramsTerm
, state :: State , state :: State
, termListFilter :: Maybe TermList , termListFilter :: Maybe TermList
, termSizeFilter :: Maybe TermSize } -> Boolean , termSizeFilter :: Maybe TermSize } -> Boolean
...@@ -496,14 +499,17 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list} ...@@ -496,14 +499,17 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
, state: { ngramsChildren , state: { ngramsChildren
, ngramsLocalPatch , ngramsLocalPatch
, ngramsParent } , ngramsParent }
, searchQuery , rootsWithMatches
, termListFilter , termListFilter
, termSizeFilter } = , termSizeFilter } =
( -- See these issues about the evolution of this filtering.
-- isNothing root -- * https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/340
-- ^ Display only nodes without parents -- * https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/87
-- ^^ (?) allow child nodes to be searched (see #340) isNothing root
maybe true (_ == list) termListFilter -- ^ Display only nodes without parents.
&& Set.member ngrams rootsWithMatches
-- ^ and which matches the search query.
&& maybe true (_ == list) termListFilter
-- ^ and which matches the ListType filter. -- ^ and which matches the ListType filter.
&& ngramsChildren ^. at ngrams /= Just true && ngramsChildren ^. at ngrams /= Just true
-- ^ and which are not scheduled to be added already -- ^ and which are not scheduled to be added already
...@@ -517,10 +523,6 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list} ...@@ -517,10 +523,6 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
-- ^ unless they are scheduled to be removed. -- ^ unless they are scheduled to be removed.
|| NTC.tablePatchHasNgrams ngramsLocalPatch ngrams || NTC.tablePatchHasNgrams ngramsLocalPatch ngrams
-- ^ unless they are being processed at the moment. -- ^ unless they are being processed at the moment.
)
&& queryMatchesLabel searchQuery (ngramsTermText ngrams)
-- ^ and which matches the search query.
allNgramsSelectedOnFirstPage :: Set NgramsTerm -> PreConversionRows -> Boolean allNgramsSelectedOnFirstPage :: Set NgramsTerm -> PreConversionRows -> Boolean
allNgramsSelectedOnFirstPage selected rows = selected == (selectNgramsOnFirstPage rows) allNgramsSelectedOnFirstPage selected rows = selected == (selectNgramsOnFirstPage rows)
......
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