Commit ea1147e6 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[docsTable] rows eyes opening/closing for doc annotate popup

parent cf85eb45
...@@ -34,7 +34,7 @@ import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse ...@@ -34,7 +34,7 @@ import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, delete) import Gargantext.Sessions (Session, sessionId, get, delete)
import Gargantext.Types (ListId, NodeID, NodeType(..), OrderBy(..), TableResult, TabSubType, TabType, showTabType') import Gargantext.Types (ListId, NodeID, NodeType(..), OrderBy(..), ReloadS, TableResult, TabSubType, TabType, showTabType')
import Gargantext.Utils (sortWith) import Gargantext.Utils (sortWith)
import Gargantext.Utils.CacheAPI as GUC import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.QueryString (joinQueryStrings, mQueryParamS, queryParam, queryParamS) import Gargantext.Utils.QueryString (joinQueryStrings, mQueryParamS, queryParam, queryParamS)
...@@ -351,11 +351,14 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -351,11 +351,14 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
, totalRecords } , totalRecords }
, localCategories , localCategories
, params } _ = do , params } _ = do
reload <- R.useState' 0
pure $ T.table pure $ T.table
{ colNames { colNames
, container: T.defaultContainer { title: "Documents" } , container: T.defaultContainer { title: "Documents" }
, params , params
, rows: rows localCategories , rows: rows reload localCategories
, totalRecords , totalRecords
, wrapColElts , wrapColElts
} }
...@@ -371,14 +374,14 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -371,14 +374,14 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
colNames = T.ColumnName <$> [ "Tag", "Date", "Title", "Source"] colNames = T.ColumnName <$> [ "Tag", "Date", "Title", "Source"]
wrapColElts = const identity wrapColElts = const identity
getCategory (lc /\ _) {_id, category} = fromMaybe category (lc ^. at _id) getCategory (lc /\ _) {_id, category} = fromMaybe category (lc ^. at _id)
rows lc@(_ /\ setLocalCategories) = row <$> A.toUnfoldable documents rows reload lc@(_ /\ setLocalCategories) = row <$> A.toUnfoldable documents
where where
row dv@(DocumentsView r) = row dv@(DocumentsView r) =
{ row: { row:
T.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ] T.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "column-tag flex" } [ H.div { className: "column-tag flex" } [
caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } []
, docChooser { listId, mCorpusId, nodeId: r._id, sidePanelTriggers } [] , docChooser { listId, mCorpusId, nodeId: r._id, sidePanelTriggers, tableReload: reload } []
] ]
--, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} } --, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} }
-- TODO show date: Year-Month-Day only -- TODO show date: Year-Month-Day only
...@@ -400,6 +403,7 @@ type DocChooser = ( ...@@ -400,6 +403,7 @@ type DocChooser = (
, mCorpusId :: Maybe NodeID , mCorpusId :: Maybe NodeID
, nodeId :: NodeID , nodeId :: NodeID
, sidePanelTriggers :: Record SidePanelTriggers , sidePanelTriggers :: Record SidePanelTriggers
, tableReload :: ReloadS
) )
docChooser :: R2.Component DocChooser docChooser :: R2.Component DocChooser
...@@ -414,9 +418,17 @@ docChooserCpt = R.hooksComponentWithModule thisModule "docChooser" cpt ...@@ -414,9 +418,17 @@ docChooserCpt = R.hooksComponentWithModule thisModule "docChooser" cpt
cpt { listId cpt { listId
, mCorpusId: Just corpusId , mCorpusId: Just corpusId
, nodeId , nodeId
, sidePanelTriggers: { triggerAnnotatedDocIdChange } } _ = do , sidePanelTriggers: { currentDocIdRef
, triggerAnnotatedDocIdChange }
, tableReload: (_ /\ setReload) } _ = do
let eyeClass = if (R.readRef currentDocIdRef) == Just nodeId then
"fa-eye"
else
"fa-eye-slash"
pure $ H.div { className: "doc-chooser" } [ pure $ H.div { className: "doc-chooser" } [
H.span { className: "fa fa-eye" H.span { className: "fa " <> eyeClass
, on: { click: onClick } } [] , on: { click: onClick } } []
] ]
where where
...@@ -425,6 +437,7 @@ docChooserCpt = R.hooksComponentWithModule thisModule "docChooser" cpt ...@@ -425,6 +437,7 @@ docChooserCpt = R.hooksComponentWithModule thisModule "docChooser" cpt
-- 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 }
setReload $ (_ + 1)
newtype SearchQuery = SearchQuery { newtype SearchQuery = SearchQuery {
......
...@@ -350,31 +350,40 @@ sidePanel = R.createElement sidePanelCpt ...@@ -350,31 +350,40 @@ sidePanel = R.createElement sidePanelCpt
sidePanelCpt :: R.Component SidePanelProps sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
where where
cpt { controls: { triggers: { triggerAnnotatedDocIdChange cpt { controls: { triggers: { currentDocIdRef
, triggerSidePanel } } , toggleSidePanel
, triggerAnnotatedDocIdChange
, triggerSidePanel
} }
, session } _ = do , session } _ = do
showSidePanel <- R.useState' InitialClosed showSidePanel <- R.useState' InitialClosed
R.useEffect' $ do R.useEffect' $ do
let trigger _ = do let toggleSidePanel' _ = snd showSidePanel toggleSidePanelState
snd showSidePanel $ const Opened triggerSidePanel' _ = snd showSidePanel $ const Opened
R2.setTrigger triggerSidePanel trigger R2.setTrigger toggleSidePanel toggleSidePanel'
R2.setTrigger triggerSidePanel triggerSidePanel'
(mCorpusId /\ setMCorpusId) <- R.useState' Nothing (mCorpusId /\ setMCorpusId) <- R.useState' Nothing
(mListId /\ setMListId) <- R.useState' Nothing (mListId /\ setMListId) <- R.useState' Nothing
(mNodeId /\ setMNodeId) <- R.useState' Nothing (mNodeId /\ setMNodeId) <- R.useState' Nothing
R.useEffect2 mListId mNodeId $ do R.useEffect3 mCorpusId mListId mNodeId $ do
let trigger :: Record TriggerAnnotatedDocIdChangeParams -> Effect Unit let trigger :: Record TriggerAnnotatedDocIdChangeParams -> Effect Unit
trigger { corpusId, listId, nodeId } = do trigger { corpusId, listId, nodeId } = do
-- log2 "[sidePanel trigger] trigger corpusId change" corpusId -- log2 "[sidePanel trigger] trigger corpusId change" corpusId
-- log2 "[sidePanel trigger] trigger listId change" listId -- log2 "[sidePanel trigger] trigger listId change" listId
-- log2 "[sidePanel trigger] trigger nodeId change" nodeId -- log2 "[sidePanel trigger] trigger nodeId change" nodeId
setMCorpusId $ const $ Just corpusId if mCorpusId == Just corpusId && mListId == Just listId && mNodeId == Just nodeId && R.readRef currentDocIdRef == Just nodeId then do
setMListId $ const $ Just listId R.setRef currentDocIdRef Nothing
setMNodeId $ const $ Just nodeId R2.callTrigger toggleSidePanel unit
R2.callTrigger triggerSidePanel unit else do
setMCorpusId $ const $ Just corpusId
setMListId $ const $ Just listId
setMNodeId $ const $ Just nodeId
R.setRef currentDocIdRef $ Just nodeId
R2.callTrigger triggerSidePanel unit
-- log2 "[sidePanel] trigger" trigger -- log2 "[sidePanel] trigger" trigger
R2.setTrigger triggerAnnotatedDocIdChange trigger R2.setTrigger triggerAnnotatedDocIdChange trigger
...@@ -386,10 +395,14 @@ sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt ...@@ -386,10 +395,14 @@ sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
Opened -> { display: "block" } Opened -> { display: "block" }
_ -> { display: "none" } _ -> { display: "none" }
let closeSidePanel _ = do
R.setRef currentDocIdRef Nothing
snd showSidePanel $ const Closed
pure $ H.div { style: mainStyle } [ pure $ H.div { style: mainStyle } [
H.div { className: "header" } [ H.div { className: "header" } [
H.span { className: "btn btn-danger" H.span { className: "btn btn-danger"
, on: { click: \_ -> snd showSidePanel $ const Closed } } [ , on: { click: closeSidePanel } } [
H.span { className: "fa fa-times" } [] H.span { className: "fa fa-times" } []
] ]
] ]
......
...@@ -24,17 +24,23 @@ type TriggerAnnotatedDocIdChangeParams = ( ...@@ -24,17 +24,23 @@ type TriggerAnnotatedDocIdChangeParams = (
) )
type SidePanelTriggers = ( type SidePanelTriggers = (
triggerAnnotatedDocIdChange :: R2.Trigger (Record TriggerAnnotatedDocIdChangeParams) currentDocIdRef :: R.Ref (Maybe Int)
, triggerSidePanel :: R2.Trigger Unit , toggleSidePanel :: R2.Trigger Unit -- toggles side panel
, triggerAnnotatedDocIdChange :: R2.Trigger (Record TriggerAnnotatedDocIdChangeParams)
, triggerSidePanel :: R2.Trigger Unit -- opens side panel
) )
emptySidePanelTriggers :: R.Hooks (Record SidePanelTriggers) emptySidePanelTriggers :: R.Hooks (Record SidePanelTriggers)
emptySidePanelTriggers = do emptySidePanelTriggers = do
currentDocIdRef <- R.useRef Nothing
toggleSidePanel <- R.useRef Nothing
triggerAnnotatedDocIdChange <- R.useRef Nothing triggerAnnotatedDocIdChange <- R.useRef Nothing
triggerSidePanel <- R.useRef Nothing triggerSidePanel <- R.useRef Nothing
pure $ { pure $ {
triggerAnnotatedDocIdChange currentDocIdRef
, toggleSidePanel
, triggerAnnotatedDocIdChange
, triggerSidePanel , triggerSidePanel
} }
......
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