Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
9f6f3704
Unverified
Commit
9f6f3704
authored
Oct 15, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACTOR] re-org tabs state and actions
parent
b1bb73de
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
128 deletions
+49
-128
Corpus.purs
src/Gargantext/Pages/Corpus.purs
+16
-89
Actions.purs
src/Gargantext/Pages/Corpus/Tabs/Actions.purs
+0
-3
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+9
-9
States.purs
src/Gargantext/Pages/Corpus/Tabs/States.purs
+22
-26
Layout.purs
src/Gargantext/Pages/Layout.purs
+2
-1
No files found.
src/Gargantext/Pages/Corpus.purs
View file @
9f6f3704
...
...
@@ -12,36 +12,24 @@ import Effect.Aff (Aff)
import React.DOM (div, h3, hr, i, p, text)
import React.DOM.Props (className, style)
import Thermite ( Render, Spec, PerformAction, focus
, simpleSpec, modifyState)
, simpleSpec, modifyState
, noState
)
--------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
---------------------------------------------------------
-- Tabs
import Gargantext.Pages.Corpus.Tabs.Documents as D
import Gargantext.Pages.Corpus.Tabs.Sources as S
import Gargantext.Pages.Corpus.Tabs.Authors as A
import Gargantext.Pages.Corpus.Tabs.Terms as T
import Gargantext.Components.Tab as Tab
import Gargantext.Pages.Corpus.Tabs.States as Tabs
import Gargantext.Pages.Corpus.Tabs.Actions as Tabs
import Gargantext.Pages.Corpus.Tabs.Specs as Tabs
-------------------------------------------------------------------
type HeaderState = { info :: Maybe (NodePoly CorpusInfo) }
type State = { headerView :: HeaderState
, docsView :: D.State
, authorsView :: A.State
, sourcesView :: S.State
, termsView :: T.State
, activeTab :: Int
, tabsView :: Tabs.State
}
initialState :: State
initialState = { headerView : { info : Nothing }
, docsView : D.initialState
, authorsView : A.initialState
, sourcesView : S.initialState
, termsView : T.initialState
, activeTab : 0
, tabsView : Tabs.initialState
}
------------------------------------------------------------------------
...
...
@@ -51,29 +39,14 @@ _info = lens (\s -> s.info) (\s ss -> s{info = ss})
_headerView :: forall a b. Lens' { headerView :: a | b } a
_headerView = lens (\s -> s.headerView) (\s ss -> s{headerView = ss})
_doclens :: Lens' State D.State
_doclens = lens (\s -> s.docsView) (\s ss -> s {docsView = ss})
_authorlens :: Lens' State A.State
_authorlens = lens (\s -> s.authorsView) (\s ss -> s {authorsView = ss})
_sourcelens :: Lens' State S.State
_sourcelens = lens (\s -> s.sourcesView) (\s ss -> s {sourcesView = ss})
_termslens :: Lens' State T.State
_termslens = lens (\s -> s.termsView) (\s ss -> s {termsView = ss})
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
_tabsView :: forall a b. Lens' { tabsView :: a | b } a
_tabsView = lens (\s -> s.tabsView) (\s ss -> s{tabsView = ss})
------------------------------------------------------------------------
data HeaderAction = Load Int
data Action = HeaderA HeaderAction
| DocviewA D.Action
| AuthorviewA A.Action
| SourceviewA S.Action
| TermsviewA T.Action
| TabViewA Tab.Action
data Action
= HeaderA HeaderAction
| TabsA Tabs.Action
_headerAction :: Prism' Action HeaderAction
_headerAction = prism HeaderA \ action ->
...
...
@@ -81,35 +54,12 @@ _headerAction = prism HeaderA \ action ->
HeaderA haction -> Right haction
_-> Left action
_docAction :: Prism' Action D.Action
_docAction = prism DocviewA \ action ->
case action of
DocviewA laction -> Right laction
_-> Left action
_authorAction :: Prism' Action A.Action
_authorAction = prism AuthorviewA \ action ->
case action of
AuthorviewA laction -> Right laction
_-> Left action
_sourceAction :: Prism' Action S.Action
_sourceAction = prism SourceviewA \ action ->
case action of
SourceviewA laction -> Right laction
_-> Left action
_termsAction :: Prism' Action T.Action
_termsAction = prism TermsviewA \ action ->
_tabsAction :: Prism' Action Tabs.Action
_tabsAction = prism TabsA \ action ->
case action of
T
ermsviewA laction -> Right l
action
T
absA taction -> Right t
action
_-> Left action
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabViewA \ action ->
case action of
TabViewA laction -> Right laction
_-> Left action
_loadAction :: Prism' HeaderAction Int
_loadAction = prism Load \ action ->
...
...
@@ -153,7 +103,8 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
------------------------------------------------------------------------
layout :: Spec State {} Action
layout = focus _headerView _headerAction corpusHeaderSpec <> facets
layout = focus _headerView _headerAction corpusHeaderSpec
<> focus _tabsView _tabsAction Tabs.statefulTabs
corpusHeaderSpec :: Spec HeaderState {} HeaderAction
corpusHeaderSpec = simpleSpec performAction render
...
...
@@ -203,27 +154,3 @@ performAction (Load nId) _ _ = do
getNode :: Int -> Aff (Either String (NodePoly CorpusInfo))
getNode id = get $ toUrl Back Node id
------------------------------------------------------------------------
-- Tabs
------------------------------------------------------------------------
facets :: Spec State {} Action
facets =
Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Documents" docPageSpec
, Tuple "Authors" authorPageSpec
, Tuple "Sources" sourcePageSpec
, Tuple "Terms" termsPageSpec
]
docPageSpec :: Spec State {} Action
docPageSpec = focus _doclens _docAction D.layoutDocview
authorPageSpec :: Spec State {} Action
authorPageSpec = focus _authorlens _authorAction A.authorspec'
sourcePageSpec :: Spec State {} Action
sourcePageSpec = focus _sourcelens _sourceAction S.sourcespec'
termsPageSpec :: Spec State {} Action
termsPageSpec = focus _termslens _termsAction T.termSpec'
src/Gargantext/Pages/Corpus/Tabs/Actions.purs
View file @
9f6f3704
...
...
@@ -46,6 +46,3 @@ _tabAction = prism TabViewA \ action ->
case action of
TabViewA laction -> Right laction
_-> Left action
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
9f6f3704
...
...
@@ -16,15 +16,15 @@ import Gargantext.Components.Tab as Tab
import Thermite (Spec, focus, hideState)
pureTab
1
:: Spec {} {} Void
pureTab
1 = hideState initialState statefulTab1
statefulTab
1
:: Spec State {} Action
statefulTab
1
=
Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Doc
View"
docPageSpec
, Tuple "Author
View"
authorPageSpec
, Tuple "Source
View"
sourcePageSpec
, Tuple "Terms
View"
termsPageSpec
pureTab
s
:: Spec {} {} Void
pureTab
s = hideState initialState statefulTabs
statefulTab
s
:: Spec State {} Action
statefulTab
s
=
Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Doc
uments"
docPageSpec
, Tuple "Author
s"
authorPageSpec
, Tuple "Source
s"
sourcePageSpec
, Tuple "Terms
"
termsPageSpec
]
docPageSpec :: Spec State {} Action
...
...
src/Gargantext/Pages/Corpus/Tabs/States.purs
View file @
9f6f3704
module Gargantext.Pages.Corpus.Tabs.States where
import Data.Lens (Lens', lens)
import Gargantext.Pages.Corpus.Tabs.Documents as D
V
import Gargantext.Pages.Corpus.Tabs.Sources
as SV
import Gargantext.Pages.Corpus.Tabs.Authors
as AV
import Gargantext.Pages.Corpus.Tabs.Terms
as TV
import Gargantext.Pages.Corpus.Tabs.Documents as D
import Gargantext.Pages.Corpus.Tabs.Sources
as S
import Gargantext.Pages.Corpus.Tabs.Authors
as A
import Gargantext.Pages.Corpus.Tabs.Terms
as T
import Gargantext.Components.Tab as Tab
type State =
{ doc
view :: DV
.State
, author
view :: AV
.State
, source
view :: SV
.State
, terms
view :: TV
.State
{ doc
sView :: D
.State
, author
sView :: A
.State
, source
sView :: S
.State
, terms
View :: T
.State
, activeTab :: Int
}
initialState :: State
initialState =
{ doc
view : DV
.initialState
, author
view : AV
.initialState
, source
view : SV
.initialState
, terms
view : TV
.initialState
{ doc
sView : D
.initialState
, author
sView : A
.initialState
, source
sView : S
.initialState
, terms
View : T
.initialState
, activeTab : 0
}
_doclens :: Lens' State D
V
.State
_doclens = lens (\s -> s.doc
view) (\s ss -> s {docv
iew = ss})
_doclens :: Lens' State D.State
_doclens = lens (\s -> s.doc
sView) (\s ss -> s {docsV
iew = ss})
_authorlens :: Lens' State A
V
.State
_authorlens = lens (\s -> s.author
view) (\s ss -> s {authorv
iew = ss})
_authorlens :: Lens' State A.State
_authorlens = lens (\s -> s.author
sView) (\s ss -> s {authorsV
iew = ss})
_sourcelens :: Lens' State S
V
.State
_sourcelens = lens (\s -> s.source
view) (\s ss -> s {sourcev
iew = ss})
_sourcelens :: Lens' State S.State
_sourcelens = lens (\s -> s.source
sView) (\s ss -> s {sourcesV
iew = ss})
_termslens :: Lens' State T
V
.State
_termslens = lens (\s -> s.terms
view) (\s ss -> s {termsv
iew = ss})
_termslens :: Lens' State T.State
_termslens = lens (\s -> s.terms
View) (\s ss -> s {termsV
iew = ss})
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
src/Gargantext/Pages/Layout.purs
View file @
9f6f3704
...
...
@@ -9,6 +9,7 @@ import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Corpus as Corpus
import Gargantext.Pages.Corpus.Document as Document
import Gargantext.Pages.Corpus.Tabs.Documents as D
import Gargantext.Pages.Corpus.Tabs.Actions as TabsA
import Gargantext.Pages.Corpus.Graph as GE
-- import Gargantext.Pages.Corpus.Tabs.Terms.NgramsTable as NG
...
...
@@ -38,7 +39,7 @@ dispatchAction dispatcher _ AddCorpus = do
dispatchAction dispatcher _ (Corpus n) = do
dispatcher $ SetRoute $ Corpus n
dispatcher $ CorpusAction $ Corpus.DocviewA $ D.UpdateNodeId n
dispatcher $ CorpusAction $ Corpus.
TabsA $ TabsA.
DocviewA $ D.UpdateNodeId n
dispatcher $ CorpusAction $ Corpus.HeaderA $ Corpus.Load n
dispatchAction dispatcher _ SearchView = do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment