Commit 2c7fecfd authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Tabs] more reactix components

parent 70fe17b6
......@@ -157,9 +157,10 @@ instance decodeResponse :: DecodeJson Response where
pure $ Response { cid, category: decodeCategory favorite, ngramCount, hyperdata }
docViewSpec :: Spec {} Props Void
docViewSpec = R2.elSpec $ R.hooksComponent "DocView" cpt
docViewSpec :: Props -> R.Element
docViewSpec p = R.createElement el p []
where
el = R.hooksComponent "DocView" cpt
cpt p _children = do
documentIdsDeleted <- R.useState' (mempty :: DocumentIdsDeleted)
localCategories <- R.useState' (mempty :: LocalCategories)
......
......@@ -14,7 +14,10 @@ import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Tab as Tab
import Gargantext.Pages.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import React (Children, ReactElement, ReactClass, createElement)
import Thermite (Spec, focus, hideState, noState, cmapProps, createClass)
......@@ -68,13 +71,14 @@ statefulTabs =
where
chart = mempty
-- TODO totalRecords
docs = cmapProps (\{nodeId, contactData: {defaultListId}} ->
{ nodeId, chart
, tabType: TabPairing TabDocs
, totalRecords: 4736
, listId: defaultListId
, corpusId: Nothing}) $
noState DT.docViewSpec
docs = noState $ R2.elSpec $ R.hooksComponent "DocViewSpecWithCorpus" $ \{nodeId, contactData: {defaultListId}} _ -> do
pure $ DT.docViewSpec
{ nodeId
, chart
, tabType: TabPairing TabDocs
, totalRecords: 4736
, listId: defaultListId
, corpusId: Nothing}
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
......
......@@ -58,28 +58,6 @@ statefulTabs =
, Tuple "Institutes" $ ngramsViewSpec {mode: Institutes}
, Tuple "Terms" $ ngramsViewSpec {mode: Terms }
]
where
-- TODO totalRecords
docs = noState ( cmapProps (\{corpusId} -> {corpusId, tabType: TabCorpus TabDocs}) histoSpec
<>
(cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
)
trash = cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4736
, listId: defaultListId
, corpusId: Nothing}) $ noState DT.docViewSpec
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
......
......@@ -22,6 +22,7 @@ import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Tab as Tab
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import React (ReactElement, ReactClass, createElement, Children)
import Thermite (Spec, hideState, noState, cmapProps, createClass)
......@@ -61,41 +62,68 @@ statefulTabs =
docs = noState ( cmapProps (\{corpusId} -> {corpusId, tabType: TabCorpus TabDocs}) histoSpec
<>
(cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
(cmapProps identity $ docViewSpec TabDocs)
)
moreLikeFav = noState (cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
moreLikeFav = noState $ cmapProps identity $ docViewSpec TabMoreLikeFav
moreLikeTrash = noState $ cmapProps identity $ docViewSpec TabMoreLikeTrash
trash = noState $ cmapProps identity $ docViewSpec TabTrash
moreLikeTrash = noState (cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
trash = cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4736
, listId: defaultListId
, corpusId: Nothing}) $ noState DT.docViewSpec
--docViewSpec :: forall a. TabSubType a -> Props -> R.Element
docViewSpec :: forall a. TabSubType a -> Spec {} Props Void
docViewSpec tst = R2.elSpec $ R.hooksComponent "DocViewSpecWithCorpus" cpt
where
cpt {corpusId, corpusData: {defaultListId}} _children = do
pure $ DT.docViewSpec $ params tst
where
params :: forall a. TabSubType a -> DT.Props
params TabDocs = {
nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
}
params TabMoreLikeFav = {
nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
}
params TabMoreLikeTrash = {
nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
}
params TabTrash = {
nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
}
-- DUMMY
params _ = {
nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
}
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