[NGRAMS-TABLE] loadPage with more params

parent 4a16a891
......@@ -127,12 +127,21 @@ pathUrl c (Tab t o l s) i =
pathUrl c (Children n o l s) i =
pathUrl c (NodeAPI Node) i <>
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s
pathUrl c (GetNgrams t o l listIds listTypeId) i =
pathUrl c (GetNgrams
{ tabType: t
, offset: o
, limit: l
, listIds
, termListFilter: tlf
, termTypeFilter: ttf
, searchQuery: q
}) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsGet t
<> offsetUrl o <> limitUrl l <> listIds' <> listTypeId'
where
listIds' = foldMap (\x -> "&list=" <> show x) listIds
listTypeId' = foldMap (\x -> "&listType=" <> show x) listTypeId
<> offsetUrl o <> limitUrl l
<> foldMap (\x -> "&list=" <> show x) listIds
<> foldMap (\x -> "&listType=" <> show x) tlf
<> foldMap (\x -> "&termType=" <> show x) ttf
<> if q == "" then "" else ("&search=" <> q)
pathUrl c (PutNgrams t listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgramsPut t <> listid'
where
......@@ -203,7 +212,16 @@ data Path
= Auth
| Tab TabType Offset Limit (Maybe OrderBy)
| Children NodeType Offset Limit (Maybe OrderBy)
| GetNgrams TabType Offset Limit (Array ListId) (Maybe TermList)
| GetNgrams
{ tabType :: TabType
, offset :: Offset
, limit :: Limit
, orderBy :: Maybe OrderBy
, listIds :: Array ListId
, termListFilter :: Maybe TermList
, termTypeFilter :: Maybe TermType
, searchQuery :: String
}
| PutNgrams TabType (Maybe ListId)
| NodeAPI NodeType
| Search { {-id :: Int
......
......@@ -13,7 +13,7 @@ import Thermite (Render, Spec, createClass, defaultPerformAction, simpleSpec)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Prelude
import Gargantext.Config (PTabNgramType(..), Offset, Limit, End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (PTabNgramType(..), Offset, Limit, OrderBy(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config.REST (get)
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact)
......@@ -34,11 +34,19 @@ modeTabType Communication = PTabCommunication
type Props = NT.Props Contact Mode
-- TODO: Move to Components.NgramsTable
-- TODO: Move to Components.NgramsTable?
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, listIds, tabType, params: {offset, limit}} =
get $ toUrl Back (GetNgrams tabType offset limit listIds Nothing) (Just nodeId)
-- TODO this ignores orderBy
loadPage { nodeId, listIds, termListFilter, termTypeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds
, orderBy: convOrderBy <$> orderBy
, termListFilter, termTypeFilter
, searchQuery
})
(Just nodeId)
where
convOrderBy _ = DateAsc -- TODO
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
......
......@@ -13,7 +13,7 @@ import Thermite (Render, Spec, createClass, defaultPerformAction, simpleSpec)
import Gargantext.Components.Node (NodePoly)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Prelude
import Gargantext.Config (CTabNgramType(..), End(..), Offset, Limit, Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (CTabNgramType(..), End(..), Offset, Limit, OrderBy(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config.REST (get)
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Corpus.Tabs.Types (CorpusData)
......@@ -37,9 +37,17 @@ modeTabType Terms = CTabTerms
-- TODO: Move to Components.NgramsTable?
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, listIds, tabType, params: {offset, limit}} =
get $ toUrl Back (GetNgrams tabType offset limit listIds Nothing) (Just nodeId)
-- TODO this ignores orderBy
loadPage { nodeId, listIds, termListFilter, termTypeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds
, orderBy: convOrderBy <$> orderBy
, termListFilter, termTypeFilter
, searchQuery
})
(Just nodeId)
where
convOrderBy _ = DateAsc -- TODO
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
......
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