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

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