Commit 00901a4b authored by Karen Konou's avatar Karen Konou

[Corpus fields] make corpus name renameable

parent 105ca003
...@@ -10,6 +10,7 @@ import Effect (Effect) ...@@ -10,6 +10,7 @@ import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.FolderView as FV import Gargantext.Components.FolderView as FV
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename)
import Gargantext.Components.Nodes.Corpus (saveCorpus) import Gargantext.Components.Nodes.Corpus (saveCorpus)
import Gargantext.Components.Nodes.Corpus.Types (CorpusInfo(..), Hyperdata(..), getCorpusInfo, saveCorpusInfo) import Gargantext.Components.Nodes.Corpus.Types (CorpusInfo(..), Hyperdata(..), getCorpusInfo, saveCorpusInfo)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
...@@ -110,7 +111,7 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed ...@@ -110,7 +111,7 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
[ R2.row [FV.backButton {} []] [ R2.row [FV.backButton {} []]
, ,
R2.row R2.row
[ H.div {className: "col-md-3"} [ H.h3 {} [H.text name] ] [ H.div {className: "col-md-3"} [ H.h3 {} [renameable {icon: "", text: name, onRename: onRenameCorpus} []] ]
, H.div {className: "col-md-9"} , H.div {className: "col-md-9"}
[ H.hr {style: {height: "2px", backgroundColor: "black"}} ] [ H.hr {style: {height: "2px", backgroundColor: "black"}} ]
] ]
...@@ -147,6 +148,9 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed ...@@ -147,6 +148,9 @@ tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxed
] ]
] ]
where where
onRenameCorpus newName = do
saveCorpusName {name: newName, session, nodeId}
onRenameTitle newTitle = do onRenameTitle newTitle = do
_ <- T.modify (\(CorpusInfo c) -> CorpusInfo $ c {title = newTitle}) corpusInfoS _ <- T.modify (\(CorpusInfo c) -> CorpusInfo $ c {title = newTitle}) corpusInfoS
corpusInfo <- T.read corpusInfoS corpusInfo <- T.read corpusInfoS
...@@ -195,6 +199,16 @@ save {fields, session, nodeId} = do ...@@ -195,6 +199,16 @@ save {fields, session, nodeId} = do
_ -> pure unit _ -> pure unit
pure unit pure unit
saveCorpusName :: {name :: String, session :: Session, nodeId :: Int} -> Effect Unit
saveCorpusName {name, session, nodeId} = do
launchAff_ do
res <- rename session nodeId $ RenameValue {text: name}
liftEffect $ do
_ <- case res of
Left err -> here.log2 "[corpusLayoutView] onClickSave RESTError" err
_ -> pure unit
pure unit
tableHeaderLayout :: R2.Component TableHeaderLayoutProps tableHeaderLayout :: R2.Component TableHeaderLayoutProps
tableHeaderLayout = R.createElement tableHeaderLayoutCpt tableHeaderLayout = R.createElement tableHeaderLayoutCpt
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
......
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