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
1ec62fb5
Unverified
Commit
1ec62fb5
authored
Jan 10, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-TABLE] rework mode/tabType, use tabType in commit
parent
1007af86
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
56 deletions
+71
-56
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+20
-16
Config.purs
src/Gargantext/Config.purs
+12
-8
NgramsTable.purs
...Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
+21
-17
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+18
-15
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
1ec62fb5
...
...
@@ -52,7 +52,7 @@ import Thermite (PerformAction, Render, Spec, StateCoTransformer, modifyState_,
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (TermList(..), TermType, readTermList, readTermType, termLists, termTypes)
import Gargantext.Config (toUrl, End(..), Path(..))
import Gargantext.Config (toUrl, End(..), Path(..)
, TabType
)
import Gargantext.Config.REST (put)
import Gargantext.Components.Table as T
import Gargantext.Prelude
...
...
@@ -60,12 +60,16 @@ import Gargantext.Components.Loader as Loader
type Props a mode = Loader.InnerProps Int a ( mode :: mode )
type PageParams mode = {nodeId :: Int, params :: T.Params, mode :: mode}
type PageParams =
{ nodeId :: Int
, params :: T.Params
, tabType :: TabType
}
initialPageParams ::
forall mode. Int -> mode -> PageParams mode
initialPageParams nodeId
mode = {nodeId, params: T.initialParams, mod
e}
initialPageParams ::
Int -> TabType -> PageParams
initialPageParams nodeId
tabType = {nodeId, params: T.initialParams, tabTyp
e}
type Props'
mode = Loader.InnerProps (PageParams mode)
VersionedNgramsTable ()
type Props'
= Loader.InnerProps PageParams
VersionedNgramsTable ()
type NgramsTerm = String
...
...
@@ -477,10 +481,10 @@ tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable
]
]
putTable :: {nodeId :: Int} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch)
putTable {nodeId
} = put (toUrl Back (PutNgrams
Nothing) $ Just nodeId)
putTable :: {nodeId :: Int
, tabType :: TabType
} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch)
putTable {nodeId
, tabType} = put (toUrl Back (PutNgrams tabType
Nothing) $ Just nodeId)
commitPatch :: {nodeId :: Int} -> NgramsTablePatch -> StateCoTransformer State Unit
commitPatch :: {nodeId :: Int
, tabType :: TabType
} -> NgramsTablePatch -> StateCoTransformer State Unit
commitPatch props pt = do
Versioned {version, data: new_patch} <- lift $ putTable props $ Versioned {version: 1, data: pt}
when (version /= 1) $
...
...
@@ -493,13 +497,13 @@ toggleMap :: forall a. a -> Maybe a -> Maybe a
toggleMap _ (Just _) = Nothing
toggleMap b Nothing = Just b
ngramsTableSpec ::
forall mode. Spec State (Props' mode)
Action
ngramsTableSpec ::
Spec State Props'
Action
ngramsTableSpec = simpleSpec performAction render
where
setParentResetChildren :: Maybe NgramsTerm -> State -> State
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren = mempty }
performAction :: PerformAction State
(Props' mode)
Action
performAction :: PerformAction State
Props'
Action
performAction (SetTermListFilter c) _ _ = modifyState_ $ _ { termListFilter = c }
performAction (SetTermTypeFilter c) _ _ = modifyState_ $ _ { termTypeFilter = c }
performAction (SetSearchQuery s) _ _ = modifyState_ $ _ { searchQuery = s }
...
...
@@ -507,19 +511,19 @@ ngramsTableSpec = simpleSpec performAction render
modifyState_ $ setParentResetChildren p
performAction (ToggleChild b c) _ _ =
modifyState_ $ _ngramsChildren <<< at c %~ toggleMap b
performAction (SetTermListItem n pl) {path: {nodeId
}} _ = commitPatch {nodeId
} pt
performAction (SetTermListItem n pl) {path: {nodeId
, tabType}} _ = commitPatch {nodeId, tabType
} pt
where
pe = NgramsPatch { patch_list: pl, patch_children: mempty }
pt = PatchMap $ Map.singleton n pe
performAction AddTermChildren _ {ngramsParent: Nothing} =
-- impossible but harmless
pure unit
performAction AddTermChildren {path: {nodeId}}
performAction AddTermChildren {path: {nodeId
, tabType
}}
{ ngramsParent: Just parent
, ngramsChildren
} = do
modifyState_ $ setParentResetChildren Nothing
commitPatch {nodeId} pt
commitPatch {nodeId
, tabType
} pt
where
pc = patchSetFromMap ngramsChildren
pe = NgramsPatch { patch_list: mempty, patch_children: pc }
...
...
@@ -527,8 +531,8 @@ ngramsTableSpec = simpleSpec performAction render
-- TODO ROOT-UPDATE
-- patch the root of the child to be equal to the root of the parent.
render :: Render State
(Props' mode)
Action
render dispatch { path: {nodeId,
mod
e}
render :: Render State
Props'
Action
render dispatch { path: {nodeId,
tabTyp
e}
, loaded: Versioned { version, data: initTable }
, dispatch: loaderDispatch }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
...
...
@@ -537,7 +541,7 @@ ngramsTableSpec = simpleSpec performAction render
| otherwise =
[ T.tableElt
{ rows
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params,
mod
e})
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params,
tabTyp
e})
, container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, colNames:
T.ColumnName <$>
...
...
src/Gargantext/Config.purs
View file @
1ec62fb5
...
...
@@ -111,9 +111,13 @@ offsetUrl o = "&offset=" <> show o
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl = maybe "" (\x -> "&order=" <> show x)
tabTypeNgrams :: TabType -> UrlPath
tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsPut :: TabType -> UrlPath
tabTypeNgramsPut (TabCorpus t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabPairing t) = "list?ngramsType=" <> show t -- TODO
pathUrl :: Config -> Path -> Maybe Id -> UrlPath
pathUrl c (Tab t o l s) i =
...
...
@@ -123,14 +127,14 @@ pathUrl c (Children n o l s) i =
pathUrl c (NodeAPI Node) i <>
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s
pathUrl c (GetNgrams t o l listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams
Get
t
<> offsetUrl o <> limitUrl l <> listid'
where
listid' = maybe "" (\x -> "&list=" <> show x) listid
pathUrl c (PutNgrams listid) i =
pathUrl c (NodeAPI Node) i <> "/
list"
<> listid'
pathUrl c (PutNgrams
t
listid) i =
pathUrl c (NodeAPI Node) i <> "/
" <> tabTypeNgramsPut t
<> listid'
where
listid' = maybe "" (\x -> "
?
list=" <> show x) listid
listid' = maybe "" (\x -> "
&
list=" <> show x) listid
pathUrl c Auth Nothing = c.prePath <> "auth"
pathUrl c Auth (Just _) = "impossible" -- TODO better types
pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i)
...
...
@@ -194,7 +198,7 @@ data Path
| Tab TabType Offset Limit (Maybe OrderBy)
| Children NodeType Offset Limit (Maybe OrderBy)
| GetNgrams TabType Offset Limit (Maybe TermList)
| PutNgrams (Maybe TermList)
| PutNgrams
TabType
(Maybe TermList)
| NodeAPI NodeType
| Search { {-id :: Int
, query :: Array String
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
View file @
1ec62fb5
...
...
@@ -27,33 +27,35 @@ instance showMode :: Show Mode where
derive instance eqMode :: Eq Mode
type Props = NT.Props Contact Mode
type PageParams = NT.PageParams Mode
getTable :: { tab :: PTabNgramType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tab, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams (TabPairing (TabNgramType tab))
offset limit Nothing) (Just nodeId)
modeTabType :: Mode -> PTabNgramType
modeTabType Patents = PTabPatents
modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
loadPage :: PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, mode, params: {offset, limit}} =
getTable {tab: modeTabType mode, nodeId, offset, limit}
type Props = NT.Props Contact Mode
-- TODO: Move to Components.NgramsTable
getTable :: { tabType :: TabType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tabType, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams tabType offset limit Nothing) (Just nodeId)
-- TODO: Move to Components.NgramsTable
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, tabType, params: {offset, limit}} =
getTable {tabType, nodeId, offset, limit}
-- TODO this ignores orderBy
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NT.VersionedNgramsTable -> ReactElement
-- TODO: Move to Components.NgramsTable?
ngramsLoader :: Loader.Props' NT.PageParams NT.VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsTableClass :: Loader.InnerClass NT.PageParams NT.VersionedNgramsTable
ngramsTableClass = createClass "ContactsNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
...
...
@@ -62,6 +64,8 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
render :: Render {} Props Void
render _ {path: nodeId, mode} _ _ =
-- TODO: ignored loaded
[ ngramsLoader { path: NT.initialPageParams nodeId
mod
e
[ ngramsLoader { path: NT.initialPageParams nodeId
tabTyp
e
, component: ngramsTableClass
} ]
where
tabType = TabPairing $ TabNgramType $ modeTabType mode
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
1ec62fb5
...
...
@@ -29,32 +29,33 @@ derive instance eqMode :: Eq Mode
type Props = NT.Props (NodePoly CorpusInfo) Mode
type PageParams = NT.PageParams Mode
getTable :: { tab :: CTabNgramType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tab, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams (TabCorpus (TabNgramType tab))
offset limit Nothing) (Just nodeId)
modeTabType :: Mode -> CTabNgramType
modeTabType Authors = CTabAuthors
modeTabType Sources = CTabSources
modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
loadPage :: PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, mode, params: {offset, limit}} =
getTable {tab: modeTabType mode, nodeId, offset, limit}
getTable :: { tabType :: TabType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tabType, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams tabType offset limit Nothing) (Just nodeId)
-- TODO: Move to Components.NgramsTable?
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, tabType, params: {offset, limit}} =
getTable {tabType, nodeId, offset, limit}
-- TODO this ignores orderBy
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NT.VersionedNgramsTable -> ReactElement
-- TODO: Move to Components.NgramsTable?
ngramsLoader :: Loader.Props' NT.PageParams NT.VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsTableClass :: Loader.InnerClass NT.PageParams NT.VersionedNgramsTable
ngramsTableClass = createClass "CorpusNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
...
...
@@ -63,6 +64,8 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
render :: Render {} Props Void
render _ {path: nodeId, mode} _ _ =
-- TODO: ignored loaded param
[ ngramsLoader { path: NT.initialPageParams nodeId
mod
e
[ ngramsLoader { path: NT.initialPageParams nodeId
tabTyp
e
, component: ngramsTableClass
} ]
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
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