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
, tabType: TabPairing TabDocs { nodeId
, totalRecords: 4736 , chart
, listId: defaultListId , tabType: TabPairing TabDocs
, corpusId: Nothing}) $ , totalRecords: 4736
noState DT.docViewSpec , listId: defaultListId
, corpusId: Nothing}
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
-- ^ TODO merge nodeId and corpusId in DT
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
) )
moreLikeFav = noState (cmapProps (\{corpusId, corpusData: {defaultListId}} -> moreLikeFav = noState $ cmapProps identity $ docViewSpec TabMoreLikeFav
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT moreLikeTrash = noState $ cmapProps identity $ docViewSpec TabMoreLikeTrash
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav trash = noState $ cmapProps identity $ docViewSpec TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
moreLikeTrash = noState (cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId --docViewSpec :: forall a. TabSubType a -> Props -> R.Element
-- ^ TODO merge nodeId and corpusId in DT docViewSpec :: forall a. TabSubType a -> Spec {} Props Void
, chart : H.div {} [] docViewSpec tst = R2.elSpec $ R.hooksComponent "DocViewSpecWithCorpus" cpt
, tabType: TabCorpus TabMoreLikeTrash where
, totalRecords: 4737 cpt {corpusId, corpusData: {defaultListId}} _children = do
, listId: defaultListId pure $ DT.docViewSpec $ params tst
, corpusId: Just corpusId}) $ noState DT.docViewSpec
) where
params :: forall a. TabSubType a -> DT.Props
trash = cmapProps (\{corpusId, corpusData: {defaultListId}} -> params TabDocs = {
{ nodeId: corpusId nodeId: corpusId
, chart : H.div {} [] -- ^ TODO merge nodeId and corpusId in DT
, tabType: TabCorpus TabTrash , chart : H.div {} []
, totalRecords: 4736 , tabType: TabCorpus TabDocs
, listId: defaultListId , totalRecords: 4737
, corpusId: Nothing}) $ noState DT.docViewSpec , 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