Commit e2f66642 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into feature/sigmax-graph-explorer

parents 097e80d8 872d4941
...@@ -245,7 +245,7 @@ loadPage {nodeId, tabType, query, listId, corpusId, params: {limit, offset, orde ...@@ -245,7 +245,7 @@ loadPage {nodeId, tabType, query, listId, corpusId, params: {limit, offset, orde
convOrderBy _ = DateAsc -- TODO convOrderBy _ = DateAsc -- TODO
renderPage :: R.State T.Params -> PageLoaderProps -> Array DocumentsView -> R.Element renderPage :: R.State T.Params -> PageLoaderProps -> Array DocumentsView -> R.Element
renderPage (_ /\ setTableParams) p res = R.createElement el p [] renderPage (tableParams /\ setTableParams) p res = R.createElement el p []
where where
el = R.hooksComponent "RenderPage" cpt el = R.hooksComponent "RenderPage" cpt
...@@ -259,10 +259,11 @@ renderPage (_ /\ setTableParams) p res = R.createElement el p [] ...@@ -259,10 +259,11 @@ renderPage (_ /\ setTableParams) p res = R.createElement el p []
cpt {nodeId, corpusId, listId, totalRecords} _children = do cpt {nodeId, corpusId, listId, totalRecords} _children = do
localCategories <- R.useState' (mempty :: LocalCategories) localCategories <- R.useState' (mempty :: LocalCategories)
pure $ R2.buff $ T.tableElt pure $ R2.buff $ T.tableEltWithInitialState
(T.paramsState tableParams)
{ rows: rows localCategories { rows: rows localCategories
-- , setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, tabType, listId, corpusId, params, query}) -- , setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, tabType, listId, corpusId, params, query})
, setParams: \params -> setTableParams $ const params , setParams: setTableParams <<< const
, container: T.defaultContainer { title: "Documents" } , container: T.defaultContainer { title: "Documents" }
, colNames: , colNames:
T.ColumnName <$> T.ColumnName <$>
......
...@@ -17,19 +17,52 @@ import Gargantext.Config.REST (put) ...@@ -17,19 +17,52 @@ import Gargantext.Config.REST (put)
import Gargantext.Utils (id) import Gargantext.Utils (id)
import URI.Extra.QueryPairs as QP import URI.Extra.QueryPairs as QP
data Database = All | PubMed | HAL | IsTex allDatabases :: Array Database
allDatabases = [All, PubMed
, HAL_EN
, HAL_FR
, IsTex_EN
, IsTex_FR
, Isidore_EN, Isidore_FR]
data Database = All | PubMed
| HAL_EN | HAL_FR
| IsTex_EN | IsTex_FR
| Isidore_EN | Isidore_FR
data Langs = FR | EN
-- | Types needed for now maybe not useful later (we could factorize the Type with Database Lang but no need for now)
instance showLangs :: Show Langs where
show FR = "FR"
show EN = "EN"
instance showDatabase :: Show Database where instance showDatabase :: Show Database where
show All = "All" show All = "All"
show PubMed = "PubMed" show PubMed = "PubMed"
show HAL = "HAL"
show IsTex = "IsTex" show HAL_EN = "HAL_" <> show EN
show HAL_FR = "HAL_" <> show FR
show IsTex_EN = "IsTex_" <> show EN
show IsTex_FR = "IsTex_" <> show FR
show Isidore_EN = "Isidore_" <> show EN
show Isidore_FR = "Isidore_" <> show FR
readDatabase :: String -> Maybe Database readDatabase :: String -> Maybe Database
readDatabase "All" = Just All readDatabase "All" = Just All
readDatabase "PubMed" = Just PubMed readDatabase "PubMed" = Just PubMed
readDatabase "HAL" = Just HAL
readDatabase "IsTex" = Just IsTex readDatabase "HAL_EN" = Just HAL_EN
readDatabase "HAL_FR" = Just HAL_FR
readDatabase "IsTex_EN" = Just IsTex_EN
readDatabase "IsTex_FR" = Just IsTex_FR
readDatabase "Isidore_EN" = Just Isidore_EN
readDatabase "Isidore_FR" = Just Isidore_FR
readDatabase _ = Nothing readDatabase _ = Nothing
derive instance eqDatabase :: Eq Database derive instance eqDatabase :: Eq Database
...@@ -38,9 +71,6 @@ instance encodeJsonDatabase :: EncodeJson Database where ...@@ -38,9 +71,6 @@ instance encodeJsonDatabase :: EncodeJson Database where
encodeJson a = encodeJson (show a) encodeJson a = encodeJson (show a)
allDatabases :: Array Database
allDatabases = [All, PubMed]
data SearchOrder data SearchOrder
= DateAsc = DateAsc
| DateDesc | DateDesc
......
module Gargantext.Components.Table where module Gargantext.Components.Table where
import Gargantext.Prelude
import Data.Array (filter) import Data.Array (filter)
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), maybe)
import Effect (Effect) import Effect (Effect)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Utils.Reactix as R2
import React (ReactElement, ReactClass, Children, createElement) import React (ReactElement, ReactClass, Children, createElement)
import React.DOM (a, b, b', p, i, h3, hr, div, option, select, span, table, tbody, td, text, th, thead, tr) import React.DOM (a, b, b', p, i, h3, hr, div, option, select, span, table, tbody, td, text, th, thead, tr)
import React.DOM.Props (className, href, onChange, onClick, scope, selected, value, defaultValue, style) import React.DOM.Props (className, href, onChange, onClick, scope, selected, value, defaultValue, style)
import Thermite (PerformAction, Render, Spec, modifyState_, simpleSpec, StateCoTransformer, createClass) import Thermite (PerformAction, Render, Spec, modifyState_, simpleSpec, StateCoTransformer, createClass)
import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2
type TableContainerProps = type TableContainerProps =
{ pageSizeControl :: ReactElement { pageSizeControl :: ReactElement
, pageSizeDescription :: ReactElement , pageSizeDescription :: ReactElement
...@@ -130,7 +131,7 @@ tableSpec = simpleSpec performAction render ...@@ -130,7 +131,7 @@ tableSpec = simpleSpec performAction render
where where
modifyStateAndReload :: (State -> State) -> Props -> State -> StateCoTransformer State Unit modifyStateAndReload :: (State -> State) -> Props -> State -> StateCoTransformer State Unit
modifyStateAndReload f {setParams} state = do modifyStateAndReload f {setParams} state = do
logs "modifyStateAndReload" -- TODO rename --logs "modifyStateAndReload" -- TODO rename
modifyState_ f modifyState_ f
liftEffect $ setParams $ stateParams $ f state liftEffect $ setParams $ stateParams $ f state
...@@ -207,12 +208,23 @@ stateParams {pageSize, currentPage, orderBy} = {offset, limit, orderBy} ...@@ -207,12 +208,23 @@ stateParams {pageSize, currentPage, orderBy} = {offset, limit, orderBy}
limit = pageSizes2Int pageSize limit = pageSizes2Int pageSize
offset = limit * (currentPage - 1) offset = limit * (currentPage - 1)
paramsState :: Params -> State
paramsState {offset, limit, orderBy} = {pageSize, currentPage, orderBy}
where
pageSize = string2PageSize $ show limit
currentPage = (offset / limit) + 1
tableClass :: ReactClass {children :: Children | Props'} tableClass :: ReactClass {children :: Children | Props'}
tableClass = createClass "Table" tableSpec (const initialState) tableClass = createClass "Table" tableSpec (const initialState)
tableElt :: Props -> ReactElement tableElt :: Props -> ReactElement
tableElt props = createElement tableClass props [] tableElt props = createElement tableClass props []
tableEltWithInitialState :: State -> Props -> ReactElement
tableEltWithInitialState state props = createElement tc props []
where
tc = createClass "Table" tableSpec (const state)
sizeDD :: PageSizes -> (Action -> Effect Unit) -> ReactElement sizeDD :: PageSizes -> (Action -> Effect Unit) -> ReactElement
sizeDD ps d sizeDD ps d
= span [] = span []
......
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