Commit aec09ff0 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-user-page' of...

Merge branch 'dev-user-page' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev
parents a016093f 81fa2009
...@@ -13,6 +13,7 @@ import Data.Newtype (unwrap) ...@@ -13,6 +13,7 @@ import Data.Newtype (unwrap)
import Data.String (joinWith) import Data.String (joinWith)
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
import Effect.Class (liftEffect)
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -112,7 +113,8 @@ contactInfoItemCpt = R.hooksComponent "G.C.N.A.U.C.contactInfoItem" cpt ...@@ -112,7 +113,8 @@ contactInfoItemCpt = R.hooksComponent "G.C.N.A.U.C.contactInfoItem" cpt
onClick _ = setIsEditing $ const true onClick _ = setIsEditing $ const true
item (true /\ setIsEditing) valueRef = item (true /\ setIsEditing) valueRef =
H.span {} [ H.span {} [
H.input { className: "form-control" H.input { autoFocus: true
, className: "form-control"
, defaultValue: R.readRef valueRef , defaultValue: R.readRef valueRef
, on: {change: \e -> R.setRef valueRef $ R2.unsafeEventValue e} , on: {change: \e -> R.setRef valueRef $ R2.unsafeEventValue e}
, placeholder } , placeholder }
...@@ -145,18 +147,21 @@ userLayoutCpt :: R.Component LayoutProps ...@@ -145,18 +147,21 @@ userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponent "G.C.Nodes.Annuaire.User.Contacts.userLayout" cpt userLayoutCpt = R.hooksComponent "G.C.Nodes.Annuaire.User.Contacts.userLayout" cpt
where where
cpt {frontends, nodeId, session} _ = do cpt {frontends, nodeId, session} _ = do
useLoader nodeId (getContact session) $ reload <- R.useState' 0
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" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata) [ display (fromMaybe "no name" name) (contactInfos hyperdata (onUpdateHyperdata reload))
, Tabs.tabs {frontends, nodeId, contactData, session} ] , Tabs.tabs {frontends, nodeId, contactData, session} ]
where where
onUpdateHyperdata :: HyperdataUser -> Effect Unit onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit
onUpdateHyperdata hd = do onUpdateHyperdata (_ /\ setReload) hd = do
log2 "[onUpdateHyperdata] hd" hd log2 "[onUpdateHyperdata] hd" hd
launchAff_ $ do launchAff_ $ do
saveContactHyperdata session nodeId hd _ <- saveContactHyperdata session nodeId hd
liftEffect $ setReload $ (+) 1
-- | toUrl to get data -- | toUrl to get data
getContact :: Session -> Int -> Aff ContactData getContact :: Session -> Int -> Aff ContactData
...@@ -171,6 +176,9 @@ getContact session id = do ...@@ -171,6 +176,9 @@ getContact session id = do
-- throwError $ error "Missing default list" -- throwError $ error "Missing default list"
pure {contactNode, defaultListId: 424242} pure {contactNode, defaultListId: 424242}
getContactWithReload :: {nodeId :: Int, reload :: Int, session :: Session} -> Aff ContactData
getContactWithReload {nodeId, session} = getContact session nodeId
saveContactHyperdata :: Session -> Int -> HyperdataUser -> Aff Int saveContactHyperdata :: Session -> Int -> HyperdataUser -> Aff Int
saveContactHyperdata session id h = do saveContactHyperdata session id h = do
put session (Routes.NodeAPI Node (Just id) "") h put session (Routes.NodeAPI Node (Just id) "") h
......
...@@ -225,7 +225,7 @@ instance encodeHyperdataContact :: EncodeJson HyperdataContact ...@@ -225,7 +225,7 @@ instance encodeHyperdataContact :: EncodeJson HyperdataContact
encodeJson (HyperdataContact {bdd, lastValidation, ou, source, title, uniqId, uniqIdBdd, who}) = encodeJson (HyperdataContact {bdd, lastValidation, ou, source, title, uniqId, uniqIdBdd, who}) =
"bdd" := bdd "bdd" := bdd
~> "lastValidation" := lastValidation ~> "lastValidation" := lastValidation
~> "ou" := ou ~> "where" := ou
~> "source" := source ~> "source" := source
~> "title" := title ~> "title" := title
~> "uniqId" := uniqId ~> "uniqId" := uniqId
......
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