Commit cae0c4bc authored by Alexandre Delanoë's avatar Alexandre Delanoë

[NGRAMS][Table] needs to adapt the type of tab for the loader.

parent 0f076527
......@@ -31,7 +31,7 @@ endConfig' v = { front : frontCaddy
-- until authentication implementation
-- (Default Root will be given after authentication)
defaultRoot :: Int
defaultRoot = 943779
defaultRoot = 950094
------------------------------------------------------------------------
frontCaddy :: Config
frontCaddy = { proto : "http://"
......@@ -149,14 +149,15 @@ instance showApiVersion :: Show ApiVersion where
show V11 = "v1.1"
------------------------------------------------------------
data TabType = TabDocs | TabTerms | TabSources | TabAuthors | TabTrash
data TabType = TabDocs | TabTerms | TabSources | TabAuthors | TabInstitutes | TabTrash
instance showTabType :: Show TabType where
show TabDocs = "Docs"
show TabTerms = "Terms"
show TabSources = "Sources"
show TabAuthors = "Authors"
show TabTrash = "Trash"
show TabDocs = "Docs"
show TabTerms = "Terms"
show TabSources = "Sources"
show TabAuthors = "Authors"
show TabInstitutes = "Institutes"
show TabTrash = "Trash"
------------------------------------------------------------
urlConfig :: NodeType -> Url
......
......@@ -80,12 +80,12 @@ _NgramsElement = _Newtype
instance decodeJsonNgramsElement :: DecodeJson NgramsElement where
decodeJson json = do
obj <- decodeJson json
ngrams <- obj .? "ngrams"
list <- obj .? "list"
occurrences <- obj .? "occurrences"
parent <- obj .?? "parent"
children' <- obj .? "children"
obj <- decodeJson json
ngrams <- obj .? "ngrams"
list <- obj .? "list"
occurrences <- obj .? "occurrences"
parent <- obj .?? "parent"
children' <- obj .? "children"
let children = Set.fromFoldable (children' :: Array NgramsTerm)
pure $ NgramsElement {ngrams, list, occurrences, parent, children}
......@@ -297,7 +297,7 @@ data Action
| SetTermTypeFilter (Maybe TermType)
| SetSearchQuery String
data Mode = Authors | Sources | Terms | Trash
data Mode = Authors | Sources | Institutes | Terms
type Dispatch = Action -> Effect Unit
......@@ -488,11 +488,12 @@ type PageLoaderProps =
--, corpusInfo :: Maybe (NodePoly CorpusInfo)
}
getNgramsTable :: Maybe Int -> Aff NgramsTable
getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
getTable :: TabType -> Maybe Int -> Aff NgramsTable
getTable tab = get <<< toUrl Back (Ngrams tab Nothing)
-- TODO TabTerms or TabAuthors ...
loadPage :: PageParams -> Aff NgramsTable
loadPage {nodeId} = getNgramsTable (Just nodeId) -- TODO this ignores params
loadPage {nodeId} = getTable TabTerms (Just nodeId) -- TODO this ignores params
ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable)
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage
......
......@@ -23,6 +23,7 @@ statefulTabs =
Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Documents" docPageSpec
, Tuple "Authors" authorPageSpec
, Tuple "Sources" sourcePageSpec
, Tuple "Institutes" institutesPageSpec
, Tuple "Terms" termsPageSpec
, Tuple "Trash" trashPageSpec
]
......@@ -41,8 +42,13 @@ authorPageSpec = ngramsViewSpec {mode: NV.Authors}
sourcePageSpec :: Spec State Props Action
sourcePageSpec = ngramsViewSpec {mode: NV.Sources}
institutesPageSpec :: Spec State Props Action
institutesPageSpec = ngramsViewSpec {mode: NV.Institutes}
termsPageSpec :: Spec State Props Action
termsPageSpec = ngramsViewSpec {mode: NV.Terms}
trashPageSpec :: Spec State Props Action
trashPageSpec = ngramsViewSpec {mode: NV.Trash}
trashPageSpec = focus _doclens _docAction DV.layoutDocview
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