Commit ee543b41 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[lists selection] send selection into new corpus endpoint

parent c0fe027a
......@@ -335,25 +335,9 @@ newtype SearchQuery = SearchQuery
}
derive instance Generic SearchQuery _
derive instance Newtype SearchQuery _
defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery
{ query : ""
, databases : Empty
, datafield : Nothing
, files_id : []
, lang : Nothing
, limit : Nothing
, node_id : Nothing
, offset : Nothing
, order : Nothing
, selection : ListSelection.MyListsFirst
}
instance ToUrl Session SearchQuery where
toUrl (Session {backend}) q = backendUrl backend q2
where q2 = "new" <> Q.print (GT.toQuery q)
instance GT.ToQuery SearchQuery where
toQuery (SearchQuery {offset, limit, order}) =
QP.print id id $ QP.QueryPairs
......@@ -364,13 +348,28 @@ instance GT.ToQuery SearchQuery where
pair k = maybe [] $ \v ->
[ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ]
instance JSON.WriteForeign SearchQuery where
writeImpl (SearchQuery { databases, lang, node_id, query }) =
writeImpl (SearchQuery { databases, lang, node_id, query, selection }) =
JSON.writeImpl { query: String.replace (String.Pattern "\"") (String.Replacement "\\\"") query
, databases: databases
, lang: maybe "EN" show lang
, node_id: fromMaybe 0 node_id
, flowListWith: selection
}
defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery
{ query : ""
, databases : Empty
, datafield : Nothing
, files_id : []
, lang : Nothing
, limit : Nothing
, node_id : Nothing
, offset : Nothing
, order : Nothing
, selection : ListSelection.MyListsFirst
}
performSearch :: Session -> Int -> SearchQuery -> Aff (Either RESTError GT.AsyncTaskWithType)
performSearch session nodeId q = do
eTask :: Either RESTError GT.AsyncTask <- post session p q
......
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