Commit 784d5604 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[forest] fix layout view, custom sidebar for texts initial impl

parent fd66a25f
...@@ -22,8 +22,7 @@ localStorageKey :: String ...@@ -22,8 +22,7 @@ localStorageKey :: String
localStorageKey = "garg-async-tasks" localStorageKey = "garg-async-tasks"
type NodeId = Int type Storage = Map.Map GT.NodeID (Array GT.AsyncTaskWithType)
type Storage = Map.Map NodeId (Array GT.AsyncTaskWithType)
empty :: Storage empty :: Storage
empty = Map.empty empty = Map.empty
...@@ -41,7 +40,7 @@ getAsyncTasks = R2.getls >>= WSS.getItem localStorageKey >>= handleMaybe ...@@ -41,7 +40,7 @@ getAsyncTasks = R2.getls >>= WSS.getItem localStorageKey >>= handleMaybe
parse s = GU.mapLeft (log2 "Error parsing serialised sessions:") (jsonParser s) parse s = GU.mapLeft (log2 "Error parsing serialised sessions:") (jsonParser s)
decode j = GU.mapLeft (log2 "Error decoding serialised sessions:") (decodeJson j) decode j = GU.mapLeft (log2 "Error decoding serialised sessions:") (decodeJson j)
getTasks :: Record ReductorProps -> NodeId -> Array GT.AsyncTaskWithType getTasks :: Record ReductorProps -> GT.NodeID -> Array GT.AsyncTaskWithType
getTasks { storage } nodeId = fromMaybe [] $ Map.lookup nodeId storage getTasks { storage } nodeId = fromMaybe [] $ Map.lookup nodeId storage
removeTaskFromList :: Array GT.AsyncTaskWithType -> GT.AsyncTaskWithType -> Array GT.AsyncTaskWithType removeTaskFromList :: Array GT.AsyncTaskWithType -> GT.AsyncTaskWithType -> Array GT.AsyncTaskWithType
...@@ -68,9 +67,9 @@ useTasks appReload treeReload = R2.useReductor act initializer unit ...@@ -68,9 +67,9 @@ useTasks appReload treeReload = R2.useReductor act initializer unit
pure { appReload, treeReload, storage } pure { appReload, treeReload, storage }
data Action = data Action =
Insert NodeId GT.AsyncTaskWithType Insert GT.NodeID GT.AsyncTaskWithType
| Finish NodeId GT.AsyncTaskWithType | Finish GT.NodeID GT.AsyncTaskWithType
| Remove NodeId GT.AsyncTaskWithType | Remove GT.NodeID GT.AsyncTaskWithType
action :: Record ReductorProps -> Action -> Effect (Record ReductorProps) action :: Record ReductorProps -> Action -> Effect (Record ReductorProps)
action p@{ treeReload, storage } (Insert nodeId t) = do action p@{ treeReload, storage } (Insert nodeId t) = do
......
...@@ -5,7 +5,6 @@ import Data.Maybe (Maybe(..), maybe') ...@@ -5,7 +5,6 @@ import Data.Maybe (Maybe(..), maybe')
import Data.Tuple (fst, snd) import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude import Gargantext.Prelude
......
...@@ -25,80 +25,61 @@ import Effect.Aff (Aff, launchAff) ...@@ -25,80 +25,61 @@ 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 Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Components.Category.Types
import Gargantext.Components.DocsTable.Types (DocumentsView(..), LocalCategories)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoaderWithCacheAPI, HashedResponse(..)) import Gargantext.Hooks.Loader (useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
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, put) import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Types (NodeType(..), OrderBy(..), TableResult, TabType, showTabType') import Gargantext.Types (NodeID, NodeType(..), OrderBy(..), TableResult, TabType, showTabType')
import Gargantext.Utils.CacheAPI as GUC import Gargantext.Utils.CacheAPI as GUC
thisModule :: String
thisModule = "Gargantext.Components.Category"
------------------------------------------------------------------------ ------------------------------------------------------------------------
data Category = Trash | UnRead | Checked | Topic | Favorite
type CarousselProps = (
categories :: Array Category category :: Category
categories = [Trash, UnRead, Checked, Topic, Favorite] , nodeId :: NodeID
, row :: DocumentsView
derive instance genericFavorite :: Generic Category _ , session :: Session
instance showCategory :: Show Category where , setLocalCategories :: R.Setter LocalCategories
show = genericShow )
instance eqCategory :: Eq Category where
eq = genericEq
instance decodeJsonCategory :: DecodeJson Category where
decodeJson json = do
obj <- decodeJson json
pure $ decodeCategory obj
instance encodeJsonCategory :: EncodeJson Category where
encodeJson cat = encodeJson (cat2score cat)
favCategory :: Category -> Category
favCategory Favorite = Topic
favCategory _ = Favorite
trashCategory :: Category -> Category
trashCategory _ = Trash
-- TODO: ?
--trashCategory Trash = UnRead
decodeCategory :: Int -> Category
decodeCategory 0 = Trash
decodeCategory 1 = UnRead
decodeCategory 2 = Checked
decodeCategory 3 = Topic
decodeCategory 4 = Favorite
decodeCategory _ = UnRead
cat2score :: Category -> Int
cat2score Trash = 0
cat2score UnRead = 1
cat2score Checked = 2
cat2score Topic = 3
cat2score Favorite = 4
-- caroussel :: Category -> R.Element -- caroussel :: Category -> R.Element
caroussel session nodeId setLocalCategories r cat = H.div {className:"flex"} divs caroussel :: R2.Component CarousselProps
caroussel = R.createElement carousselCpt
carousselCpt :: R.Component CarousselProps
carousselCpt = R.hooksComponentWithModule thisModule "caroussel" cpt
where where
divs = map (\c -> if cat == c cpt { category, nodeId, row: DocumentsView r, session, setLocalCategories } _ = do
then pure $ H.div {className:"flex"} divs
H.div { className : icon c (cat == c) } [] where
divs = map (\c -> if category == c
else then
H.div { className : icon c (cat == c) H.div { className : icon c (category == c) } []
, on: { click: onClick c}
} [] else
) (caroussel' cat) H.div { className : icon c (category == c)
, on: { click: onClick c}
caroussel' :: Category -> Array Category } []
caroussel' Trash = A.take 2 categories ) (caroussel' category)
caroussel' c = A.take 3 $ A.drop (cat2score c - 1 ) categories
caroussel' :: Category -> Array Category
onClick c = \_-> do caroussel' Trash = A.take 2 categories
setLocalCategories $ Map.insert r._id c caroussel' c = A.take 3 $ A.drop (cat2score c - 1 ) categories
void $ launchAff $ putCategories session nodeId $ CategoryQuery {nodeIds: [r._id], category: c}
onClick c = \_-> do
setLocalCategories $ Map.insert r._id c
void $ launchAff $ putCategories session nodeId $ CategoryQuery {nodeIds: [r._id], category: c}
icon :: Category -> Boolean -> String icon :: Category -> Boolean -> String
icon cat b = btn b $ "glyphicon glyphicon-" <> (color $ size b $ icon' cat b) icon cat b = btn b $ "glyphicon glyphicon-" <> (color $ size b $ icon' cat b)
......
module Gargantext.Components.Category.Types where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Gargantext.Prelude
------------------------------------------------------------------------
data Category = Trash | UnRead | Checked | Topic | Favorite
categories :: Array Category
categories = [Trash, UnRead, Checked, Topic, Favorite]
derive instance genericFavorite :: Generic Category _
instance showCategory :: Show Category where
show = genericShow
instance eqCategory :: Eq Category where
eq = genericEq
instance decodeJsonCategory :: DecodeJson Category where
decodeJson json = do
obj <- decodeJson json
pure $ decodeCategory obj
instance encodeJsonCategory :: EncodeJson Category where
encodeJson cat = encodeJson (cat2score cat)
favCategory :: Category -> Category
favCategory Favorite = Topic
favCategory _ = Favorite
trashCategory :: Category -> Category
trashCategory _ = Trash
-- TODO: ?
--trashCategory Trash = UnRead
decodeCategory :: Int -> Category
decodeCategory 0 = Trash
decodeCategory 1 = UnRead
decodeCategory 2 = Checked
decodeCategory 3 = Topic
decodeCategory 4 = Favorite
decodeCategory _ = UnRead
cat2score :: Category -> Int
cat2score Trash = 0
cat2score UnRead = 1
cat2score Checked = 2
cat2score Topic = 3
cat2score Favorite = 4
...@@ -22,15 +22,18 @@ import Reactix as R ...@@ -22,15 +22,18 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
------------------------------------------------------------------------ ------------------------------------------------------------------------
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Components.Category (Category(..), caroussel, decodeCategory) import Gargantext.Components.Category (caroussel)
import Gargantext.Components.Category.Types (Category(..), decodeCategory)
import Gargantext.Components.DocsTable.Types
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types (SidePanelTriggers)
import Gargantext.Components.Table as T import Gargantext.Components.Table as T
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..)) 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 (NodeType(..), OrderBy(..), TableResult, TabSubType, TabType, showTabType') import Gargantext.Types (NodeID, NodeType(..), OrderBy(..), 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)
...@@ -51,19 +54,20 @@ type Path a = ( ...@@ -51,19 +54,20 @@ type Path a = (
) )
type LayoutProps = ( type LayoutProps = (
cacheState :: R.State NT.CacheState cacheState :: R.State NT.CacheState
, corpusId :: Maybe Int , corpusId :: Maybe Int
, frontends :: Frontends , frontends :: Frontends
, chart :: R.Element , chart :: R.Element
, listId :: Int , listId :: Int
, nodeId :: Int , nodeId :: Int
-- , path :: Record (Path a) -- , path :: Record (Path a)
, session :: Session , session :: Session
, showSearch :: Boolean , showSearch :: Boolean
, tabType :: TabType , sidePanelTriggers :: Record SidePanelTriggers
, tabType :: TabType
-- ^ tabType is not ideal here since it is too much entangled with tabs and -- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. ) -- ngramtable. Let's see how this evolves. )
, totalRecords :: Int , totalRecords :: Int
) )
type PageLayoutProps = ( type PageLayoutProps = (
...@@ -76,97 +80,14 @@ type PageLayoutProps = ( ...@@ -76,97 +80,14 @@ type PageLayoutProps = (
, params :: T.Params , params :: T.Params
, query :: Query , query :: Query
, session :: Session , session :: Session
, sidePanelTriggers :: Record SidePanelTriggers
, tabType :: TabType , tabType :: TabType
, totalRecords :: Int , totalRecords :: Int
) )
type LocalCategories = Map Int Category
type Query = String
_documentIdsDeleted = prop (SProxy :: SProxy "documentIdsDeleted") _documentIdsDeleted = prop (SProxy :: SProxy "documentIdsDeleted")
_localCategories = prop (SProxy :: SProxy "localCategories") _localCategories = prop (SProxy :: SProxy "localCategories")
data Action
= MarkCategory Int Category
newtype DocumentsView
= DocumentsView
{ _id :: Int
, category :: Category
, date :: Int
, ngramCount :: Int
, source :: String
, title :: String
, url :: String
}
{-
derive instance genericDocumentsView :: Generic DocumentsView _
instance showDocumentsView :: Show DocumentsView where
show = genericShow
instance decodeJsonSearchType :: Argonaut.DecodeJson SearchType where
decodeJson = genericSumDecodeJson
instance encodeJsonSearchType :: Argonaut.EncodeJson SearchType where
encodeJson = genericSumEncodeJson
-}
instance decodeDocumentsView :: DecodeJson DocumentsView where
decodeJson json = do
obj <- decodeJson json
_id <- obj .: "id"
category <- obj .: "category"
date <- obj .: "date"
ngramCount <- obj .: "ngramCount"
source <- obj .: "source"
title <- obj .: "title"
url <- obj .: "url"
pure $ DocumentsView { _id, category, date, ngramCount, source, title, url }
instance encodeDocumentsView :: EncodeJson DocumentsView where
encodeJson (DocumentsView dv) =
"id" := dv._id
~> "category" := dv.category
~> "date" := dv.date
~> "ngramCount" := dv.ngramCount
~> "source" := dv.source
~> "title" := dv.title
~> "url" := dv.url
~> jsonEmptyObject
newtype Response = Response
{ cid :: Int
, hyperdata :: Hyperdata
, category :: Category
, ngramCount :: Int
, title :: String
}
newtype Hyperdata = Hyperdata
{ title :: String
, source :: String
, pub_year :: Int
}
instance decodeHyperdata :: DecodeJson Hyperdata where
decodeJson json = do
obj <- decodeJson json
title <- obj .: "title"
source <- obj .: "source"
pub_year <- obj .: "publication_year"
pure $ Hyperdata { title,source, pub_year}
instance decodeResponse :: DecodeJson Response where
decodeJson json = do
obj <- decodeJson json
category <- obj .: "category"
cid <- obj .: "id"
hyperdata <- obj .: "hyperdata"
ngramCount <- obj .: "id"
title <- obj .: "title"
pure $ Response { cid, title, category: decodeCategory category, ngramCount, hyperdata }
docViewLayout :: Record LayoutProps -> R.Element docViewLayout :: Record LayoutProps -> R.Element
docViewLayout props = R.createElement docViewLayoutCpt props [] docViewLayout props = R.createElement docViewLayoutCpt props []
...@@ -197,6 +118,7 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where ...@@ -197,6 +118,7 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
, nodeId , nodeId
, session , session
, showSearch , showSearch
, sidePanelTriggers
, tabType , tabType
, totalRecords , totalRecords
} }
...@@ -217,6 +139,7 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where ...@@ -217,6 +139,7 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt where
, params , params
, query: fst query , query: fst query
, session , session
, sidePanelTriggers
, tabType , tabType
, totalRecords , totalRecords
} ] ] ] } ] ] ]
...@@ -310,7 +233,16 @@ pageLayout props = R.createElement pageLayoutCpt props [] ...@@ -310,7 +233,16 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Component PageLayoutProps pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
cpt props@{ cacheState, corpusId, frontends, listId, nodeId, params, query, session, tabType } _ = do cpt props@{ cacheState
, corpusId
, frontends
, listId
, nodeId
, params
, query
, session
, sidePanelTriggers
, tabType } _ = do
let path = { corpusId, listId, nodeId, params, query, tabType } let path = { corpusId, listId, nodeId, params, query, tabType }
handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView) handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView)
handleResponse (HashedResponse { hash, value: res }) = ret handleResponse (HashedResponse { hash, value: res }) = ret
...@@ -402,7 +334,7 @@ pagePaintRaw props = R.createElement pagePaintRawCpt props [] ...@@ -402,7 +334,7 @@ pagePaintRaw props = R.createElement pagePaintRawCpt props []
pagePaintRawCpt :: R.Component PagePaintRawProps pagePaintRawCpt :: R.Component PagePaintRawProps
pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt where pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt where
cpt { documents cpt { documents
, layout: { corpusId, frontends, listId, nodeId, session, totalRecords } , layout: { corpusId, frontends, listId, nodeId, session, sidePanelTriggers, totalRecords }
, localCategories , localCategories
, params } _ = do , params } _ = do
pure $ T.table pure $ T.table
...@@ -427,10 +359,10 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -427,10 +359,10 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
getCategory (localCategories /\ _) {_id, category} = fromMaybe category (localCategories ^. at _id) getCategory (localCategories /\ _) {_id, category} = fromMaybe category (localCategories ^. at _id)
rows localCategories = row <$> A.toUnfoldable documents rows localCategories = row <$> A.toUnfoldable documents
where where
row (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} } [] ]
caroussel session nodeId setLocalCategories r cat caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } []
--, 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
, H.div { style } [ R2.showText r.date ] , H.div { style } [ R2.showText r.date ]
......
module Gargantext.Components.DocsTable.Types where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Map (Map)
import Data.Map as Map
import Gargantext.Prelude
import Gargantext.Components.Category.Types (Category(..), decodeCategory)
data Action
= MarkCategory Int Category
newtype DocumentsView
= DocumentsView
{ _id :: Int
, category :: Category
, date :: Int
, ngramCount :: Int
, source :: String
, title :: String
, url :: String
}
{-
derive instance genericDocumentsView :: Generic DocumentsView _
instance showDocumentsView :: Show DocumentsView where
show = genericShow
instance decodeJsonSearchType :: Argonaut.DecodeJson SearchType where
decodeJson = genericSumDecodeJson
instance encodeJsonSearchType :: Argonaut.EncodeJson SearchType where
encodeJson = genericSumEncodeJson
-}
instance decodeDocumentsView :: DecodeJson DocumentsView where
decodeJson json = do
obj <- decodeJson json
_id <- obj .: "id"
category <- obj .: "category"
date <- obj .: "date"
ngramCount <- obj .: "ngramCount"
source <- obj .: "source"
title <- obj .: "title"
url <- obj .: "url"
pure $ DocumentsView { _id, category, date, ngramCount, source, title, url }
instance encodeDocumentsView :: EncodeJson DocumentsView where
encodeJson (DocumentsView dv) =
"id" := dv._id
~> "category" := dv.category
~> "date" := dv.date
~> "ngramCount" := dv.ngramCount
~> "source" := dv.source
~> "title" := dv.title
~> "url" := dv.url
~> jsonEmptyObject
newtype Response = Response
{ cid :: Int
, hyperdata :: Hyperdata
, category :: Category
, ngramCount :: Int
, title :: String
}
newtype Hyperdata = Hyperdata
{ title :: String
, source :: String
, pub_year :: Int
}
instance decodeHyperdata :: DecodeJson Hyperdata where
decodeJson json = do
obj <- decodeJson json
title <- obj .: "title"
source <- obj .: "source"
pub_year <- obj .: "publication_year"
pure $ Hyperdata { title,source, pub_year}
instance decodeResponse :: DecodeJson Response where
decodeJson json = do
obj <- decodeJson json
category <- obj .: "category"
cid <- obj .: "id"
hyperdata <- obj .: "hyperdata"
ngramCount <- obj .: "id"
title <- obj .: "title"
pure $ Response { cid, title, category: decodeCategory category, ngramCount, hyperdata }
type LocalCategories = Map Int Category
type Query = String
...@@ -22,7 +22,8 @@ import Prelude ...@@ -22,7 +22,8 @@ import Prelude
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Gargantext.Components.Category (Category(..), CategoryQuery(..), favCategory, decodeCategory, putCategories) import Gargantext.Components.Category (CategoryQuery(..), putCategories)
import Gargantext.Components.Category.Types (Category(..), decodeCategory, favCategory)
import Gargantext.Components.Search import Gargantext.Components.Search
import Gargantext.Components.Table as T import Gargantext.Components.Table as T
import Gargantext.Ends (url, Frontends) import Gargantext.Ends (url, Frontends)
......
...@@ -133,7 +133,7 @@ forestLayoutCpt :: R.Component ForestLayoutProps ...@@ -133,7 +133,7 @@ forestLayoutCpt :: R.Component ForestLayoutProps
forestLayoutCpt = R.hooksComponentWithModule thisModule "forestLayout" cpt forestLayoutCpt = R.hooksComponentWithModule thisModule "forestLayout" cpt
where where
cpt props@{ handed } children = do cpt props@{ handed } children = do
pure $ R.fragment [ topBar { handed } [], forestLayoutMain props children ] pure $ R.fragment [ topBar { handed } [], forestLayoutRaw props children ]
-- a component, for which first child element is placed inside the top bar -- a component, for which first child element is placed inside the top bar
-- while the remaining ones are put into the main view -- while the remaining ones are put into the main view
...@@ -148,6 +148,39 @@ forestLayoutWithTopBarCpt = R.hooksComponentWithModule thisModule "forestLayoutW ...@@ -148,6 +148,39 @@ forestLayoutWithTopBarCpt = R.hooksComponentWithModule thisModule "forestLayoutW
fromMaybe { head: H.div {} [], tail: [] } $ A.uncons children fromMaybe { head: H.div {} [], tail: [] } $ A.uncons children
pure $ R.fragment [ topBar { handed } [ topBarChild ], forestLayoutMain props mainChildren ] pure $ R.fragment [ topBar { handed } [ topBarChild ], forestLayoutMain props mainChildren ]
forestLayoutRaw :: R2.Component ForestLayoutProps
forestLayoutRaw props = R.createElement forestLayoutRawCpt props
forestLayoutRawCpt :: R.Component ForestLayoutProps
forestLayoutRawCpt = R.hooksComponentWithModule thisModule "forestLayoutRaw" cpt
where
cpt { appReload
, asyncTasksRef
, backend
, frontends
, handed
, route
, sessions
, showLogin
, treeReloadRef } children = do
let ordering =
case fst handed of
LeftHanded -> A.reverse
RightHanded -> identity
pure $ R2.row $ ordering [
H.div { className: "col-md-2", style: { paddingTop: "60px" } } ([
forest { appReload
, asyncTasksRef
, backend
, frontends
, handed: fst handed
, route
, sessions
, showLogin
, treeReloadRef } ] <> children)
]
forestLayoutMain :: R2.Component ForestLayoutProps forestLayoutMain :: R2.Component ForestLayoutProps
forestLayoutMain props = R.createElement forestLayoutMainCpt props forestLayoutMain props = R.createElement forestLayoutMainCpt props
......
...@@ -20,6 +20,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter) ...@@ -20,6 +20,7 @@ import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types as TT
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==)) import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==))
...@@ -198,6 +199,8 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" ...@@ -198,6 +199,8 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
cacheState <- R.useState' NT.CacheOn cacheState <- R.useState' NT.CacheOn
sidePanelTriggers <- TT.emptySidePanelTriggers
useLoader {nodeId, reload: fst reload, session} getContactWithReload $ useLoader {nodeId, reload: fst reload, session} getContactWithReload $
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } [ H.ul { className: "col-md-12 list-group" } [
...@@ -210,13 +213,13 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" ...@@ -210,13 +213,13 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
, frontends , frontends
, nodeId , nodeId
, session , session
, sidePanelTriggers
, treeReloadRef , treeReloadRef
} }
] ]
where where
onUpdateHyperdata :: ReloadS -> HyperdataUser -> Effect Unit onUpdateHyperdata :: ReloadS -> HyperdataUser -> Effect Unit
onUpdateHyperdata (_ /\ setReload) hd = do onUpdateHyperdata (_ /\ setReload) hd = do
log2 "[onUpdateHyperdata] hd" hd
launchAff_ $ do launchAff_ $ do
_ <- saveContactHyperdata session nodeId hd _ <- saveContactHyperdata session nodeId hd
liftEffect $ setReload $ (+) 1 liftEffect $ setReload $ (+) 1
...@@ -256,6 +259,8 @@ annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayou ...@@ -256,6 +259,8 @@ annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayou
cpt { annuaireId, appReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef } _ = do cpt { annuaireId, appReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef } _ = do
cacheState <- R.useState' NT.CacheOn cacheState <- R.useState' NT.CacheOn
sidePanelTriggers <- TT.emptySidePanelTriggers
useLoader nodeId (getAnnuaireContact session annuaireId) $ useLoader nodeId (getAnnuaireContact session annuaireId) $
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } [ H.ul { className: "col-md-12 list-group" } [
...@@ -268,6 +273,7 @@ annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayou ...@@ -268,6 +273,7 @@ annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayou
, frontends , frontends
, nodeId , nodeId
, session , session
, sidePanelTriggers
, treeReloadRef , treeReloadRef
} }
] ]
......
...@@ -7,6 +7,7 @@ import Data.Generic.Rep.Show (genericShow) ...@@ -7,6 +7,7 @@ import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (fst) import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Reactix as R import Reactix as R
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
...@@ -16,9 +17,10 @@ import Gargantext.Components.NgramsTable.Core as NTC ...@@ -16,9 +17,10 @@ import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Components.Nodes.Lists.Types as NTypes import Gargantext.Components.Nodes.Lists.Types as NTypes
import Gargantext.Components.Nodes.Texts.Types (SidePanelTriggers)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (ReloadS, TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..)) import Gargantext.Types (CTabNgramType(..), NodeID, PTabNgramType(..), ReloadS, TabType(..), TabSubType(..))
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs" thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
...@@ -45,14 +47,15 @@ modeTabType' Books = CTabAuthors ...@@ -45,14 +47,15 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors modeTabType' Communication = CTabAuthors
type TabsProps = ( type TabsProps = (
appReload :: ReloadS appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor) , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, contactData :: ContactData , contactData :: ContactData
, frontends :: Frontends , frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, treeReloadRef :: R.Ref (Maybe ReloadS) , sidePanelTriggers :: Record SidePanelTriggers
, treeReloadRef :: R.Ref (Maybe ReloadS)
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -61,7 +64,15 @@ tabs props = R.createElement tabsCpt props [] ...@@ -61,7 +64,15 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
cpt { appReload, asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session, treeReloadRef } _ = do cpt { appReload
, asyncTasksRef
, cacheState
, contactData: {defaultListId}
, frontends
, nodeId
, session
, sidePanelTriggers
, treeReloadRef } _ = do
active <- R.useState' 0 active <- R.useState' 0
pure $ pure $
Tab.tabs { selected: fst active, tabs: tabs' } Tab.tabs { selected: fst active, tabs: tabs' }
...@@ -74,9 +85,32 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -74,9 +85,32 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Trash" /\ docs -- TODO pass-in trash mode , "Trash" /\ docs -- TODO pass-in trash mode
] ]
where where
patentsView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session, treeReloadRef } patentsView = { appReload
booksView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session, treeReloadRef } , asyncTasksRef
commView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session, treeReloadRef } , cacheState
, defaultListId
, mode: Patents
, nodeId
, session
, sidePanelTriggers
, treeReloadRef }
booksView = { appReload
, asyncTasksRef
, cacheState
, defaultListId
, mode: Books
, nodeId
, session
, sidePanelTriggers
, treeReloadRef }
commView = { appReload, asyncTasksRef
, cacheState
, defaultListId
, mode: Communication
, nodeId
, session
, sidePanelTriggers
, treeReloadRef }
chart = mempty chart = mempty
totalRecords = 4736 -- TODO totalRecords = 4736 -- TODO
docs = DT.docViewLayout docs = DT.docViewLayout
...@@ -88,6 +122,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -88,6 +122,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, nodeId , nodeId
, session , session
, showSearch: true , showSearch: true
, sidePanelTriggers
, tabType: TabPairing TabDocs , tabType: TabPairing TabDocs
, totalRecords , totalRecords
} }
...@@ -101,6 +136,7 @@ type NgramsViewTabsProps = ( ...@@ -101,6 +136,7 @@ type NgramsViewTabsProps = (
, mode :: Mode , mode :: Mode
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, sidePanelTriggers :: Record SidePanelTriggers
, treeReloadRef :: R.Ref (Maybe ReloadS) , treeReloadRef :: R.Ref (Maybe ReloadS)
) )
......
...@@ -28,7 +28,7 @@ import Gargantext.Components.Tab as Tab ...@@ -28,7 +28,7 @@ import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session, Sessions, sessionId, getCacheState, setCacheState) import Gargantext.Sessions (Session, Sessions, sessionId, getCacheState, setCacheState)
import Gargantext.Types (CTabNgramType(..), Handed(..), ReloadS, TabSubType(..), TabType(..)) import Gargantext.Types (CTabNgramType(..), Handed(..), NodeID, ReloadS, TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
thisModule :: String thisModule :: String
...@@ -52,21 +52,31 @@ textsWithForestCpt = R.hooksComponentWithModule thisModule "textsWithForest" cpt ...@@ -52,21 +52,31 @@ textsWithForestCpt = R.hooksComponentWithModule thisModule "textsWithForest" cpt
pure $ Forest.forestLayoutWithTopBar forestProps [ pure $ Forest.forestLayoutWithTopBar forestProps [
topBar { controls } [] topBar { controls } []
, textsLayout (Record.merge textsProps { controls }) [] , H.div {className: "col-md-10"} [
H.div {id: "page-wrapper"} [
H.div {className: "container-fluid"} [
textsLayout (Record.merge textsProps { controls }) []
]
]
]
, sidePanel { controls } []
] ]
-------------------------------------------------------- --------------------------------------------------------
type TextsLayoutControls = ( type TextsLayoutControls = (
showSidePanel :: R.State SidePanelState showSidePanel :: R.State SidePanelState
, triggers :: Record SidePanelTriggers
) )
initialControls :: R.Hooks (Record TextsLayoutControls) initialControls :: R.Hooks (Record TextsLayoutControls)
initialControls = do initialControls = do
showSidePanel <- R.useState' InitialClosed showSidePanel <- R.useState' InitialClosed
triggers <- emptySidePanelTriggers
pure $ { pure $ {
showSidePanel showSidePanel
, triggers
} }
type TopBarProps = ( type TopBarProps = (
...@@ -96,7 +106,7 @@ type CommonProps = ( ...@@ -96,7 +106,7 @@ type CommonProps = (
) )
type Props = ( type Props = (
controls :: Record TextsLayoutControls controls :: Record TextsLayoutControls
| CommonProps | CommonProps
) )
...@@ -127,7 +137,7 @@ textsLayoutWithKey = R.createElement textsLayoutWithKeyCpt ...@@ -127,7 +137,7 @@ textsLayoutWithKey = R.createElement textsLayoutWithKeyCpt
textsLayoutWithKeyCpt :: R.Component KeyProps textsLayoutWithKeyCpt :: R.Component KeyProps
textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKey" cpt textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKey" cpt
where where
cpt { frontends, nodeId, session, sessionUpdate } _children = do cpt { controls, frontends, nodeId, session, sessionUpdate } _children = do
cacheState <- R.useState' $ getCacheState NT.CacheOff session nodeId cacheState <- R.useState' $ getCacheState NT.CacheOff session nodeId
pure $ loader { nodeId, session } loadCorpusWithChild $ pure $ loader { nodeId, session } loadCorpusWithChild $
...@@ -145,7 +155,12 @@ textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKe ...@@ -145,7 +155,12 @@ textsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "textsLayoutWithKe
, query , query
, title , title
, user: authors } , user: authors }
, tabs { cacheState, corpusData, corpusId, frontends, session } , tabs { cacheState
, corpusData
, corpusId
, frontends
, session
, sidePanelTriggers: controls.triggers }
] ]
where where
afterCacheStateChange cacheState = do afterCacheStateChange cacheState = do
...@@ -166,11 +181,12 @@ modeTabType MoreLikeFav = CTabAuthors -- TODO ...@@ -166,11 +181,12 @@ modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO modeTabType MoreLikeTrash = CTabSources -- TODO
type TabsProps = ( type TabsProps = (
cacheState :: R.State NT.CacheState cacheState :: R.State NT.CacheState
, corpusData :: CorpusData , corpusData :: CorpusData
, corpusId :: Int , corpusId :: Int
, frontends :: Frontends , frontends :: Frontends
, session :: Session , session :: Session
, sidePanelTriggers :: Record SidePanelTriggers
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -179,7 +195,7 @@ tabs props = R.createElement tabsCpt props [] ...@@ -179,7 +195,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
cpt { cacheState, corpusId, corpusData, frontends, session } _ = do cpt { cacheState, corpusId, corpusData, frontends, session, sidePanelTriggers } _ = do
(selected /\ setSelected) <- R.useState' 0 (selected /\ setSelected) <- R.useState' 0
let path = initialPath let path = initialPath
...@@ -205,16 +221,18 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -205,16 +221,18 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, frontends , frontends
-- , path -- , path
, session , session
, tabType } , tabType
, sidePanelTriggers }
type DocViewProps a = ( type DocViewProps a = (
cacheState :: R.State NT.CacheState cacheState :: R.State NT.CacheState
, corpusData :: CorpusData , corpusData :: CorpusData
, corpusId :: Int , corpusId :: Int
, frontends :: Frontends , frontends :: Frontends
-- , path :: Record DT.Path -- , path :: Record DT.Path
, session :: Session , session :: Session
, tabType :: TabSubType a , tabType :: TabSubType a
, sidePanelTriggers :: Record SidePanelTriggers
) )
docView :: forall a. Record (DocViewProps a) -> R.Element docView :: forall a. Record (DocViewProps a) -> R.Element
...@@ -227,7 +245,13 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt ...@@ -227,7 +245,13 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
pure $ DT.docViewLayout $ docViewLayoutRec props pure $ DT.docViewLayout $ docViewLayoutRec props
-- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps -- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabDocs } = docViewLayoutRec { cacheState
, corpusData: { defaultListId }
, corpusId
, frontends
, session
, tabType: TabDocs
, sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Just corpusId , corpusId: Just corpusId
...@@ -237,10 +261,17 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend ...@@ -237,10 +261,17 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
, showSearch: true , showSearch: true
, sidePanelTriggers
, tabType: TabCorpus TabDocs , tabType: TabCorpus TabDocs
, totalRecords: 4737 , totalRecords: 4737
} }
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeFav } = docViewLayoutRec { cacheState
, corpusData: { defaultListId }
, corpusId
, frontends
, session
, tabType: TabMoreLikeFav
, sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Just corpusId , corpusId: Just corpusId
...@@ -250,10 +281,17 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend ...@@ -250,10 +281,17 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
, showSearch: false , showSearch: false
, sidePanelTriggers
, tabType: TabCorpus TabMoreLikeFav , tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737 , totalRecords: 4737
} }
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeTrash } = docViewLayoutRec { cacheState
, corpusData: { defaultListId }
, corpusId
, frontends
, session
, tabType: TabMoreLikeTrash
, sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Just corpusId , corpusId: Just corpusId
...@@ -263,10 +301,17 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend ...@@ -263,10 +301,17 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
, showSearch: false , showSearch: false
, sidePanelTriggers
, tabType: TabCorpus TabMoreLikeTrash , tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737 , totalRecords: 4737
} }
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabTrash } = docViewLayoutRec { cacheState
, corpusData: { defaultListId }
, corpusId
, frontends
, session
, tabType: TabTrash
, sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Nothing , corpusId: Nothing
...@@ -276,11 +321,18 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend ...@@ -276,11 +321,18 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
, showSearch: true , showSearch: true
, sidePanelTriggers
, tabType: TabCorpus TabTrash , tabType: TabCorpus TabTrash
, totalRecords: 4737 , totalRecords: 4737
} }
-- DUMMY -- DUMMY
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType } = docViewLayoutRec { cacheState
, corpusData: { defaultListId }
, corpusId
, frontends
, session
, tabType
, sidePanelTriggers } =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, corpusId: Nothing , corpusId: Nothing
...@@ -290,6 +342,29 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend ...@@ -290,6 +342,29 @@ docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontend
-- ^ TODO merge nodeId and corpusId in DT -- ^ TODO merge nodeId and corpusId in DT
, session , session
, showSearch: true , showSearch: true
, sidePanelTriggers
, tabType: TabCorpus TabTrash , tabType: TabCorpus TabTrash
, totalRecords: 4737 , totalRecords: 4737
} }
--------------------------------------------------------
type SidePanelProps = (
controls :: Record TextsLayoutControls
)
sidePanel :: R2.Component SidePanelProps
sidePanel = R.createElement sidePanelCpt
sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
where
cpt { controls: { showSidePanel: (InitialClosed /\ _) } } _ = do
pure $ H.div {} []
cpt { controls: { showSidePanel: (Closed /\ _) } } _ = do
pure $ H.div {} []
cpt { controls: { showSidePanel: (Opened /\ _) } } _ = do
pure $ H.div { className: "side-bar" } [
H.h4 {} [ H.text "Side Bar" ]
]
...@@ -28,5 +28,5 @@ sidePanelToggleButtonCpt = R.hooksComponentWithModule thisModule "sidePanelToggl ...@@ -28,5 +28,5 @@ sidePanelToggleButtonCpt = R.hooksComponentWithModule thisModule "sidePanelToggl
H.button { className: "btn btn-primary" H.button { className: "btn btn-primary"
, on: { click: \_ -> setOpen $ toggleSidePanelState } } [ H.text (text open) ] , on: { click: \_ -> setOpen $ toggleSidePanelState } } [ H.text (text open) ]
text InitialClosed = "Show Side Panel" text InitialClosed = "Show Side Panel"
text Opened = "Show Side Panel" text Opened = "Hide Side Panel"
text Closed = "Hide Side Panel" text Closed = "Show Side Panel"
module Gargantext.Components.Nodes.Texts.Types where module Gargantext.Components.Nodes.Texts.Types where
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Reactix as R
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Types (NodeID)
data SidePanelState = InitialClosed | Opened | Closed data SidePanelState = InitialClosed | Opened | Closed
derive instance eqSidePanelState :: Eq SidePanelState derive instance eqSidePanelState :: Eq SidePanelState
...@@ -9,3 +15,16 @@ toggleSidePanelState :: SidePanelState -> SidePanelState ...@@ -9,3 +15,16 @@ toggleSidePanelState :: SidePanelState -> SidePanelState
toggleSidePanelState InitialClosed = Opened toggleSidePanelState InitialClosed = Opened
toggleSidePanelState Closed = Opened toggleSidePanelState Closed = Opened
toggleSidePanelState Opened = Closed toggleSidePanelState Opened = Closed
type SidePanelTriggers = (
triggerAnnotatedDocIdChange :: R.Ref (Maybe (NodeID -> Effect Unit))
)
emptySidePanelTriggers :: R.Hooks (Record SidePanelTriggers)
emptySidePanelTriggers = do
triggerAnnotatedDocIdChange <- R.useRef Nothing
pure $ {
triggerAnnotatedDocIdChange
}
...@@ -4,11 +4,13 @@ module Gargantext.Components.Search where ...@@ -4,11 +4,13 @@ module Gargantext.Components.Search where
import Data.Argonaut as Argonaut import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Gargantext.Components.Category (Category)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Gargantext.Prelude (class Eq, class Read, class Show) import Gargantext.Prelude (class Eq, class Read, class Show)
import Gargantext.Components.Category.Types (Category)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
-- Example: -- Example:
-- [["machine","learning"],["artificial","intelligence"]] -- [["machine","learning"],["artificial","intelligence"]]
......
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