Commit 38ab9629 authored by James Laver's avatar James Laver

Make document be routed also by list id

parent 03f40a8a
...@@ -51,7 +51,7 @@ initialState {} = ...@@ -51,7 +51,7 @@ initialState {} =
} }
data Action data Action
= Load Int = Load Int Int
| ChangeString String | ChangeString String
| SetInput String | SetInput String
...@@ -279,11 +279,10 @@ instance decodeDocument :: DecodeJson Document ...@@ -279,11 +279,10 @@ instance decodeDocument :: DecodeJson Document
------------------------------------------------------------------------ ------------------------------------------------------------------------
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
performAction (Load nId) _ _ = do performAction (Load lId nId) _ _ = do
node <- lift $ getNode (Just nId) node <- lift $ getNode (Just nId)
let listIds = [1]
(Versioned {version:_version, data:table}) <- lift $ loadNgramsTable {nodeId : nId (Versioned {version:_version, data:table}) <- lift $ loadNgramsTable {nodeId : nId
, listIds : listIds , listIds : [lId]
, params : { offset : 0, limit : 100, orderBy: Nothing} , params : { offset : 0, limit : 100, orderBy: Nothing}
, tabType : (TabDocument (TabNgramType CTabTerms)) , tabType : (TabDocument (TabNgramType CTabTerms))
, searchQuery : "" , searchQuery : ""
......
...@@ -49,9 +49,9 @@ dispatchAction dispatcher _ (Annuaire id) = do ...@@ -49,9 +49,9 @@ dispatchAction dispatcher _ (Annuaire id) = do
dispatchAction dispatcher _ (Folder id) = do dispatchAction dispatcher _ (Folder id) = do
dispatcher $ SetRoute $ Folder id dispatcher $ SetRoute $ Folder id
dispatchAction dispatcher _ (Document n) = do dispatchAction dispatcher _ (Document i n) = do
dispatcher $ SetRoute $ Document n dispatcher $ SetRoute $ Document i n
dispatcher $ DocumentViewA $ Document.Load n dispatcher $ DocumentViewA $ Document.Load i n
dispatchAction dispatcher _ (PGraphExplorer nid) = do dispatchAction dispatcher _ (PGraphExplorer nid) = do
dispatcher $ SetRoute $ PGraphExplorer nid dispatcher $ SetRoute $ PGraphExplorer nid
......
...@@ -59,7 +59,7 @@ pagesComponent s = case s.currentRoute of ...@@ -59,7 +59,7 @@ pagesComponent s = case s.currentRoute of
selectSpec (Corpus i) = layout0 $ cmapProps (const {nodeId: i}) $ noState Corpus.layout selectSpec (Corpus i) = layout0 $ cmapProps (const {nodeId: i}) $ noState Corpus.layout
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec (Document i) = layout0 $ focus _documentViewState _documentViewAction Annotation.docview selectSpec (Document l i) = layout0 $ focus _documentViewState _documentViewAction Annotation.docview
selectSpec (PGraphExplorer i)= layout1 $ focus _graphExplorerState _graphExplorerAction GE.specOld selectSpec (PGraphExplorer i)= layout1 $ focus _graphExplorerState _graphExplorerAction GE.specOld
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout
......
...@@ -3,6 +3,7 @@ module Gargantext.Router where ...@@ -3,6 +3,7 @@ module Gargantext.Router where
import Gargantext.Prelude import Gargantext.Prelude
import Control.Alt ((<|>)) import Control.Alt ((<|>))
import Data.Foldable (oneOf)
import Data.Int (floor) import Data.Int (floor)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect (Effect) import Effect (Effect)
...@@ -19,7 +20,7 @@ data Routes ...@@ -19,7 +20,7 @@ data Routes
| Folder Int | Folder Int
| Corpus Int | Corpus Int
| AddCorpus | AddCorpus
| Document Int | Document Int Int
| PGraphExplorer Int | PGraphExplorer Int
| Dashboard | Dashboard
| Annuaire Int | Annuaire Int
...@@ -27,19 +28,20 @@ data Routes ...@@ -27,19 +28,20 @@ data Routes
| ContactPage Int | ContactPage Int
routing :: Match Routes routing :: Match Routes
routing = routing = oneOf
Login <$ route "login" [ Login <$ route "login"
<|> SearchView <$ route "search" , SearchView <$ route "search"
<|> AddCorpus <$ route "addCorpus" , AddCorpus <$ route "addCorpus"
<|> Folder <$> (route "folder" *> int) , Folder <$> (route "folder" *> int)
<|> Corpus <$> (route "corpus" *> int) , Corpus <$> (route "corpus" *> int)
<|> Document <$> (route "document" *> int) , Document <$> (route "list" *> int) <*> (lit "document" *> int)
<|> Dashboard <$ route "dashboard" , Dashboard <$ route "dashboard"
<|> PGraphExplorer <$> (route "graph" *> int) , PGraphExplorer <$> (route "graph" *> int)
<|> Annuaire <$> (route "annuaire" *> int) , Annuaire <$> (route "annuaire" *> int)
<|> UserPage <$> (route "user" *> int) , UserPage <$> (route "user" *> int)
<|> ContactPage <$> (route "contact" *> int) , ContactPage <$> (route "contact" *> int)
<|> Home <$ lit "" , Home <$ lit ""
]
where where
route str = lit "" *> lit str route str = lit "" *> lit str
...@@ -53,7 +55,7 @@ instance showRoutes :: Show Routes where ...@@ -53,7 +55,7 @@ instance showRoutes :: Show Routes where
show SearchView = "Search" show SearchView = "Search"
show (UserPage i) = "User" <> show i show (UserPage i) = "User" <> show i
show (ContactPage i) = "Contact" <> show i show (ContactPage i) = "Contact" <> show i
show (Document i) = "Document" show (Document _ i) = "Document" <> show i
show (Corpus i) = "Corpus" <> show i show (Corpus i) = "Corpus" <> show i
show (Annuaire i) = "Annuaire" <> show i show (Annuaire i) = "Annuaire" <> show i
show (Folder i) = "Folder" <> show i show (Folder i) = "Folder" <> show i
......
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