Commit 6721d074 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[texts] mCorpusId refactoring

parent c67e7993
...@@ -56,10 +56,10 @@ type Path a = ( ...@@ -56,10 +56,10 @@ type Path a = (
type LayoutProps = ( type LayoutProps = (
cacheState :: R.State NT.CacheState cacheState :: R.State NT.CacheState
, corpusId :: Maybe Int
, frontends :: Frontends , frontends :: Frontends
, chart :: R.Element , chart :: R.Element
, listId :: Int , listId :: Int
, mCorpusId :: Maybe Int
, nodeId :: Int , nodeId :: Int
-- , path :: Record (Path a) -- , path :: Record (Path a)
, session :: Session , session :: Session
...@@ -73,10 +73,10 @@ type LayoutProps = ( ...@@ -73,10 +73,10 @@ type LayoutProps = (
type PageLayoutProps = ( type PageLayoutProps = (
cacheState :: R.State NT.CacheState cacheState :: R.State NT.CacheState
, corpusId :: Maybe Int
, frontends :: Frontends , frontends :: Frontends
, key :: String -- NOTE Necessary to clear the component when cache state changes , key :: String -- NOTE Necessary to clear the component when cache state changes
, listId :: Int , listId :: Int
, mCorpusId :: Maybe Int
, nodeId :: Int , nodeId :: Int
, params :: T.Params , params :: T.Params
, query :: Query , query :: Query
...@@ -113,9 +113,9 @@ docViewCpt :: R.Component Props ...@@ -113,9 +113,9 @@ docViewCpt :: R.Component Props
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
cpt { layout: { cacheState cpt { layout: { cacheState
, chart , chart
, corpusId
, frontends , frontends
, listId , listId
, mCorpusId
, nodeId , nodeId
, session , session
, showSearch , showSearch
...@@ -132,10 +132,10 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where ...@@ -132,10 +132,10 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
, if showSearch then searchBar query else H.div {} [] , if showSearch then searchBar query else H.div {} []
, H.div {className: "col-md-12"} , H.div {className: "col-md-12"}
[ pageLayout { cacheState [ pageLayout { cacheState
, corpusId
, frontends , frontends
, key: "docView-" <> (show $ fst cacheState) , key: "docView-" <> (show $ fst cacheState)
, listId , listId
, mCorpusId
, nodeId , nodeId
, params , params
, query: fst query , query: fst query
...@@ -190,16 +190,17 @@ searchBar (query /\ setQuery) = R.createElement el {} [] ...@@ -190,16 +190,17 @@ searchBar (query /\ setQuery) = R.createElement el {} []
mock :: Boolean mock :: Boolean
mock = false mock = false
type PageParams = type PageParams = {
{ corpusId :: Maybe Int listId :: Int
, listId :: Int , mCorpusId :: Maybe Int
, nodeId :: Int , nodeId :: Int
, tabType :: TabType , tabType :: TabType
, query :: Query , query :: Query
, params :: T.Params} , params :: T.Params
}
getPageHash :: Session -> PageParams -> Aff String getPageHash :: Session -> PageParams -> Aff String
getPageHash session { corpusId, listId, nodeId, query, tabType } = do getPageHash session { nodeId, tabType } = do
(get session $ tableHashRoute nodeId tabType) :: Aff String (get session $ tableHashRoute nodeId tabType) :: Aff String
convOrderBy :: Maybe (T.OrderByDirection T.ColumnName) -> Maybe OrderBy convOrderBy :: Maybe (T.OrderByDirection T.ColumnName) -> Maybe OrderBy
...@@ -235,16 +236,16 @@ pageLayout props = R.createElement pageLayoutCpt props [] ...@@ -235,16 +236,16 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Component PageLayoutProps pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
cpt props@{ cacheState cpt props@{ cacheState
, corpusId
, frontends , frontends
, listId , listId
, mCorpusId
, nodeId , nodeId
, params , params
, query , query
, session , session
, sidePanelTriggers , sidePanelTriggers
, tabType } _ = do , tabType } _ = do
let path = { corpusId, listId, nodeId, params, query, tabType } let path = { listId, mCorpusId, nodeId, params, query, tabType }
handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView) handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView)
handleResponse (HashedResponse { hash, value: res }) = ret handleResponse (HashedResponse { hash, value: res }) = ret
where where
...@@ -341,9 +342,9 @@ pagePaintRaw = R.createElement pagePaintRawCpt ...@@ -341,9 +342,9 @@ pagePaintRaw = R.createElement pagePaintRawCpt
pagePaintRawCpt :: R.Component PagePaintRawProps pagePaintRawCpt :: R.Component PagePaintRawProps
pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt where pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt where
cpt { documents cpt { documents
, layout: { corpusId , layout: { frontends
, frontends
, listId , listId
, mCorpusId
, nodeId , nodeId
, session , session
, sidePanelTriggers , sidePanelTriggers
...@@ -365,7 +366,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -365,7 +366,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
trashStyle Trash = {textDecoration: "line-through"} trashStyle Trash = {textDecoration: "line-through"}
trashStyle _ = {textDecoration: "none"} trashStyle _ = {textDecoration: "none"}
corpusDocument corpusDocument
| Just cid <- corpusId = Routes.CorpusDocument sid cid listId | Just cid <- mCorpusId = Routes.CorpusDocument sid cid listId
| otherwise = Routes.Document sid listId | otherwise = Routes.Document sid listId
colNames = T.ColumnName <$> [ "Tag", "Date", "Title", "Source"] colNames = T.ColumnName <$> [ "Tag", "Date", "Title", "Source"]
wrapColElts = const identity wrapColElts = const identity
...@@ -376,12 +377,13 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -376,12 +377,13 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
{ row: { row:
T.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ] T.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } []
, docChooser { listId, mCorpusId: corpusId, nodeId: r._id, sidePanelTriggers } [] , docChooser { listId, mCorpusId, nodeId: r._id, sidePanelTriggers } []
--, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} } --, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} }
-- TODO show date: Year-Month-Day only -- TODO show date: Year-Month-Day only
, H.div { style } [ R2.showText r.date ] , H.div { style } [ R2.showText r.date ]
, H.div { style } , H.div { style } [
[ H.a { href: url frontends $ corpusDocument r._id, target: "_blank"} [ H.text r.title ] ] H.a { href: url frontends $ corpusDocument r._id, target: "_blank"} [ H.text r.title ]
]
, H.div { style } [ H.text $ if r.source == "" then "Source" else r.source ] , H.div { style } [ H.text $ if r.source == "" then "Source" else r.source ]
] ]
, delete: true } , delete: true }
...@@ -423,9 +425,9 @@ docChooserCpt = R.hooksComponentWithModule thisModule "docChooser" cpt ...@@ -423,9 +425,9 @@ docChooserCpt = R.hooksComponentWithModule thisModule "docChooser" cpt
R2.callTrigger triggerAnnotatedDocIdChange { corpusId, listId, nodeId } R2.callTrigger triggerAnnotatedDocIdChange { corpusId, listId, nodeId }
newtype SearchQuery = SearchQuery newtype SearchQuery = SearchQuery {
{ query :: Array String parent_id :: Int
, parent_id :: Int , query :: Array String
} }
...@@ -439,8 +441,8 @@ instance encodeJsonSQuery :: EncodeJson SearchQuery where ...@@ -439,8 +441,8 @@ instance encodeJsonSQuery :: EncodeJson SearchQuery where
documentsRoute :: Int -> SessionRoute documentsRoute :: Int -> SessionRoute
documentsRoute nodeId = NodeAPI Node (Just nodeId) "documents" documentsRoute nodeId = NodeAPI Node (Just nodeId) "documents"
tableRoute :: forall row. {nodeId :: Int, tabType :: TabType, listId :: Int | row} -> SessionRoute tableRoute :: forall row. { listId :: Int, nodeId :: Int, tabType :: TabType | row} -> SessionRoute
tableRoute {nodeId, tabType, listId} = NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType) <> "&list=" <> (show listId) tableRoute { listId, nodeId, tabType } = NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType) <> "&list=" <> (show listId)
tableHashRoute :: Int -> TabType -> SessionRoute tableHashRoute :: Int -> TabType -> SessionRoute
tableHashRoute nodeId tabType = NodeAPI Node (Just nodeId) $ "table/hash" <> "?tabType=" <> (showTabType' tabType) tableHashRoute nodeId tabType = NodeAPI Node (Just nodeId) $ "table/hash" <> "?tabType=" <> (showTabType' tabType)
......
...@@ -116,9 +116,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -116,9 +116,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
docs = DT.docViewLayout docs = DT.docViewLayout
{ cacheState { cacheState
, chart , chart
, corpusId: Nothing
, frontends , frontends
, listId: defaultListId , listId: defaultListId
, mCorpusId: Nothing
, nodeId , nodeId
, session , session
, showSearch: true , showSearch: true
......
...@@ -181,7 +181,7 @@ loadDocument :: Session -> Int -> Aff NodeDocument ...@@ -181,7 +181,7 @@ loadDocument :: Session -> Int -> Aff NodeDocument
loadDocument session nodeId = get session $ NodeAPI Node (Just nodeId) "" loadDocument session nodeId = get session $ NodeAPI Node (Just nodeId) ""
loadData :: DocPath -> Aff LoadedData loadData :: DocPath -> Aff LoadedData
loadData {session, nodeId, listIds, tabType} = do loadData { listIds, nodeId, session, tabType } = do
document <- loadDocument session nodeId document <- loadDocument session nodeId
ngramsTable <- loadNgramsTable ngramsTable <- loadNgramsTable
{ listIds { listIds
......
...@@ -243,9 +243,9 @@ docViewLayoutRec { cacheState ...@@ -243,9 +243,9 @@ docViewLayoutRec { cacheState
, sidePanelTriggers } = , sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Just corpusId
, frontends , frontends
, listId , listId
, mCorpusId: Just corpusId
, nodeId: corpusId , nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
...@@ -263,9 +263,9 @@ docViewLayoutRec { cacheState ...@@ -263,9 +263,9 @@ docViewLayoutRec { cacheState
, sidePanelTriggers } = , sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Just corpusId
, frontends , frontends
, listId , listId
, mCorpusId: Just corpusId
, nodeId: corpusId , nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
...@@ -283,9 +283,9 @@ docViewLayoutRec { cacheState ...@@ -283,9 +283,9 @@ docViewLayoutRec { cacheState
, sidePanelTriggers } = , sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Just corpusId
, frontends , frontends
, listId , listId
, mCorpusId: Just corpusId
, nodeId: corpusId , nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
...@@ -303,9 +303,9 @@ docViewLayoutRec { cacheState ...@@ -303,9 +303,9 @@ docViewLayoutRec { cacheState
, sidePanelTriggers } = , sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Nothing
, frontends , frontends
, listId , listId
, mCorpusId: Just corpusId
, nodeId: corpusId , nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
...@@ -324,9 +324,9 @@ docViewLayoutRec { cacheState ...@@ -324,9 +324,9 @@ docViewLayoutRec { cacheState
, sidePanelTriggers } = , sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Nothing
, frontends , frontends
, listId , listId
, mCorpusId: Just corpusId
, nodeId: corpusId , nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
...@@ -371,7 +371,6 @@ sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt ...@@ -371,7 +371,6 @@ sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
-- log2 "[sidePanel trigger] trigger corpusId change" corpusId -- log2 "[sidePanel trigger] trigger corpusId change" corpusId
-- log2 "[sidePanel trigger] trigger listId change" listId -- log2 "[sidePanel trigger] trigger listId change" listId
-- log2 "[sidePanel trigger] trigger nodeId change" nodeId -- log2 "[sidePanel trigger] trigger nodeId change" nodeId
-- TODO work on this?
setMCorpusId $ const $ Just corpusId setMCorpusId $ const $ Just corpusId
setMListId $ const $ Just listId setMListId $ const $ Just listId
setMNodeId $ const $ Just nodeId setMNodeId $ const $ Just nodeId
......
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