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