Commit 553daf40 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/468-dev-ngrams-order-by' into dev-merge

parents 5e12ef58 140d077e
......@@ -10,6 +10,7 @@ module Gargantext.Components.NgramsTable
import Gargantext.Prelude
import DOM.Simple.Console (log)
import Data.Array as A
import Data.Either (Either(..))
import Data.FunctorWithIndex (mapWithIndex)
......@@ -42,7 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (changePage)
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.Config.REST (AffRESTError, RESTError, logRESTError)
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
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as Seq
import Gargantext.Utils.Toestand as T2
import Reactix (useEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
......@@ -1014,19 +1016,18 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
loader :: PageParams -> AffRESTError VersionedWithCountNgramsTable
loader { listIds
, nodeId
, params: { limit, offset }
, params: { limit, offset, orderBy }
, searchQuery
, session
, tabType
, termListFilter
, termSizeFilter
} =
get session $ Routes.GetNgrams params (Just nodeId)
} = get session $ Routes.GetNgrams params (Just nodeId)
where
params = { limit
, listIds
, offset: Just offset
, orderBy: Nothing -- TODO
, orderBy: orderByToGTOrderBy orderBy
, searchQuery
, tabType
, termListFilter
......
module Gargantext.Components.Table.Types where
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.Show.Generic (genericShow)
import Gargantext.Components.Search (SearchType)
import Gargantext.Types as GT
import Prelude (class Eq, class Show, (<>))
import Reactix as R
import Toestand as T
import Prelude (class Eq, class Show, (<>))
import Gargantext.Components.Search (SearchType)
type Params = { limit :: Int
, offset :: Int
, orderBy :: OrderBy
......@@ -28,6 +27,20 @@ orderByToForm :: OrderByDirection ColumnName -> String
orderByToForm (ASC (ColumnName x)) = x <> "Asc"
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
derive instance Generic ColumnName _
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