Commit 718c44e8 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[docsTable] open/close on eye click

parent 57a2253d
...@@ -380,13 +380,13 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -380,13 +380,13 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
, localCategories , localCategories
, params } _ = do , params } _ = do
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
localCategories' <- T.useLive T.unequal localCategories
mCurrentDocId <- T.useFocused mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId) (maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
mCurrentDocId' <- T.useLive T.unequal mCurrentDocId mCurrentDocId' <- T.useLive T.unequal mCurrentDocId
localCategories' <- T.useLive T.unequal localCategories
pure $ TT.table pure $ TT.table
{ colNames { colNames
, container: TT.defaultContainer { title: "Documents" } , container: TT.defaultContainer { title: "Documents" }
...@@ -417,7 +417,6 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -417,7 +417,6 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
[ docChooser { listId [ docChooser { listId
, mCorpusId , mCorpusId
, nodeId: r._id , nodeId: r._id
, selected
, sidePanel , sidePanel
, sidePanelState , sidePanelState
, tableReload: reload } [] , tableReload: reload } []
...@@ -443,15 +442,14 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -443,15 +442,14 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
where where
cat = fromMaybe category (localCategories' ^. at _id) cat = fromMaybe category (localCategories' ^. at _id)
-- checked = Star_1 == cat -- checked = Star_1 == cat
selected = mCurrentDocId' == Just r._id
tClassName = trashClassName cat selected tClassName = trashClassName cat selected
className = gi cat className = gi cat
selected = mCurrentDocId' == Just r._id
type DocChooser = ( type DocChooser = (
listId :: ListId listId :: ListId
, mCorpusId :: Maybe NodeID , mCorpusId :: Maybe NodeID
, nodeId :: NodeID , nodeId :: NodeID
, selected :: Boolean
, sidePanel :: T.Box (Maybe (Record TextsT.SidePanel)) , sidePanel :: T.Box (Maybe (Record TextsT.SidePanel))
, sidePanelState :: T.Box SidePanelState , sidePanelState :: T.Box SidePanelState
, tableReload :: T2.ReloadS , tableReload :: T2.ReloadS
...@@ -469,29 +467,37 @@ docChooserCpt = here.component "docChooser" cpt ...@@ -469,29 +467,37 @@ docChooserCpt = here.component "docChooser" cpt
cpt { listId cpt { listId
, mCorpusId: Just corpusId , mCorpusId: Just corpusId
, nodeId , nodeId
, selected
, sidePanel , sidePanel
, sidePanelState , sidePanelState
, tableReload } _ = do , tableReload } _ = do
mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
mCurrentDocId' <- T.useLive T.unequal mCurrentDocId
let eyeClass = if selected then "fa-eye" else "fa-eye-slash" let selected = mCurrentDocId' == Just nodeId
eyeClass = if selected then "fa-eye" else "fa-eye-slash"
pure $ H.div { className: "btn" } [ pure $ H.div { className: "btn" } [
H.span { className: "fa " <> eyeClass H.span { className: "fa " <> eyeClass
, on: { click: onClick } } [] , on: { click: onClick selected } } []
] ]
where where
onClick _ = do onClick selected _ = do
-- log2 "[docChooser] onClick, listId" listId -- log2 "[docChooser] onClick, listId" listId
-- log2 "[docChooser] onClick, corpusId" corpusId -- log2 "[docChooser] onClick, corpusId" corpusId
-- log2 "[docChooser] onClick, nodeId" nodeId -- log2 "[docChooser] onClick, nodeId" nodeId
-- R2.callTrigger triggerAnnotatedDocIdChange { corpusId, listId, nodeId } -- R2.callTrigger triggerAnnotatedDocIdChange { corpusId, listId, nodeId }
-- T2.reload tableReload -- T2.reload tableReload
T.write_ (Just { corpusId: corpusId if selected then do
, listId: listId T.write_ Nothing sidePanel
, mCurrentDocId: Nothing T.write_ Closed sidePanelState
, nodeId: nodeId }) sidePanel else do
T.write_ Opened sidePanelState T.write_ (Just { corpusId: corpusId
, listId: listId
, mCurrentDocId: Just nodeId
, nodeId: nodeId }) sidePanel
T.write_ Opened sidePanelState
log2 "[docChooser] sidePanel opened" sidePanelState log2 "[docChooser] sidePanel opened" sidePanelState
......
...@@ -13,8 +13,6 @@ import Effect.Aff (Aff, launchAff_) ...@@ -13,8 +13,6 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record as Record
import Record.Extra as REX
import Toestand as T import Toestand as T
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
......
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