Commit 4f1ab90d authored by Alexandre Delanoë's avatar Alexandre Delanoë
parents f1722b30 68dd9873
...@@ -60,12 +60,12 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where ...@@ -60,12 +60,12 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
Login -> login { sessions, backends, visible: showLogin } Login -> login { sessions, backends, visible: showLogin }
Folder sid _ -> withSession sid $ \_ -> forested (folder {}) Folder sid _ -> withSession sid $ \_ -> forested (folder {})
Corpus sid nodeId -> withSession sid $ \_ -> forested $ corpusLayout { nodeId } Corpus sid nodeId -> withSession sid $ \_ -> forested $ corpusLayout { nodeId }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session } Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, route }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session } Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session }
Dashboard sid _nodeId -> withSession sid $ \session -> forested $ dashboardLayout {} Dashboard sid _nodeId -> withSession sid $ \session -> forested $ dashboardLayout {}
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { nodeId, session } Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { nodeId, session } UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { route, nodeId, session }
ContactPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { nodeId, session } ContactPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { route, nodeId, session }
CorpusDocument sid corpusId listId nodeId -> CorpusDocument sid corpusId listId nodeId ->
withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId } withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Document sid listId nodeId -> Document sid listId nodeId ->
......
...@@ -14,7 +14,7 @@ import Data.Maybe (Maybe(..), maybe) ...@@ -14,7 +14,7 @@ import Data.Maybe (Maybe(..), maybe)
import Data.Set (Set) import Data.Set (Set)
import Data.Set as Set import Data.Set as Set
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst) import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log, log3) import DOM.Simple.Console (log, log3)
import DOM.Simple.Event as DE import DOM.Simple.Event as DE
...@@ -33,7 +33,7 @@ import Gargantext.Components.Table as T ...@@ -33,7 +33,7 @@ import Gargantext.Components.Table as T
import Gargantext.Ends (url) import Gargantext.Ends (url)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (AppRoute, SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, post, delete) import Gargantext.Sessions (Session, sessionId, post, delete)
import Gargantext.Types (NodeType(..), OrderBy(..), TabType, TabPostQuery(..)) import Gargantext.Types (NodeType(..), OrderBy(..), TabType, TabPostQuery(..))
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -49,6 +49,7 @@ type LayoutProps = ...@@ -49,6 +49,7 @@ type LayoutProps =
, listId :: Int , listId :: Int
, corpusId :: Maybe Int , corpusId :: Maybe Int
, showSearch :: Boolean , showSearch :: Boolean
, route :: R.State AppRoute
, session :: Session ) , session :: Session )
-- ^ tabType is not ideal here since it is too much entangled with tabs and -- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. ) -- ngramtable. Let's see how this evolves. )
...@@ -61,6 +62,7 @@ type PageLayoutProps = ...@@ -61,6 +62,7 @@ type PageLayoutProps =
, corpusId :: Maybe Int , corpusId :: Maybe Int
, query :: Query , query :: Query
, session :: Session , session :: Session
, route :: R.State AppRoute
, params :: R.State T.Params ) , params :: R.State T.Params )
type LocalCategories = Map Int Category type LocalCategories = Map Int Category
...@@ -146,14 +148,14 @@ docView props = R.createElement docViewCpt props [] ...@@ -146,14 +148,14 @@ docView props = R.createElement docViewCpt props []
docViewCpt :: R.Component Props docViewCpt :: R.Component Props
docViewCpt = R.hooksComponent "G.C.DocsTable.docView" cpt where docViewCpt = R.hooksComponent "G.C.DocsTable.docView" cpt where
cpt { query, params cpt { query, params
, layout: { session, nodeId, tabType, listId, corpusId , layout: { route, session, nodeId, tabType, listId
, totalRecords, chart, showSearch } } _ = do , corpusId, totalRecords, chart, showSearch } } _ = do
pure $ H.div {className: "container1"} pure $ H.div {className: "container1"}
[ H.div {className: "row"} [ H.div {className: "row"}
[ chart [ chart
, if showSearch then searchBar query else H.div {} [] , if showSearch then searchBar query else H.div {} []
, H.div {className: "col-md-12"} , H.div {className: "col-md-12"}
[ pageLayout {session, nodeId, totalRecords, tabType, listId, corpusId, query: fst query, params} ] ] ] [ pageLayout {route, session, nodeId, totalRecords, tabType, listId, corpusId, query: fst query, params} ] ] ]
-- onClickTrashAll nodeId _ = do -- onClickTrashAll nodeId _ = do
-- launchAff $ deleteAllDocuments p.session nodeId -- launchAff $ deleteAllDocuments p.session nodeId
...@@ -214,7 +216,8 @@ searchBar (query /\ setQuery) = R.createElement el {} [] ...@@ -214,7 +216,8 @@ searchBar (query /\ setQuery) = R.createElement el {} []
mock :: Boolean mock :: Boolean
mock = false mock = false
type PageParams = { nodeId :: Int type PageParams =
{ nodeId :: Int
, listId :: Int , listId :: Int
, corpusId :: Maybe Int , corpusId :: Maybe Int
, tabType :: TabType , tabType :: TabType
...@@ -262,7 +265,7 @@ pageLayout props = R.createElement pageLayoutCpt props [] ...@@ -262,7 +265,7 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Memo PageLayoutProps pageLayoutCpt :: R.Memo PageLayoutProps
pageLayoutCpt = R.memo' $ R.staticComponent "G.C.DocsTable.pageLayout" cpt where pageLayoutCpt = R.memo' $ R.staticComponent "G.C.DocsTable.pageLayout" cpt where
cpt props@{session, nodeId, listId, corpusId, tabType, query, params} _ = cpt props@{route, session, nodeId, listId, corpusId, tabType, query, params} _ =
loader path (loadPage session) paint loader path (loadPage session) paint
where where
path = {nodeId, listId, corpusId, tabType, query, params: fst params} path = {nodeId, listId, corpusId, tabType, query, params: fst params}
...@@ -278,7 +281,7 @@ page params layout documents = R.createElement pageCpt {params, layout, document ...@@ -278,7 +281,7 @@ page params layout documents = R.createElement pageCpt {params, layout, document
pageCpt :: R.Memo PageProps pageCpt :: R.Memo PageProps
pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where
cpt { layout: {session, nodeId, corpusId, listId, totalRecords}, documents, params } _ = do cpt { layout: {route, session, nodeId, corpusId, listId, totalRecords}, documents, params } _ = do
localCategories <- R.useState' (mempty :: LocalCategories) localCategories <- R.useState' (mempty :: LocalCategories)
pure $ T.table pure $ T.table
{ rows: rows localCategories { rows: rows localCategories
...@@ -290,8 +293,9 @@ pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where ...@@ -290,8 +293,9 @@ pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where
gi _ = "glyphicon glyphicon-star-empty" gi _ = "glyphicon glyphicon-star-empty"
trashStyle Trash = {textDecoration: "line-through"} trashStyle Trash = {textDecoration: "line-through"}
trashStyle _ = {textDecoration: "none"} trashStyle _ = {textDecoration: "none"}
corpusDocument (Just corpusId) = Routes.CorpusDocument sid corpusId corpusDocument
corpusDocument _ = Routes.Document sid | Just cid <- corpusId = Routes.CorpusDocument sid cid listId
| otherwise = Routes.Document sid listId
colNames = T.ColumnName <$> [ "Map", "Stop", "Date", "Title", "Source"] colNames = T.ColumnName <$> [ "Map", "Stop", "Date", "Title", "Source"]
getCategory (localCategories /\ _) {_id, category} = maybe category identity (localCategories ^. at _id) getCategory (localCategories /\ _) {_id, category} = maybe category identity (localCategories ^. at _id)
rows localCategories = row <$> documents rows localCategories = row <$> documents
...@@ -302,7 +306,8 @@ pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where ...@@ -302,7 +306,8 @@ pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where
, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} } , H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} }
-- TODO show date: Year-Month-Day only -- TODO show date: Year-Month-Day only
, H.div { style } [ R2.showText r.date ] , H.div { style } [ R2.showText r.date ]
, H.div { style } [ H.text r.title ] , H.div { style }
[ H.a { on: {click: \_ -> (snd route) (const $ corpusDocument r._id) } } [ H.text r.title ] ]
, H.div { style } [ H.text r.source ] , H.div { style } [ H.text r.source ]
] ]
, delete: true } , delete: true }
......
...@@ -18,7 +18,7 @@ import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types ...@@ -18,7 +18,7 @@ import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
( Contact(..), ContactData, ContactTouch(..), ContactWhere(..) ( Contact(..), ContactData, ContactTouch(..), ContactWhere(..)
, ContactWho(..), HyperData(..), HyperdataContact(..) ) , ContactWho(..), HyperData(..), HyperdataContact(..) )
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (AppRoute, SessionRoute(..))
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
import Gargantext.Types (NodeType(..)) import Gargantext.Types (NodeType(..))
...@@ -122,7 +122,7 @@ infoRender (Tuple title content) = ...@@ -122,7 +122,7 @@ infoRender (Tuple title content) =
[ H.span { className: "badge badge-default badge-pill"} [ H.text title ] [ H.span { className: "badge badge-default badge-pill"} [ H.text title ]
, H.span {} [H.text content] ] , H.span {} [H.text content] ]
type LayoutProps = ( nodeId :: Int, session :: Session ) type LayoutProps = ( route :: R.State AppRoute, nodeId :: Int, session :: Session )
userLayout :: Record LayoutProps -> R.Element userLayout :: Record LayoutProps -> R.Element
userLayout props = R.createElement userLayoutCpt props [] userLayout props = R.createElement userLayoutCpt props []
...@@ -130,12 +130,12 @@ userLayout props = R.createElement userLayoutCpt props [] ...@@ -130,12 +130,12 @@ userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponent "G.P.Annuaire.UserLayout" cpt userLayoutCpt = R.hooksComponent "G.P.Annuaire.UserLayout" cpt
where where
cpt {nodeId, session} _ = cpt {route, nodeId, session} _ =
useLoader nodeId (getContact session) $ useLoader nodeId (getContact session) $
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata) [ display (fromMaybe "no name" name) (contactInfos hyperdata)
, Tabs.tabs {nodeId, contactData, session} ] , Tabs.tabs {route, nodeId, contactData, session} ]
-- | toUrl to get data -- | toUrl to get data
getContact :: Session -> Int -> Aff ContactData getContact :: Session -> Int -> Aff ContactData
......
...@@ -12,6 +12,7 @@ import Gargantext.Components.DocsTable as DT ...@@ -12,6 +12,7 @@ import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..)) import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
...@@ -36,18 +37,19 @@ modeTabType' Patents = CTabAuthors ...@@ -36,18 +37,19 @@ modeTabType' Patents = CTabAuthors
modeTabType' Books = CTabAuthors modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors modeTabType' Communication = CTabAuthors
type Props = type TabsProps =
( nodeId :: Int ( nodeId :: Int
, contactData :: ContactData , contactData :: ContactData
, route :: R.State AppRoute
, session :: Session ) , session :: Session )
tabs :: Record Props -> R.Element tabs :: Record TabsProps -> R.Element
tabs props = R.createElement tabsCpt props [] tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component Props tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponent "G.P.Annuaire.User.Contacts.Tabs.tabs" cpt tabsCpt = R.hooksComponent "G.P.Annuaire.User.Contacts.Tabs.tabs" cpt
where where
cpt {nodeId, contactData: {defaultListId}, session} _ = do cpt {route, nodeId, contactData: {defaultListId}, session} _ = do
active <- R.useState' 0 active <- R.useState' 0
pure $ pure $
Tab.tabs { tabs: tabs', selected: fst active } Tab.tabs { tabs: tabs', selected: fst active }
...@@ -66,20 +68,20 @@ tabsCpt = R.hooksComponent "G.P.Annuaire.User.Contacts.Tabs.tabs" cpt ...@@ -66,20 +68,20 @@ tabsCpt = R.hooksComponent "G.P.Annuaire.User.Contacts.Tabs.tabs" cpt
chart = mempty chart = mempty
totalRecords = 4736 -- TODO totalRecords = 4736 -- TODO
docs = DT.docViewLayout docs = DT.docViewLayout
{ session, nodeId, chart, totalRecords { route, session, nodeId, chart, totalRecords
, tabType: TabPairing TabDocs , tabType: TabPairing TabDocs
, listId: defaultListId , listId: defaultListId
, corpusId: Nothing , corpusId: Nothing
, showSearch: true } , showSearch: true }
type NgramsViewProps = type NgramsViewTabsProps =
( session :: Session ( session :: Session
, mode :: Mode , mode :: Mode
, defaultListId :: Int , defaultListId :: Int
, nodeId :: Int ) , nodeId :: Int )
ngramsView :: Record NgramsViewProps -> R.Element ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView {session,mode, defaultListId, nodeId} = ngramsView {session,mode, defaultListId, nodeId} =
NT.mainNgramsTable NT.mainNgramsTable
{ nodeId, defaultListId, tabType, session, tabNgramType } { nodeId, defaultListId, tabType, session, tabNgramType }
......
module Gargantext.Components.Nodes.Texts where module Gargantext.Components.Nodes.Texts where
import Prelude
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H
-------------------------------------------------------- --------------------------------------------------------
import Gargantext.Prelude import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Loader (loader) import Gargantext.Components.Loader (loader)
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Nodes.Corpus (CorpusData, CorpusInfo(..), loadCorpus)
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Routes (AppRoute)
import Gargantext.Components.Nodes.Corpus (CorpusInfo(..), loadCorpus)
import Gargantext.Components.Nodes.Texts.Tabs as Tabs
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (NodeType(..)) import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
type Props = ( session :: Session, nodeId :: Int ) type Props = ( route :: R.State AppRoute, session :: Session, nodeId :: Int )
textsLayout :: Record Props -> R.Element textsLayout :: Record Props -> R.Element
textsLayout props = R.createElement textsLayoutCpt props [] textsLayout props = R.createElement textsLayoutCpt props []
------------------------------------------------------------------------ ------------------------------------------------------------------------
textsLayoutCpt :: R.Component Props textsLayoutCpt :: R.Component Props
textsLayoutCpt = R.hooksComponent "G.P.Texts.textsLayout" cpt where textsLayoutCpt = R.hooksComponent "G.C.Nodes.Texts.textsLayout" cpt where
cpt path@{session} _ = do cpt {session,nodeId,route} _ = do
pure $ loader path loadCorpus paint pure $ loader {session, nodeId} loadCorpus paint
where where
paint corpusData@{corpusId, corpusNode, defaultListId} = paint corpusData@{corpusId, corpusNode, defaultListId} =
R.fragment [ Table.tableHeaderLayout headerProps, tabs ] R.fragment [ Table.tableHeaderLayout headerProps, tabs' ]
where where
NodePoly { name, date, hyperdata: CorpusInfo corpus } = corpusNode NodePoly { name, date, hyperdata: CorpusInfo corpus } = corpusNode
{desc, query, authors: user} = corpus {desc, query, authors: user} = corpus
tabs = Tabs.tabs {session, corpusId, corpusData} tabs' = tabs {session, corpusId, corpusData, route}
title = "Corpus " <> name title = "Corpus " <> name
headerProps = { title, desc, query, date, user } headerProps = { title, desc, query, date, user }
data Mode = MoreLikeFav | MoreLikeTrash
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
modeTabType :: Mode -> CTabNgramType
modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO
type TabsProps = ( route :: R.State AppRoute, session :: Session, corpusId :: Int, corpusData :: CorpusData )
tabs :: Record TabsProps -> R.Element
tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponent "G.C.Nodes.Texts.tabs" cpt
where
cpt {route, session, corpusId, corpusData} _ = do
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { tabs: tabs', selected }
where
tabs' = [ "Documents" /\ docs, "Trash" /\ trash
, "More like fav" /\ moreLikeFav, "More like trash" /\ moreLikeTrash ]
docView' tabType = docView { route, session, corpusId, corpusData, tabType }
docs = R.fragment [ docsHisto, docView' TabDocs ]
docsHisto = histo { path, session }
where path = { corpusId, tabType: TabCorpus TabDocs }
moreLikeFav = docView' TabMoreLikeFav
moreLikeTrash = docView' TabMoreLikeTrash
trash = docView' TabTrash
type DocViewProps a = ( route :: R.State AppRoute, session :: Session, corpusId :: Int, corpusData :: CorpusData, tabType :: TabSubType a )
docView :: forall a. Record (DocViewProps a) -> R.Element
docView props = R.createElement docViewCpt props []
docViewCpt :: forall a. R.Component (DocViewProps a)
docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
where
cpt {route, session, corpusId, corpusData: {defaultListId}, tabType} _children = do
pure $ DT.docViewLayout $ params tabType
where
params :: forall b. TabSubType b -> Record DT.LayoutProps
params TabDocs =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: true
, route, session }
params TabMoreLikeFav =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: false
, route, session }
params TabMoreLikeTrash =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: false
, route, session }
params TabTrash =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, route, session }
-- DUMMY
params _ =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, route, session }
module Gargantext.Components.Nodes.Texts.Tabs where
--------------------------------------------------------
import Prelude (class Eq, class Show, bind, pure, ($))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.??))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Corpus (CorpusData)
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
data Mode = MoreLikeFav | MoreLikeTrash
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
modeTabType :: Mode -> CTabNgramType
modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO
type Props = ( session :: Session, corpusId :: Int, corpusData :: CorpusData )
tabs :: Record Props -> R.Element
tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component Props
tabsCpt = R.hooksComponent "CorpusTabs" cpt
where
cpt {session, corpusId, corpusData} _ = do
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { tabs: tabs', selected }
where
tabs' = [ "Documents" /\ docs, "Trash" /\ trash
, "More like fav" /\ moreLikeFav, "More like trash" /\ moreLikeTrash ]
docView' tabType = docView { session, corpusId, corpusData, tabType }
docs = R.fragment [ docsHisto, docView' TabDocs ]
docsHisto = histo { path, session }
where path = { corpusId, tabType: TabCorpus TabDocs }
moreLikeFav = docView' TabMoreLikeFav
moreLikeTrash = docView' TabMoreLikeTrash
trash = docView' TabTrash
type DocViewProps a = ( session :: Session, corpusId :: Int, corpusData :: CorpusData, tabType :: TabSubType a )
docView :: forall a. Record (DocViewProps a) -> R.Element
docView props = R.createElement docViewCpt props []
--docViewSpec :: forall a. TabSubType a -> Props -> R.Element
docViewCpt :: forall a. R.Component (DocViewProps a)
docViewCpt = R.hooksComponent "DocViewWithCorpus" cpt
where
cpt {session, corpusId, corpusData: {defaultListId}, tabType} _children = do
pure $ DT.docViewLayout $ params tabType
where
params :: forall b. TabSubType b -> Record DT.LayoutProps
params TabDocs =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: true
, session }
params TabMoreLikeFav =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: false
, session }
params TabMoreLikeTrash =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: false
, session }
params TabTrash =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, session }
-- DUMMY
params _ =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, session }
...@@ -85,7 +85,7 @@ tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element ...@@ -85,7 +85,7 @@ tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props [] tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.staticComponent "TableHeaderLayout" cpt tableHeaderLayoutCpt = R.staticComponent "G.C.Table.tableHeaderLayout" cpt
where where
cpt {title, desc, query, date, user} _ = cpt {title, desc, query, date, user} _ =
R.fragment R.fragment
...@@ -124,7 +124,7 @@ table :: Record Props -> R.Element ...@@ -124,7 +124,7 @@ table :: Record Props -> R.Element
table props = R.createElement tableCpt props [] table props = R.createElement tableCpt props []
tableCpt :: R.Component Props tableCpt :: R.Component Props
tableCpt = R.hooksComponent "Table" cpt tableCpt = R.hooksComponent "G.C.Table.table" cpt
where where
cpt {container, colNames, totalRecords, rows, params} _ = do cpt {container, colNames, totalRecords, rows, params} _ = do
pageSize@(pageSize' /\ setPageSize) <- R.useState' PS10 pageSize@(pageSize' /\ setPageSize) <- R.useState' PS10
......
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