Rename TermType as TermSize and use a min/max API for sizes

parent 37be629b
...@@ -56,7 +56,7 @@ import React.DOM.Props as DOM ...@@ -56,7 +56,7 @@ import React.DOM.Props as DOM
import Thermite (PerformAction, Render, Spec, StateCoTransformer, defaultPerformAction, modifyState_, simpleSpec, createClass) import Thermite (PerformAction, Render, Spec, StateCoTransformer, defaultPerformAction, modifyState_, simpleSpec, createClass)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (TermList(..), TermType, readTermList, readTermType, termLists, termTypes) import Gargantext.Types (TermList(..), TermSize, readTermList, readTermSize, termLists, termSizes)
import Gargantext.Config (toUrl, End(..), Path(..), TabType(..), OrderBy(..)) import Gargantext.Config (toUrl, End(..), Path(..), TabType(..), OrderBy(..))
import Gargantext.Config.REST (get, put) import Gargantext.Config.REST (get, put)
import Gargantext.Components.AutoUpdate (autoUpdateElt) import Gargantext.Components.AutoUpdate (autoUpdateElt)
...@@ -71,7 +71,7 @@ type PageParams = ...@@ -71,7 +71,7 @@ type PageParams =
, tabType :: TabType , tabType :: TabType
, searchQuery :: String , searchQuery :: String
, termListFilter :: Maybe TermList -- Nothing means all , termListFilter :: Maybe TermList -- Nothing means all
, termTypeFilter :: Maybe TermType -- Nothing means all , termSizeFilter :: Maybe TermSize -- Nothing means all
} }
initialPageParams :: Int -> Array Int -> TabType -> PageParams initialPageParams :: Int -> Array Int -> TabType -> PageParams
...@@ -80,7 +80,7 @@ initialPageParams nodeId listIds tabType = ...@@ -80,7 +80,7 @@ initialPageParams nodeId listIds tabType =
, listIds , listIds
, params: T.initialParams , params: T.initialParams
, tabType , tabType
, termTypeFilter: Nothing , termSizeFilter: Nothing
, termListFilter: Nothing , termListFilter: Nothing
, searchQuery: "" , searchQuery: ""
} }
...@@ -465,8 +465,8 @@ tableContainer { pageParams ...@@ -465,8 +465,8 @@ tableContainer { pageParams
[ select [ _id "picktermtype" [ select [ _id "picktermtype"
, className "form-control custom-select" , className "form-control custom-select"
-- , value ? -- , value ?
, onChange (\e -> setTermTypeFilter $ readTermType $ unsafeEventValue e) , onChange (\e -> setTermSizeFilter $ readTermSize $ unsafeEventValue e)
] $ map optps1 termTypes ] $ map optps1 termSizes
] ]
, li [className " list-group-item"] [ props.pageSizeControl ] , li [className " list-group-item"] [ props.pageSizeControl ]
] ]
...@@ -509,7 +509,7 @@ tableContainer { pageParams ...@@ -509,7 +509,7 @@ tableContainer { pageParams
setPageParams f = loaderDispatch $ Loader.SetPath $ f pageParams setPageParams f = loaderDispatch $ Loader.SetPath $ f pageParams
setSearchQuery x = setPageParams $ _ { searchQuery = x } setSearchQuery x = setPageParams $ _ { searchQuery = x }
setTermListFilter x = setPageParams $ _ { termListFilter = x } setTermListFilter x = setPageParams $ _ { termListFilter = x }
setTermTypeFilter x = setPageParams $ _ { termTypeFilter = x } setTermSizeFilter x = setPageParams $ _ { termSizeFilter = x }
putTable :: {nodeId :: Int, listIds :: Array Int, tabType :: TabType} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch) putTable :: {nodeId :: Int, listIds :: Array Int, tabType :: TabType} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch)
putTable {nodeId, listIds, tabType} = putTable {nodeId, listIds, tabType} =
...@@ -621,12 +621,12 @@ ngramsTableSpec = simpleSpec performAction render ...@@ -621,12 +621,12 @@ ngramsTableSpec = simpleSpec performAction render
} }
loadPage :: PageParams -> Aff VersionedNgramsTable loadPage :: PageParams -> Aff VersionedNgramsTable
loadPage { nodeId, listIds, termListFilter, termTypeFilter loadPage { nodeId, listIds, termListFilter, termSizeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} = , searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds (GetNgrams { tabType, offset, limit, listIds
, orderBy: convOrderBy <$> orderBy , orderBy: convOrderBy <$> orderBy
, termListFilter, termTypeFilter , termListFilter, termSizeFilter
, searchQuery , searchQuery
}) })
(Just nodeId) (Just nodeId)
......
...@@ -133,14 +133,17 @@ pathUrl c (GetNgrams ...@@ -133,14 +133,17 @@ pathUrl c (GetNgrams
, limit: l , limit: l
, listIds , listIds
, termListFilter: tlf , termListFilter: tlf
, termTypeFilter: ttf , termSizeFilter: tsf
, searchQuery: q , searchQuery: q
}) i = }) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsGet t pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsGet t
<> offsetUrl o <> limitUrl l <> offsetUrl o <> limitUrl l
<> foldMap (\x -> "&list=" <> show x) listIds <> foldMap (\x -> "&list=" <> show x) listIds
<> foldMap (\x -> "&listType=" <> show x) tlf <> foldMap (\x -> "&listType=" <> show x) tlf
<> foldMap (\x -> "&termType=" <> show x) ttf <> foldMap (\x -> case x of
MonoTerm -> "&minTermSize=0&maxTermSize=1"
MultiTerm -> "&minTermSize=2"
) tsf
<> if q == "" then "" else ("&search=" <> q) <> if q == "" then "" else ("&search=" <> q)
pathUrl c (PutNgrams t listid) i = pathUrl c (PutNgrams t listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsPut t <> listid' pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsPut t <> listid'
...@@ -219,7 +222,7 @@ data Path ...@@ -219,7 +222,7 @@ data Path
, orderBy :: Maybe OrderBy , orderBy :: Maybe OrderBy
, listIds :: Array ListId , listIds :: Array ListId
, termListFilter :: Maybe TermList , termListFilter :: Maybe TermList
, termTypeFilter :: Maybe TermType , termSizeFilter :: Maybe TermSize
, searchQuery :: String , searchQuery :: String
} }
| PutNgrams TabType (Maybe ListId) | PutNgrams TabType (Maybe ListId)
......
...@@ -6,21 +6,21 @@ import Data.Maybe (Maybe(..)) ...@@ -6,21 +6,21 @@ import Data.Maybe (Maybe(..))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Gargantext.Prelude import Gargantext.Prelude
data TermType = MonoTerm | MultiTerm data TermSize = MonoTerm | MultiTerm
derive instance eqTermType :: Eq TermType derive instance eqTermSize :: Eq TermSize
instance showTermType :: Show TermType where instance showTermSize :: Show TermSize where
show MonoTerm = "MonoTerm" show MonoTerm = "MonoTerm"
show MultiTerm = "MultiTerm" show MultiTerm = "MultiTerm"
readTermType :: String -> Maybe TermType readTermSize :: String -> Maybe TermSize
readTermType "MonoTerm" = Just MonoTerm readTermSize "MonoTerm" = Just MonoTerm
readTermType "MultiTerm" = Just MultiTerm readTermSize "MultiTerm" = Just MultiTerm
readTermType _ = Nothing readTermSize _ = Nothing
termTypes :: Array { desc :: String, mval :: Maybe TermType } termSizes :: Array { desc :: String, mval :: Maybe TermSize }
termTypes = [ { desc: "All types", mval: Nothing } termSizes = [ { desc: "All types", mval: Nothing }
, { desc: "One-word terms", mval: Just MonoTerm } , { desc: "One-word terms", mval: Just MonoTerm }
, { desc: "Multi-word terms", mval: Just MultiTerm } , { desc: "Multi-word terms", mval: Just MultiTerm }
] ]
......
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