Commit 78f5ce5d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] refresh tree after node created + cosmetics.

parent 78c93d7e
...@@ -21,7 +21,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload ...@@ -21,7 +21,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload
import Gargantext.Components.Forest.Tree.Node import Gargantext.Components.Forest.Tree.Node
import Gargantext.Components.Forest.Tree.Node.Box import Gargantext.Components.Forest.Tree.Node.Box
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Components.Loader (loader)
import Gargantext.Routes (AppRoute) import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>)) import Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>))
...@@ -49,9 +49,9 @@ treeViewCpt = R.hooksComponent "G.C.Tree.treeView" cpt ...@@ -49,9 +49,9 @@ treeViewCpt = R.hooksComponent "G.C.Tree.treeView" cpt
treeLoadView :: R.State Reload -> Record Props -> R.Element treeLoadView :: R.State Reload -> Record Props -> R.Element
treeLoadView reload p = R.createElement el p [] treeLoadView reload p = R.createElement el p []
where where
el = R.hooksComponent "TreeLoadView" cpt el = R.staticComponent "TreeLoadView" cpt
cpt {root, mCurrentRoute, session, frontends} _ = do cpt {root, mCurrentRoute, session, frontends} _ = do
useLoader root (loadNode session) $ \loaded -> loader root (loadNode session) $ \loaded ->
loadedTreeView reload {tree: loaded, mCurrentRoute, session, frontends} loadedTreeView reload {tree: loaded, mCurrentRoute, session, frontends}
type TreeViewProps = ( tree :: FTree type TreeViewProps = ( tree :: FTree
......
...@@ -12,14 +12,14 @@ import Gargantext.Sessions (Session, sessionId, get, put, post, postWwwUrlencode ...@@ -12,14 +12,14 @@ import Gargantext.Sessions (Session, sessionId, get, put, post, postWwwUrlencode
import Gargantext.Types (class ToQuery, toQuery, NodeType(..), NodePath(..), readNodeType) import Gargantext.Types (class ToQuery, toQuery, NodeType(..), NodePath(..), readNodeType)
import Prelude hiding (div) import Prelude hiding (div)
-- file upload types data Action = Submit String
data Action = Submit String | DeleteNode
| DeleteNode | CreateSubmit String NodeType
| CreateSubmit String NodeType | UploadFile FileType UploadFileContents
| UploadFile FileType UploadFileContents
----------------------------------------------------- -----------------------------------------------------
-- UploadFile Action -- UploadFile Action
-- file upload types
data FileType = CSV | PresseRIS data FileType = CSV | PresseRIS
derive instance genericFileType :: Generic FileType _ derive instance genericFileType :: Generic FileType _
...@@ -50,8 +50,7 @@ type Reload = Int ...@@ -50,8 +50,7 @@ type Reload = Int
newtype UploadFileContents = UploadFileContents String newtype UploadFileContents = UploadFileContents String
createNode :: Session -> ID -> CreateValue -> Aff (Array ID)
createNode :: Session -> ID -> CreateValue -> Aff ID
createNode session parentId = post session $ NodeAPI Node (Just parentId) "" createNode session parentId = post session $ NodeAPI Node (Just parentId) ""
renameNode :: Session -> ID -> RenameValue -> Aff (Array ID) renameNode :: Session -> ID -> RenameValue -> Aff (Array ID)
......
...@@ -17,7 +17,7 @@ import FFI.Simple ((..)) ...@@ -17,7 +17,7 @@ import FFI.Simple ((..))
import Gargantext.Components.Forest.Tree.Node.Action import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.Forest.Tree.Node import Gargantext.Components.Forest.Tree.Node
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Components.Loader (loader)
import Gargantext.Routes (AppRoute, SessionRoute(..)) import Gargantext.Routes (AppRoute, SessionRoute(..))
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, get, put, post, postWwwUrlencoded, delete) import Gargantext.Sessions (Session, sessionId, get, put, post, postWwwUrlencoded, delete)
...@@ -103,7 +103,7 @@ createNodeView d p@{nodeType} (_ /\ setPopupOpen) nodeTypes = R.createElement el ...@@ -103,7 +103,7 @@ createNodeView d p@{nodeType} (_ /\ setPopupOpen) nodeTypes = R.createElement el
-- , showConfig nt -- , showConfig nt
] ]
else else
H.button { className : "btn btn-success" H.button { className : "btn btn-primary"
, type : "button" , type : "button"
, onClick : mkEffectFn1 $ \_ -> setNodeType ( const , onClick : mkEffectFn1 $ \_ -> setNodeType ( const
$ fromMaybe nt $ fromMaybe nt
...@@ -117,7 +117,7 @@ createNodeView d p@{nodeType} (_ /\ setPopupOpen) nodeTypes = R.createElement el ...@@ -117,7 +117,7 @@ createNodeView d p@{nodeType} (_ /\ setPopupOpen) nodeTypes = R.createElement el
panelFooter :: R.State String -> R.State NodeType -> R.Element panelFooter :: R.State String -> R.State NodeType -> R.Element
panelFooter (name' /\ _) (nt /\ _) = panelFooter (name' /\ _) (nt /\ _) =
H.div {className: "panel-footer"} H.div {className: "panel-footer"}
[ H.button {className: "btn btn-success" [ H.button {className: "btn btn-primary text-center"
, type: "button" , type: "button"
, onClick: mkEffectFn1 $ \_ -> do , onClick: mkEffectFn1 $ \_ -> do
setPopupOpen $ const Nothing setPopupOpen $ const Nothing
......
...@@ -270,8 +270,11 @@ buttonClick ({id,name,nodeType,action} /\ setNodePopup) d Delete = H.div {classN ...@@ -270,8 +270,11 @@ buttonClick ({id,name,nodeType,action} /\ setNodePopup) d Delete = H.div {classN
, className: "btn glyphitem glyphicon glyphicon-trash" <> if action == (Just Delete) then " active" else "" , className: "btn glyphitem glyphicon glyphicon-trash" <> if action == (Just Delete) then " active" else ""
, id: "delete" , id: "delete"
, title: "Delete" , title: "Delete"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const {id, name, nodeType, action : Just Delete} , onClick: mkEffectFn1 $ \_ -> setNodePopup $ const { id
--, onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode} , name
, nodeType
, action : Just Delete
}
} }
[] []
] ]
...@@ -283,7 +286,6 @@ buttonClick (node@{action} /\ setNodePopup) d (Add xs) = H.div {className: "col- ...@@ -283,7 +286,6 @@ buttonClick (node@{action} /\ setNodePopup) d (Add xs) = H.div {className: "col-
, id: "add" , id: "add"
, title: "add" , title: "add"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node { action = Just $ Add xs} , onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node { action = Just $ Add xs}
--, onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode}
} }
[] []
] ]
...@@ -347,14 +349,13 @@ panelAction :: (Action -> Aff Unit) ...@@ -347,14 +349,13 @@ panelAction :: (Action -> Aff Unit)
-> R.Element -> R.Element
panelAction d {id,name,nodeType,action, session} p = case action of panelAction d {id,name,nodeType,action, session} p = case action of
(Just (Documentation x)) -> R.fragment [ H.div {} [H.text $ "More information on" <> show nodeType]] (Just (Documentation x)) -> R.fragment [ H.div {} [H.text $ "More information on" <> show nodeType]]
(Just SearchBox) -> R.fragment [ searchBar {session, databases:allDatabases} (Just SearchBox) -> R.fragment [ H.div {} [ H.text $ "Search and create a private corpus with the search query as corpus name." ]
, H.div {} [ H.text $ "Search and create a private corpus with the search query as corpus name." ] , searchBar {session, databases:allDatabases}
] ]
(Just Delete) -> case nodeType of (Just Delete) -> case nodeType of
NodeUser -> R.fragment [ H.div {} [H.text "Yes, we are RGPD compliant! But you can not delete User Node yet (we are still on development). Thanks for your comprehensin."]] NodeUser -> R.fragment [ H.div {} [H.text "Yes, we are RGPD compliant! But you can not delete User Node yet (we are still on development). Thanks for your comprehensin."]]
_ -> R.fragment [ H.div {} [H.text "Are your sure you want to delete, if yes, click again ?"], reallyDelete d] _ -> R.fragment [ H.div {} [H.text "Are your sure you want to delete, if yes, click again ?"], reallyDelete d]
(Just (Add xs)) -> createNodeView d {id, name, nodeType} p xs (Just (Add xs)) -> createNodeView d {id, name, nodeType} p xs
--R.fragment [ H.div {} [H.text "Adding configuration"]]
_ -> H.div {} [] _ -> H.div {} []
...@@ -364,7 +365,7 @@ reallyDelete d = H.div {className: "panel-footer"} ...@@ -364,7 +365,7 @@ reallyDelete d = H.div {className: "panel-footer"}
, id: "delete" , id: "delete"
, title: "Delete" , title: "Delete"
, onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode} , onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode}
[H.text "Yes, delete!"] [H.text " Yes, delete!"]
] ]
...@@ -14,7 +14,10 @@ type Props path loaded = ...@@ -14,7 +14,10 @@ type Props path loaded =
, load :: path -> Aff loaded , load :: path -> Aff loaded
, paint :: loaded -> R.Element ) , paint :: loaded -> R.Element )
loader :: forall path loaded. path -> (path -> Aff loaded) -> (loaded -> R.Element) -> R.Element loader :: forall path loaded. path
-> (path -> Aff loaded)
-> (loaded -> R.Element)
-> R.Element
loader path load paint = loader path load paint =
R.createElement loaderCpt {path,load,paint} [] R.createElement loaderCpt {path,load,paint} []
......
...@@ -46,10 +46,11 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -46,10 +46,11 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
term <- R.useState' search.term term <- R.useState' search.term
db <- R.useState' (Nothing :: Maybe Database) db <- R.useState' (Nothing :: Maybe Database)
pure $ pure $
div { className: "search-field input-group" } div { className: "search-field-group" }
[ searchInput term [ searchInput term
, div {className: "text-primary center"} [text "in"]
, databaseInput db props.databases , databaseInput db props.databases
, span { className: "input-group-btn" } [ submitButton db term props.search ] , div { className: "panel-footer" } [ submitButton db term props.search ]
] ]
hasChanged p p' = (fst p.search /= fst p'.search) hasChanged p p' = (fst p.search /= fst p'.search)
|| (p.databases /= p'.databases) || (p.databases /= p'.databases)
...@@ -57,7 +58,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -57,7 +58,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
databaseInput :: R.State (Maybe Database) -> Array Database -> R.Element databaseInput :: R.State (Maybe Database) -> Array Database -> R.Element
databaseInput (db /\ setDB) dbs = databaseInput (db /\ setDB) dbs =
R.fragment [ div { className: "form-group" } div { className: "form-group" }
[ R2.select { className: "form-control" [ R2.select { className: "form-control"
, onChange: mkEffectFn1 , onChange: mkEffectFn1
$ \e -> setDB $ \e -> setDB
...@@ -66,10 +67,9 @@ databaseInput (db /\ setDB) dbs = ...@@ -66,10 +67,9 @@ databaseInput (db /\ setDB) dbs =
$ e .. "target" .. "value" $ e .. "target" .. "value"
} (liItem <$> dbs) } (liItem <$> dbs)
] ]
]
where where
liItem :: Database -> R.Element liItem :: Database -> R.Element
liItem db = option {} [ text (show db) ] liItem db = option {className : "text-primary center"} [ text (show db) ]
...@@ -85,7 +85,10 @@ searchInput (term /\ setTerm) = ...@@ -85,7 +85,10 @@ searchInput (term /\ setTerm) =
submitButton :: R.State (Maybe Database) -> R.State String -> R.State (Maybe Search) -> R.Element submitButton :: R.State (Maybe Database) -> R.State String -> R.State (Maybe Search) -> R.Element
submitButton (database /\ _) (term /\ _) (_ /\ setSearch) = submitButton (database /\ _) (term /\ _) (_ /\ setSearch) =
button { className: "btn btn-default", type: "button", onClick: click } [ text "Search" ] button { className: "btn btn-primary text-center"
, type: "button"
, onClick: click
} [ text "Search" ]
where where
click = mkEffectFn1 $ \_ -> do click = mkEffectFn1 $ \_ -> do
case term of case term of
......
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