Commit 8c3900e4 authored by Karen Konou's avatar Karen Konou

[Doc view] Mark document as read when clicking on the link

parent 409ace3a
...@@ -38,6 +38,7 @@ import Gargantext.Components.Table.Types as TT ...@@ -38,6 +38,7 @@ import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (AffRESTError) import Gargantext.Config.REST (AffRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..)) import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
...@@ -603,6 +604,8 @@ tableRowCpt = here.component "tableRow" cpt where ...@@ -603,6 +604,8 @@ tableRowCpt = here.component "tableRow" cpt where
, session } _ = do , session } _ = do
mCurrentDocId' <- T.useLive T.unequal mCurrentDocId mCurrentDocId' <- T.useLive T.unequal mCurrentDocId
{ goToURL } <- useLinkHandler
let cat :: Category let cat :: Category
cat = fromMaybe category (localCategories ^. at _id) cat = fromMaybe category (localCategories ^. at _id)
selected = mCurrentDocId' == Just r._id selected = mCurrentDocId' == Just r._id
...@@ -648,10 +651,16 @@ tableRowCpt = here.component "tableRow" cpt where ...@@ -648,10 +651,16 @@ tableRowCpt = here.component "tableRow" cpt where
H.div H.div
{ className: tClassName } { className: tClassName }
[ [
H.a H.button
{ href: url frontends $ corpusDocument r._id { on: { click: \_ -> do
, target: "_blank" let categoryMarked = markCategoryChecked categoryS'
, className: "text-primary" launchAff_ $ do
_ <- updateNodeContextCategory session r._id (fromMaybe 0 mCorpusId) $ cat2score categoryMarked
pure unit
T.write_ categoryMarked categoryS
goToURL $ url frontends $ corpusDocument r._id }
, className: "btn btn-link text-primary"
, type: "Button"
} }
[ H.text r.title [ H.text r.title
, H.i { className: "fa fa-external-link mx-1 small" } [] , H.i { className: "fa fa-external-link mx-1 small" } []
......
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