Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
9e228236
Commit
9e228236
authored
Feb 25, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[contact] add HyperdataUser model
parent
2f839b7e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
34 deletions
+66
-34
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+23
-13
Contacts.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
+30
-20
Types.purs
...antext/Components/Nodes/Annuaire/User/Contacts/Types.purs
+13
-1
No files found.
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
9e228236
...
...
@@ -9,7 +9,7 @@ import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
(Contact(..), HyperdataContact(..), ContactWhere(..))
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
as CT
import Gargantext.Components.Table as T
import Gargantext.Ends (url, Frontends)
import Gargantext.Routes (SessionRoute(..))
...
...
@@ -100,7 +100,7 @@ type PageProps =
, frontends :: Frontends
, pagePath :: R.State PagePath
-- , info :: AnnuaireInfo
, table :: TableResult Contact
, table :: TableResult C
T.C
ontact
)
page :: Record PageProps -> R.Element
...
...
@@ -124,10 +124,19 @@ pageCpt = R.hooksComponent "LoadedAnnuairePage" cpt
type AnnuaireId = Int
contactCells :: Session -> Frontends -> AnnuaireId -> Contact -> Array R.Element
contactCells :: Session -> Frontends -> AnnuaireId -> C
T.C
ontact -> Array R.Element
contactCells session frontends aId = render
where
render (Contact { id, hyperdata : (HyperdataContact contact@{who: who, ou:ou} ) }) =
render (CT.Contact { id, hyperdata : (CT.HyperdataUser {shared: Nothing} )}) =
[ H.text ""
, H.span {} [ H.text "name" ]
--, H.a { href, target: "blank" } [ H.text $ maybe "name" identity contact.title ]
, H.text "No ContactWhere"
, H.text "No ContactWhereDept"
, H.div {className: "nooverflow"}
[ H.text "No ContactWhereRole" ]
]
render (CT.Contact { id, hyperdata : (CT.HyperdataUser {shared: Just (CT.HyperdataContact contact@{who: who, ou:ou}) } )}) =
--let nodepath = NodePath (sessionId session) NodeContact (Just id)
let nodepath = Routes.ContactPage (sessionId session) aId id
href = url frontends nodepath in
...
...
@@ -135,17 +144,18 @@ contactCells session frontends aId = render
, H.a { href} [ H.text $ maybe "name" identity contact.title ]
--, H.a { href, target: "blank" } [ H.text $ maybe "name" identity contact.title ]
, H.text $ maybe "No ContactWhere" contactWhereOrg (head $ ou)
, H.text $ maybe "No ContactWhere" contactWhereDept (head $ ou)
, H.text $ maybe "No ContactWhere
Dept
" contactWhereDept (head $ ou)
, H.div {className: "nooverflow"}
[ H.text $ maybe "No ContactWhere" contactWhereRole (head $ ou) ] ]
contactWhereOrg (ContactWhere { organization: [] }) = "No Organization"
contactWhereOrg (ContactWhere { organization: orga }) =
[ H.text $ maybe "No ContactWhereRole" contactWhereRole (head $ ou) ] ]
contactWhereOrg (CT.ContactWhere { organization: [] }) = "No Organization"
contactWhereOrg (CT.ContactWhere { organization: orga }) =
maybe "No orga (list)" identity (head orga)
contactWhereDept (ContactWhere { labTeamDepts : [] }) = "Empty Dept"
contactWhereDept (ContactWhere { labTeamDepts : dept }) =
contactWhereDept (C
T.C
ontactWhere { labTeamDepts : [] }) = "Empty Dept"
contactWhereDept (C
T.C
ontactWhere { labTeamDepts : dept }) =
maybe "No Dept (list)" identity (head dept)
contactWhereRole (ContactWhere { role: Nothing }) = "Empty Role"
contactWhereRole (ContactWhere { role: Just role }) = role
contactWhereRole (C
T.C
ontactWhere { role: Nothing }) = "Empty Role"
contactWhereRole (C
T.C
ontactWhere { role: Just role }) = role
data HyperdataAnnuaire = HyperdataAnnuaire
...
...
@@ -198,7 +208,7 @@ instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
------------------------------------------------------------------------
loadPage :: Session -> PagePath -> AffTableResult Contact
loadPage :: Session -> PagePath -> AffTableResult C
T.C
ontact
loadPage session {nodeId, params: { offset, limit, orderBy }} =
get session children
-- TODO orderBy
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
View file @
9e228236
...
...
@@ -14,10 +14,7 @@ import Data.String (joinWith)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Loader (loader)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
( Contact(..), ContactData, ContactTouch(..), ContactWhere(..)
, ContactWho(..), HyperData(..), HyperdataContact(..) )
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes
...
...
@@ -41,6 +38,7 @@ display title elems =
, H.div { className: "col-md-8"} elems
]]]]
getFirstName :: Maybe ContactWho -> String
getFirstName obj = fromMaybe "Empty title" $ getFirstName' <$> obj
getFirstName' = fromMaybe "Empty first name" <<< _.firstName <<< unwrap
...
...
@@ -96,10 +94,24 @@ getMail' :: ContactTouch -> String
getMail' = fromMaybe "Empty mail" <<< _.mail <<< unwrap
-- | TODO format data in better design (UI) shape
contactInfos :: Hyperdata
Contact
-> Array R.Element
contactInfos (Hyperdata
Contact {who:who, ou:ou}) = item <$> items
contactInfos :: Hyperdata
User
-> Array R.Element
contactInfos (Hyperdata
User { shared }) = item <$> contactInfoItems shared
where
items =
item (name /\ value) =
H.li { className: "list-group-item" }
(infoRender (name /\ (" " <> value)))
contactInfoItems Nothing =
[ "Last Name" /\ "Empty Last Name"
, "First Name" /\ "Empty First Name"
, "Organisation" /\ "Empty Organisation"
, "Lab/Team/Dept" /\ "Empty Lab/Team/Dept"
, "Office" /\ "Empty Office"
, "City" /\ "Empty City"
, "Country" /\ "Empty Country"
, "Role" /\ "Empty Role"
, "Phone" /\ "Empty Phone"
, "Mail" /\ "Empty Mail" ]
contactInfoItems (Just (HyperdataContact {who:who, ou:ou})) =
[ "Last Name" /\ getLastName who
, "First Name" /\ getFirstName who
, "Organisation" /\ getOrga ou
...
...
@@ -110,9 +122,6 @@ contactInfos (HyperdataContact {who:who, ou:ou}) = item <$> items
, "Role" /\ getRole ou
, "Phone" /\ getPhone ou
, "Mail" /\ getMail ou ]
item (name /\ value) =
H.li { className: "list-group-item" }
(infoRender (name /\ (" " <> value)))
listInfo :: Tuple String String -> R.Element
listInfo s = listElement $ infoRender s
...
...
@@ -131,10 +140,11 @@ userLayout :: Record LayoutProps -> R.Element
userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.
static
Component "G.C.Nodes.Annuaire.User.Contacts.userLayout" cpt
userLayoutCpt = R.
hooks
Component "G.C.Nodes.Annuaire.User.Contacts.userLayout" cpt
where
cpt {frontends, nodeId, session} _ =
loader nodeId (getContact session) $
cpt {frontends, nodeId, session} _ = do
--loader nodeId (getContact session) $
useLoader nodeId (getContact session) $
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata)
...
...
@@ -143,7 +153,7 @@ userLayoutCpt = R.staticComponent "G.C.Nodes.Annuaire.User.Contacts.userLayout"
-- | toUrl to get data
getContact :: Session -> Int -> Aff ContactData
getContact session id = do
contactNode <- get session $ Routes.NodeAPI Node
Contact
(Just id) ""
contactNode <- get session $ Routes.NodeAPI Node (Just id) ""
-- TODO: we need a default list for the pairings
--defaultListIds <- get $ toUrl endConfigStateful Back (Children NodeList 0 1 Nothing) $ Just id
--case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Types.purs
View file @
9e228236
...
...
@@ -17,7 +17,7 @@ newtype Contact =
, parentId :: Maybe Int
, name :: Maybe String
, date :: Maybe String
, hyperdata :: Hyperdata
Contact
, hyperdata :: Hyperdata
User
}
derive instance newtypeContact :: Newtype Contact _
...
...
@@ -102,6 +102,18 @@ instance decodeContactTouch :: DecodeJson ContactTouch
pure $ ContactTouch {mail, phone, url}
newtype HyperdataUser =
HyperdataUser { shared :: Maybe HyperdataContact }
derive instance newtypeHyperdataUser :: Newtype HyperdataUser _
instance decodeHyperdataUser :: DecodeJson HyperdataUser
where
decodeJson json = do
obj <- decodeJson json
shared <- obj .:! "shared"
pure $ HyperdataUser { shared }
newtype HyperdataContact =
HyperdataContact { bdd :: Maybe String
, who :: Maybe ContactWho
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment