[FacetTable/Search] Pass the listId param at some places

parent 0dfc506b
...@@ -64,6 +64,7 @@ instance decodeSearchResults :: DecodeJson SearchResults where ...@@ -64,6 +64,7 @@ instance decodeSearchResults :: DecodeJson SearchResults where
type Props = type Props =
{ nodeId :: Int { nodeId :: Int
, listId :: Int
, query :: TextQuery , query :: TextQuery
, totalRecords :: Int , totalRecords :: Int
, chart :: ReactElement , chart :: ReactElement
...@@ -206,7 +207,7 @@ layoutDocview = simpleSpec performAction render ...@@ -206,7 +207,7 @@ layoutDocview = simpleSpec performAction render
} }
render :: Render State Props Action render :: Render State Props Action
render dispatch {nodeId, query, totalRecords, chart, container} deletionState _ = render dispatch {nodeId, listId, query, totalRecords, chart, container} deletionState _ =
[ {- br' [ {- br'
, div [ style {textAlign : "center"}] [ text " Filter " , div [ style {textAlign : "center"}] [ text " Filter "
, input [className "form-control", style {width : "120px", display : "inline-block"}, placeholder "Filter here"] , input [className "form-control", style {width : "120px", display : "inline-block"}, placeholder "Filter here"]
...@@ -219,7 +220,7 @@ layoutDocview = simpleSpec performAction render ...@@ -219,7 +220,7 @@ layoutDocview = simpleSpec performAction render
[ chart [ chart
, div [className "col-md-12"] , div [className "col-md-12"]
[ pageLoader [ pageLoader
{ path: initialPageParams {nodeId, query} { path: initialPageParams {nodeId, listId, query}
, totalRecords , totalRecords
, deletionState , deletionState
, dispatch , dispatch
...@@ -257,7 +258,7 @@ layoutDocviewGraph = simpleSpec performAction render ...@@ -257,7 +258,7 @@ layoutDocviewGraph = simpleSpec performAction render
} }
render :: Render State Props Action render :: Render State Props Action
render dispatch {nodeId, query, totalRecords, chart, container} deletionState _ = render dispatch {nodeId, listId, query, totalRecords, chart, container} deletionState _ =
[ br' [ br'
, p [] [text ""] , p [] [text ""]
...@@ -267,7 +268,7 @@ layoutDocviewGraph = simpleSpec performAction render ...@@ -267,7 +268,7 @@ layoutDocviewGraph = simpleSpec performAction render
[ chart [ chart
, div [className "col-md-12"] , div [className "col-md-12"]
[ pageLoader [ pageLoader
{ path: initialPageParams {nodeId, query} { path: initialPageParams {nodeId, listId, query}
, totalRecords , totalRecords
, deletionState , deletionState
, dispatch , dispatch
...@@ -287,15 +288,15 @@ layoutDocviewGraph = simpleSpec performAction render ...@@ -287,15 +288,15 @@ layoutDocviewGraph = simpleSpec performAction render
type PageParams = {nodeId :: Int, query :: TextQuery, params :: T.Params} type PageParams = {nodeId :: Int, listId :: Int, query :: TextQuery, params :: T.Params}
initialPageParams :: {nodeId :: Int, query :: TextQuery} -> PageParams initialPageParams :: {nodeId :: Int, listId :: Int, query :: TextQuery} -> PageParams
initialPageParams {nodeId, query} = {nodeId, query, params: T.initialParams} initialPageParams {nodeId, listId, query} = {nodeId, listId, query, params: T.initialParams}
loadPage :: PageParams -> Aff (Array DocumentsView) loadPage :: PageParams -> Aff (Array DocumentsView)
loadPage {nodeId, query, params: {limit, offset, orderBy}} = do loadPage {nodeId, listId, query, params: {limit, offset, orderBy}} = do
logs "loading documents page: loadPage with Offset and limit" logs "loading documents page: loadPage with Offset and limit"
let url = toUrl Back (Search { offset, limit, orderBy: convOrderBy <$> orderBy }) (Just nodeId) let url = toUrl Back (Search { listId, offset, limit, orderBy: convOrderBy <$> orderBy }) (Just nodeId)
SearchResults res <- post url $ SearchQuery {query} SearchResults res <- post url $ SearchQuery {query}
pure $ res2corpus <$> res.results pure $ res2corpus <$> res.results
where where
...@@ -332,7 +333,7 @@ type PageLoaderProps row = ...@@ -332,7 +333,7 @@ type PageLoaderProps row =
} }
renderPage :: forall props path. renderPage :: forall props path.
Render (Loader.State {nodeId :: Int, query :: TextQuery | path} (Array DocumentsView)) Render (Loader.State {nodeId :: Int, listId :: Int, query :: TextQuery | path} (Array DocumentsView))
{ totalRecords :: Int { totalRecords :: Int
, dispatch :: Action -> Effect Unit , dispatch :: Action -> Effect Unit
, deletionState :: State , deletionState :: State
...@@ -343,10 +344,10 @@ renderPage :: forall props path. ...@@ -343,10 +344,10 @@ renderPage :: forall props path.
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage loaderDispatch { totalRecords, dispatch, container renderPage loaderDispatch { totalRecords, dispatch, container
, deletionState: {documentIdsToDelete, documentIdsDeleted}} , deletionState: {documentIdsToDelete, documentIdsDeleted}}
{currentPath: {nodeId, query}, loaded: Just res} _ = {currentPath: {nodeId, listId, query}, loaded: Just res} _ =
[ T.tableElt [ T.tableElt
{ rows { rows
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, query, params}) , setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, listId, query, params})
, container , container
, colNames: , colNames:
T.ColumnName <$> T.ColumnName <$>
......
...@@ -174,10 +174,9 @@ pathUrl c (PutNgrams t listid termList) i = ...@@ -174,10 +174,9 @@ pathUrl c (PutNgrams t listid termList) i =
pathUrl c Auth Nothing = c.prePath <> "auth" pathUrl c Auth Nothing = c.prePath <> "auth"
pathUrl c Auth (Just _) = "impossible" -- TODO better types pathUrl c Auth (Just _) = "impossible" -- TODO better types
pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i) pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i)
pathUrl c (Search {limit,offset,orderBy}) i = pathUrl c (Search {listId,limit,offset,orderBy}) i =
pathUrl c (NodeAPI Corpus) i pathUrl c (NodeAPI Corpus) i
<> "/search?dummy=dummy" <> "/search?list_id=" <> show listId
-- dummy is here just because offsetUrl starts with &...
<> offsetUrl offset <> limitUrl limit <> orderUrl orderBy <> offsetUrl offset <> limitUrl limit <> orderUrl orderBy
pathUrl c (CorpusMetrics {tabType, listId, limit}) i = pathUrl c (CorpusMetrics {tabType, listId, limit}) i =
pathUrl c (NodeAPI Corpus) i <> "/metrics" pathUrl c (NodeAPI Corpus) i <> "/metrics"
...@@ -333,7 +332,9 @@ data Path ...@@ -333,7 +332,9 @@ data Path
| NodeAPI NodeType | NodeAPI NodeType
| Search { {-id :: Int | Search { {-id :: Int
, query :: Array String , query :: Array String
,-} limit :: Limit ,-}
listId :: Int
, limit :: Limit
, offset :: Offset , offset :: Offset
, orderBy :: Maybe OrderBy , orderBy :: Maybe OrderBy
} }
......
...@@ -29,7 +29,7 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs ...@@ -29,7 +29,7 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
tab :: forall props state. TextQuery -> GraphSideCorpus -> Tuple String (Spec state props Tab.Action) tab :: forall props state. TextQuery -> GraphSideCorpus -> Tuple String (Spec state props Tab.Action)
tab query (GraphSideCorpus {corpusId: nodeId, corpusLabel}) = tab query (GraphSideCorpus {corpusId: nodeId, corpusLabel}) =
Tuple corpusLabel $ Tuple corpusLabel $
cmapProps (const {nodeId, query, chart, totalRecords: 4736, container}) $ cmapProps (const {nodeId, listId: 0, query, chart, totalRecords: 4736, container}) $
noState docViewSpec noState docViewSpec
where where
-- TODO totalRecords: probably need to insert a corpusLoader. -- TODO totalRecords: probably need to insert a corpusLoader.
......
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