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