Commit d7659cda authored by James Laver's avatar James Laver

plumb Ends thrugh DocsTable

parent e5dd7110
...@@ -57,7 +57,7 @@ type PageLoaderProps = ...@@ -57,7 +57,7 @@ type PageLoaderProps =
, listId :: Int , listId :: Int
, corpusId :: Maybe Int , corpusId :: Maybe Int
, query :: Query , query :: Query
) , ends :: Ends )
type LocalCategories = Map Int Category type LocalCategories = Map Int Category
type Query = String type Query = String
...@@ -136,13 +136,13 @@ layoutDocview :: R.State Query -> R.State T.Params -> Record Props -> R.Element ...@@ -136,13 +136,13 @@ layoutDocview :: R.State Query -> R.State T.Params -> Record Props -> R.Element
layoutDocview query tableParams@(params /\ _) p = R.createElement el p [] layoutDocview query tableParams@(params /\ _) p = R.createElement el p []
where where
el = R.hooksComponent "LayoutDocView" cpt el = R.hooksComponent "LayoutDocView" cpt
cpt {nodeId, tabType, listId, corpusId, totalRecords, chart, showSearch} _children = do cpt {ends, nodeId, tabType, listId, corpusId, totalRecords, chart, showSearch} _children = do
pure $ H.div {className: "container1"} pure $ H.div {className: "container1"}
[ H.div {className: "row"} [ H.div {className: "row"}
[ chart [ chart
, 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"}
[ pageLoader tableParams {nodeId, totalRecords, tabType, listId, corpusId, query: fst query} ] ] ] [ pageLoader tableParams {ends, nodeId, totalRecords, tabType, listId, corpusId, query: fst query} ] ] ]
onClickTrashAll nodeId = mkEffectFn1 $ \_ -> do onClickTrashAll nodeId = mkEffectFn1 $ \_ -> do
launchAff $ deleteAllDocuments p.ends nodeId launchAff $ deleteAllDocuments p.ends nodeId
...@@ -247,8 +247,8 @@ loadPage ends {nodeId, tabType, query, listId, corpusId, params: {limit, offset, ...@@ -247,8 +247,8 @@ loadPage ends {nodeId, tabType, query, listId, corpusId, params: {limit, offset,
convOrderBy _ = DateAsc -- TODO convOrderBy _ = DateAsc -- TODO
renderPage :: Ends -> R.State T.Params -> Record PageLoaderProps -> Array DocumentsView -> R.Element renderPage :: R.State T.Params -> Record PageLoaderProps -> Array DocumentsView -> R.Element
renderPage ends (_ /\ setTableParams) p res = R.createElement el p [] renderPage (_ /\ setTableParams) p res = R.createElement el p []
where where
el = R.hooksComponent "RenderPage" cpt el = R.hooksComponent "RenderPage" cpt
...@@ -259,7 +259,7 @@ renderPage ends (_ /\ setTableParams) p res = R.createElement el p [] ...@@ -259,7 +259,7 @@ renderPage ends (_ /\ setTableParams) p res = R.createElement el p []
corpusDocument (Just corpusId) = Router.CorpusDocument corpusId corpusDocument (Just corpusId) = Router.CorpusDocument corpusId
corpusDocument _ = Router.Document corpusDocument _ = Router.Document
cpt {nodeId, corpusId, listId, totalRecords} _children = do cpt {ends, nodeId, corpusId, listId, totalRecords} _children = do
localCategories <- R.useState' (mempty :: LocalCategories) localCategories <- R.useState' (mempty :: LocalCategories)
pure $ T.table pure $ T.table
{ rows: rows localCategories { rows: rows localCategories
...@@ -294,13 +294,13 @@ renderPage ends (_ /\ setTableParams) p res = R.createElement el p [] ...@@ -294,13 +294,13 @@ renderPage ends (_ /\ setTableParams) p res = R.createElement el p []
setLocalCategories $ insert nid newCat setLocalCategories $ insert nid newCat
void $ launchAff $ putCategories ends nodeId $ CategoryQuery {nodeIds: [nid], category: newCat} void $ launchAff $ putCategories ends nodeId $ CategoryQuery {nodeIds: [nid], category: newCat}
pageLoader :: Ends -> R.State T.Params -> Record PageLoaderProps -> R.Element pageLoader :: R.State T.Params -> Record PageLoaderProps -> R.Element
pageLoader ends tableParams@(pageParams /\ _) p = R.createElement el p [] pageLoader tableParams@(pageParams /\ _) p = R.createElement el p []
where where
el = R.hooksComponent "PageLoader" cpt el = R.hooksComponent "PageLoader" cpt
cpt p@{nodeId, listId, corpusId, tabType, query} _children = do cpt p@{ends, nodeId, listId, corpusId, tabType, query} _children = do
useLoader {nodeId, listId, corpusId, tabType, query, params: pageParams} (loadPage ends) $ useLoader {nodeId, listId, corpusId, tabType, query, params: pageParams} (loadPage ends) $
\loaded -> renderPage ends tableParams p loaded \loaded -> renderPage tableParams p loaded
--------------------------------------------------------- ---------------------------------------------------------
sampleData' :: DocumentsView sampleData' :: DocumentsView
...@@ -344,23 +344,6 @@ searchResults :: SearchQuery -> Aff Int ...@@ -344,23 +344,6 @@ searchResults :: SearchQuery -> Aff Int
searchResults squery = post "http://localhost:8008/count" unit searchResults squery = post "http://localhost:8008/count" unit
-- TODO -- TODO
newtype CategoryQuery = CategoryQuery {
nodeIds :: Array Int
, category :: Category
}
instance encodeJsonCategoryQuery :: EncodeJson CategoryQuery where
encodeJson (CategoryQuery post) =
"ntc_nodesId" := post.nodeIds
~> "ntc_category" := encodeJson post.category
~> jsonEmptyObject
categoryUrl :: Int -> String
categoryUrl nodeId = toUrl endConfigStateful Back Node (Just nodeId) <> "/category"
putCategories :: Int -> CategoryQuery -> Aff (Array Int)
putCategories nodeId = put $ categoryUrl nodeId
documentsUrl :: Ends -> Int -> String documentsUrl :: Ends -> Int -> String
documentsUrl ends nodeId = url ends (NodeAPI Node (Just nodeId)) <> "/documents" documentsUrl ends nodeId = url ends (NodeAPI Node (Just nodeId)) <> "/documents"
......
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