Commit 140d077e authored by Karen Konou's avatar Karen Konou

[Ngrams table] Pass orderBy parameter to the BE

parent 8042e3a3
...@@ -10,6 +10,7 @@ module Gargantext.Components.NgramsTable ...@@ -10,6 +10,7 @@ module Gargantext.Components.NgramsTable
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple.Console (log)
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.FunctorWithIndex (mapWithIndex) import Data.FunctorWithIndex (mapWithIndex)
...@@ -42,7 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre ...@@ -42,7 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (changePage) import Gargantext.Components.Table (changePage)
import Gargantext.Components.Table as TT import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types (Params) import Gargantext.Components.Table.Types (Params, orderByToGTOrderBy)
import Gargantext.Components.Table.Types as TT import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError)
import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned) import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned)
...@@ -56,6 +57,7 @@ import Gargantext.Utils.CacheAPI as GUC ...@@ -56,6 +57,7 @@ import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as Seq import Gargantext.Utils.Seq as Seq
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix (useEffect)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record as Record import Record as Record
...@@ -1014,19 +1016,18 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where ...@@ -1014,19 +1016,18 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
loader :: PageParams -> AffRESTError VersionedWithCountNgramsTable loader :: PageParams -> AffRESTError VersionedWithCountNgramsTable
loader { listIds loader { listIds
, nodeId , nodeId
, params: { limit, offset } , params: { limit, offset, orderBy }
, searchQuery , searchQuery
, session , session
, tabType , tabType
, termListFilter , termListFilter
, termSizeFilter , termSizeFilter
} = } = get session $ Routes.GetNgrams params (Just nodeId)
get session $ Routes.GetNgrams params (Just nodeId)
where where
params = { limit params = { limit
, listIds , listIds
, offset: Just offset , offset: Just offset
, orderBy: Nothing -- TODO , orderBy: orderByToGTOrderBy orderBy
, searchQuery , searchQuery
, tabType , tabType
, termListFilter , termListFilter
......
module Gargantext.Components.Table.Types where module Gargantext.Components.Table.Types where
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow) import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Show.Generic (genericShow)
import Gargantext.Components.Search (SearchType)
import Gargantext.Types as GT
import Prelude (class Eq, class Show, (<>))
import Reactix as R import Reactix as R
import Toestand as T import Toestand as T
import Prelude (class Eq, class Show, (<>))
import Gargantext.Components.Search (SearchType)
type Params = { limit :: Int type Params = { limit :: Int
, offset :: Int , offset :: Int
, orderBy :: OrderBy , orderBy :: OrderBy
...@@ -28,6 +27,20 @@ orderByToForm :: OrderByDirection ColumnName -> String ...@@ -28,6 +27,20 @@ orderByToForm :: OrderByDirection ColumnName -> String
orderByToForm (ASC (ColumnName x)) = x <> "Asc" orderByToForm (ASC (ColumnName x)) = x <> "Asc"
orderByToForm (DESC (ColumnName x)) = x <> "Desc" orderByToForm (DESC (ColumnName x)) = x <> "Desc"
orderByToGTOrderBy :: OrderBy -> Maybe GT.OrderBy
orderByToGTOrderBy (Just (ASC (ColumnName "Date"))) = Just GT.DateAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Date"))) = Just GT.DateDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Title"))) = Just GT.TitleAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Title"))) = Just GT.TitleDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Score"))) = Just GT.ScoreAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Score"))) = Just GT.ScoreDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Terms"))) = Just GT.TermAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Terms"))) = Just GT.TermDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Source"))) = Just GT.SourceAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Source"))) = Just GT.SourceDesc
orderByToGTOrderBy (Just _) = Nothing
orderByToGTOrderBy Nothing = Nothing
newtype ColumnName = ColumnName String newtype ColumnName = ColumnName String
derive instance Generic ColumnName _ derive instance Generic ColumnName _
instance Show ColumnName where instance Show ColumnName where
......
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