[ngrams] side panel is ok now

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