[ngrams] side panel is ok now

parent f4d58b57
...@@ -273,7 +273,6 @@ type ItemProps = ...@@ -273,7 +273,6 @@ type ItemProps =
item :: R2.Leaf ItemProps item :: R2.Leaf ItemProps
item = R2.leaf itemCpt item = R2.leaf itemCpt
itemCpt :: R.Component ItemProps itemCpt :: R.Component ItemProps
itemCpt = here.component "item" cpt where itemCpt = here.component "item" cpt where
cpt { documentView: dv@(DocumentsView { id, title, source }) cpt { documentView: dv@(DocumentsView { id, title, source })
......
...@@ -568,12 +568,13 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -568,12 +568,13 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
, getNgramsChildrenAff , getNgramsChildrenAff
, getNgramsChildren , getNgramsChildren
, isEditing , isEditing
, mListId: A.head path'.listIds
, ngrams: ngramsElement ^. _NgramsElement <<< _ngrams , ngrams: ngramsElement ^. _NgramsElement <<< _ngrams
, ngramsElement , ngramsElement
, ngramsLocalPatch , ngramsLocalPatch
, ngramsSelection , ngramsSelection
, ngramsTable , ngramsTable
, session , session: path'.session
, sidePanel } [] , sidePanel } []
, delete: false , delete: false
} }
......
...@@ -233,6 +233,7 @@ type RenderNgramsItem = ...@@ -233,6 +233,7 @@ type RenderNgramsItem =
, getNgramsChildrenAff :: Maybe (NgramsTerm -> Aff (Array NgramsTerm)) , getNgramsChildrenAff :: Maybe (NgramsTerm -> Aff (Array NgramsTerm))
, getNgramsChildren :: Maybe (NgramsTerm -> Array NgramsTerm) , getNgramsChildren :: Maybe (NgramsTerm -> Array NgramsTerm)
, isEditing :: T.Box Boolean , isEditing :: T.Box Boolean
, mListId :: Maybe GT.ListId
, ngrams :: NgramsTerm , ngrams :: NgramsTerm
, ngramsElement :: NgramsElement , ngramsElement :: NgramsElement
, ngramsLocalPatch :: NgramsTablePatch , ngramsLocalPatch :: NgramsTablePatch
...@@ -252,6 +253,7 @@ renderNgramsItemCpt = here.component "renderNgramsItem" cpt ...@@ -252,6 +253,7 @@ renderNgramsItemCpt = here.component "renderNgramsItem" cpt
, dispatch , dispatch
--, getNgramsChildren --, getNgramsChildren
, isEditing , isEditing
, mListId
, ngrams , ngrams
, ngramsElement , ngramsElement
, ngramsLocalPatch , ngramsLocalPatch
...@@ -275,6 +277,7 @@ renderNgramsItemCpt = here.component "renderNgramsItem" cpt ...@@ -275,6 +277,7 @@ renderNgramsItemCpt = here.component "renderNgramsItem" cpt
[ [
ngramsContext { boxes ngramsContext { boxes
, corpusId , corpusId
, mListId
, ngrams , ngrams
, session , session
, sidePanel } [] , sidePanel } []
...@@ -416,6 +419,7 @@ nextTermList GT.CandidateTerm = GT.MapTerm ...@@ -416,6 +419,7 @@ nextTermList GT.CandidateTerm = GT.MapTerm
type NgramsContextProps = type NgramsContextProps =
( boxes :: Boxes ( boxes :: Boxes
, corpusId :: GT.CorpusId , corpusId :: GT.CorpusId
, mListId :: Maybe GT.ListId
, ngrams :: NgramsTerm , ngrams :: NgramsTerm
, session :: Session , session :: Session
, sidePanel :: T.Box (Maybe (Record SidePanel))) , sidePanel :: T.Box (Maybe (Record SidePanel)))
...@@ -427,6 +431,7 @@ ngramsContextCpt = here.component "ngramsContext" cpt where ...@@ -427,6 +431,7 @@ ngramsContextCpt = here.component "ngramsContext" cpt where
cpt { ngrams cpt { ngrams
, boxes: { sidePanelState } , boxes: { sidePanelState }
, corpusId , corpusId
, mListId
, session , session
, sidePanel } _ = do , sidePanel } _ = do
mCurrentNgrams <- mCurrentNgrams <-
...@@ -450,10 +455,10 @@ ngramsContextCpt = here.component "ngramsContext" cpt where ...@@ -450,10 +455,10 @@ ngramsContextCpt = here.component "ngramsContext" cpt where
T.write_ GT.Closed sidePanelState T.write_ GT.Closed sidePanelState
else do else do
T.write_ (Just { mCorpusId: Just corpusId T.write_ (Just { mCorpusId: Just corpusId
, mListId
, mCurrentNgrams: Just ngrams }) sidePanel , mCurrentNgrams: Just ngrams }) sidePanel
T.write_ GT.Opened sidePanelState T.write_ GT.Opened sidePanelState
pure $ H.div { className: "doc-chooser"} pure $ H.div { className: "doc-chooser"}
[ B.iconButton [ B.iconButton
{ name: eyeClass { name: eyeClass
......
...@@ -2,7 +2,7 @@ module Gargantext.Components.Nodes.Lists where ...@@ -2,7 +2,7 @@ module Gargantext.Components.Nodes.Lists where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Gargantext.Components.App.Store (Boxes) import Gargantext.Components.App.Store (Boxes)
...@@ -15,9 +15,12 @@ import Gargantext.Components.Nodes.Lists.SidePanel (SidePanel) ...@@ -15,9 +15,12 @@ import Gargantext.Components.Nodes.Lists.SidePanel (SidePanel)
import Gargantext.Components.Nodes.Lists.Tabs as Tabs import Gargantext.Components.Nodes.Lists.Tabs as Tabs
import Gargantext.Components.Nodes.Lists.Types (CacheState(..)) import Gargantext.Components.Nodes.Lists.Types (CacheState(..))
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Config (defaultFrontends)
import Gargantext.Config.REST (logRESTError, AffRESTError) import Gargantext.Config.REST (logRESTError, AffRESTError)
import Gargantext.Core.NgramsTable.Types (NgramsTerm(..)) import Gargantext.Core.NgramsTable.Types (NgramsTerm(..))
import Gargantext.Ends (url)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes
import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState, setCacheState) import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState, setCacheState)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -151,14 +154,18 @@ sidePanelNgramsContextViewCpt = here.component "sidePanelNgramsContextView" cpt ...@@ -151,14 +154,18 @@ sidePanelNgramsContextViewCpt = here.component "sidePanelNgramsContextView" cpt
case mSidePanel' of case mSidePanel' of
Nothing -> pure $ H.div {} [] Nothing -> pure $ H.div {} []
Just sidePanel' -> Just sidePanel' -> do
pure $ H.div {} [ H.text $ show sidePanel' let ngrams = maybe "" (\(NormNgramsTerm n) -> n) sidePanel'.mCurrentNgrams
pure $ H.div {} [ H.h3 {} [ H.text ngrams ]
, ngramsDocList { mCorpusId: sidePanel'.mCorpusId , ngramsDocList { mCorpusId: sidePanel'.mCorpusId
, mListId: sidePanel'.mListId
, mNgrams: sidePanel'.mCurrentNgrams , mNgrams: sidePanel'.mCurrentNgrams
, session } [] ] , session } [] ]
type NgramsDocListProps = type NgramsDocListProps =
( mCorpusId :: Maybe GT.CorpusId ( mCorpusId :: Maybe GT.CorpusId
, mListId :: Maybe GT.ListId
, mNgrams :: Maybe NgramsTerm , mNgrams :: Maybe NgramsTerm
, session :: Session ) , session :: Session )
...@@ -168,9 +175,12 @@ ngramsDocListCpt :: R.Component NgramsDocListProps ...@@ -168,9 +175,12 @@ ngramsDocListCpt :: R.Component NgramsDocListProps
ngramsDocListCpt = here.component "ngramsDocList" cpt where ngramsDocListCpt = here.component "ngramsDocList" cpt where
cpt { mCorpusId: Nothing } _ = do cpt { mCorpusId: Nothing } _ = do
pure $ H.div {} [] pure $ H.div {} []
cpt { mListId: Nothing } _ = do
pure $ H.div {} []
cpt { mNgrams: Nothing } _ = do cpt { mNgrams: Nothing } _ = do
pure $ H.div {} [] pure $ H.div {} []
cpt { mCorpusId: Just corpusId cpt { mCorpusId: Just corpusId
, mListId: Just listId
, mNgrams: Just ngrams , mNgrams: Just ngrams
, session } _ = do , session } _ = do
useLoader { errorHandler useLoader { errorHandler
...@@ -178,6 +188,7 @@ ngramsDocListCpt = here.component "ngramsDocList" cpt where ...@@ -178,6 +188,7 @@ ngramsDocListCpt = here.component "ngramsDocList" cpt where
, loader: loaderNgramsDocList , loader: loaderNgramsDocList
, render: \ctx -> ngramsDocListLoaded { contexts: ctx , render: \ctx -> ngramsDocListLoaded { contexts: ctx
, corpusId , corpusId
, listId
, ngrams , ngrams
, session } [] , session } []
} }
...@@ -196,6 +207,7 @@ loaderNgramsDocList { corpusId, ngrams: NormNgramsTerm ngrams, session } = ...@@ -196,6 +207,7 @@ loaderNgramsDocList { corpusId, ngrams: NormNgramsTerm ngrams, session } =
type NgramsDocListLoadedProps = type NgramsDocListLoadedProps =
( contexts :: Array GQLCTX.Context ( contexts :: Array GQLCTX.Context
, corpusId :: GT.CorpusId , corpusId :: GT.CorpusId
, listId :: GT.ListId
, ngrams :: NgramsTerm , ngrams :: NgramsTerm
, session :: Session ) , session :: Session )
...@@ -205,22 +217,37 @@ ngramsDocListLoadedCpt :: R.Component NgramsDocListLoadedProps ...@@ -205,22 +217,37 @@ ngramsDocListLoadedCpt :: R.Component NgramsDocListLoadedProps
ngramsDocListLoadedCpt = here.component "ngramsDocListLoaded" cpt where ngramsDocListLoadedCpt = here.component "ngramsDocListLoaded" cpt where
cpt { contexts cpt { contexts
, corpusId , corpusId
, listId
, ngrams , ngrams
, session } _ = do , session } _ = do
pure $ H.div { className: "ngrams-doc-list" } pure $ H.div { className: "ngrams-doc-list" }
[ H.text "contexts" [ H.ul { className: "list-group" } ((\item -> contextItem { corpusId
, H.ul { className: "list-group" } ((\item -> contextItem { item } [] ) <$> contexts) , item
, listId
, session } [] ) <$> contexts)
] ]
type ContextItemProps = type ContextItemProps =
( item :: GQLCTX.Context ) ( corpusId :: GT.CorpusId
, item :: GQLCTX.Context
, listId :: GT.ListId
, session :: Session )
contextItem :: R2.Component ContextItemProps contextItem :: R2.Component ContextItemProps
contextItem = R.createElement contextItemCpt contextItem = R.createElement contextItemCpt
contextItemCpt :: R.Component ContextItemProps contextItemCpt :: R.Component ContextItemProps
contextItemCpt = here.component "contextItem" cpt where contextItemCpt = here.component "contextItem" cpt where
cpt { item } _ = do cpt { corpusId
pure $ H.a { className: "list-group-item text-decoration-none" } , item
, listId
, session } _ = do
let route = Routes.CorpusDocument (sessionId session) corpusId listId item.c_id
href = url defaultFrontends route
pure $ H.a { className: "list-group-item text-decoration-none"
, href
, target: "_blank" }
[ H.div { className: "context-item-title" } [ H.div { className: "context-item-title" }
[ H.text $ maybe "" (_.hrd_title) item.c_hyperdata ] [ H.text $ maybe "" (_.hrd_title) item.c_hyperdata ]
, H.div { className: "context-item-source"} , H.div { className: "context-item-source"}
......
...@@ -2,13 +2,14 @@ module Gargantext.Components.Nodes.Lists.SidePanel where ...@@ -2,13 +2,14 @@ module Gargantext.Components.Nodes.Lists.SidePanel where
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Gargantext.Core.NgramsTable.Types (NgramsTerm) import Gargantext.Core.NgramsTable.Types (NgramsTerm)
import Gargantext.Types (CorpusId) import Gargantext.Types (CorpusId, ListId)
-- type SidePanel :: forall k. Row k -- type SidePanel :: forall k. Row k
type SidePanel = ( type SidePanel = (
mCorpusId :: Maybe CorpusId mCorpusId :: Maybe CorpusId
, mCurrentNgrams :: Maybe NgramsTerm , mCurrentNgrams :: Maybe NgramsTerm
, mListId :: Maybe ListId
) )
initialSidePanel :: Maybe (Record SidePanel) initialSidePanel :: Maybe (Record SidePanel)
......
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