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

[UserPage] needs right alignment.

parent cf0c1d4a
......@@ -7,3 +7,6 @@ to rebuild (after a major upgrade) use ./rebuild
to add a new dependency: psc-package install PACKAGE
use git, commit and pull request :)
## Indentation
- 2 spaces
......@@ -155,18 +155,18 @@ renderContactCells Nothing = []
renderContactCells (Just (Contact { id, hyperdata : (HyperdataContact contact@{who: who, ou:ou} ) })) =
[ text ""
, a [ href (toUrl Front NodeContact (Just id)) ] [ text $ maybe "name" identity contact.title ]
, text $ maybe "No ContactWhere" renderContactWhereOrg (join $ head <$> ou)
, text $ maybe "No ContactWhere" renderContactWhereDept (join $ head <$> ou)
, text $ maybe "No ContactWhere" renderContactWhereRole (join $ head <$> ou)
, text $ maybe "No ContactWhere" renderContactWhereOrg (head $ ou)
, text $ maybe "No ContactWhere" renderContactWhereDept (head $ ou)
, text $ maybe "No ContactWhere" renderContactWhereRole (head $ ou)
]
where
maybe' = maybe "" identity
renderContactWhereOrg (ContactWhere { organization: Nothing }) = "No Organization"
renderContactWhereOrg (ContactWhere { organization: Just orga }) =
renderContactWhereOrg (ContactWhere { organization: [] }) = "No Organization"
renderContactWhereOrg (ContactWhere { organization: orga }) =
maybe "No orga (list)" identity (head orga)
renderContactWhereDept (ContactWhere { labTeamDepts : Nothing }) = "Empty Dept"
renderContactWhereDept (ContactWhere { labTeamDepts : Just dept }) =
renderContactWhereDept (ContactWhere { labTeamDepts : [] }) = "Empty Dept"
renderContactWhereDept (ContactWhere { labTeamDepts : dept }) =
maybe "No Dept (list)" identity (head dept)
renderContactWhereRole (ContactWhere { role: Nothing }) = "Empty Role"
......
......@@ -5,7 +5,9 @@ import Gargantext.Pages.Annuaire.User.Contacts.Types
import Data.List (List, zipWith, catMaybes, toUnfoldable)
import Data.Map (Map, empty, keys, values, lookup)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Array (head)
import Data.Semigroup ((<>))
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Set (toUnfoldable) as S
import Data.Tuple (Tuple(..), uncurry)
import Data.Unfoldable (class Unfoldable)
......@@ -63,30 +65,29 @@ getFirstName' = fromMaybe "no first name" <<< _.firstName <<< unwrap
getLastName obj = fromMaybe "no title" $ getLastName' <$> obj
getLastName' = fromMaybe "no last name" <<< _.lastName <<< unwrap
getRole obj = joinWith ", " $ getRole' <$> (fromMaybe [] obj)
getRole obj = joinWith ", " $ getRole' <$> obj
getRole' = fromMaybe "no role" <<< _.role <<< unwrap
-- getTouch :: Maybe (Array ContactWhere) -> Array ContactTouch
-- getTouch obj = (_.touch <<< unwrap) <$>
-- where
-- ary = fromMaybe [] obj
getTouch :: Array ContactWhere -> Maybe ContactTouch
getTouch = maybe Nothing (\(ContactWhere {touch:x}) -> x) <<< head
-- getPhone :: Maybe (Array ContactWhere) -> String
-- getPhone obj = fromMaybe "" $ getPhone' <$> (getTouch obj)
getPhone :: Array ContactWhere -> String
getPhone obj = fromMaybe "" $ getPhone' <$> (getTouch obj)
getPhone' :: ContactTouch -> String
getPhone' = fromMaybe "no phone" <<< _.phone <<< unwrap
-- getPhone' :: ContactTouch -> String
-- getPhone' = fromMaybe "no phone" <<< _.phone <<< unwrap
-- getMail obj = fromMaybe "" $ getMail' <$> (getTouch obj)
-- getMail' = fromMaybe "no mail" <<< _.mail <<< unwrap
getMail :: Array ContactWhere -> String
getMail obj = fromMaybe "" $ getMail' <$> (getTouch obj)
getMail' :: ContactTouch -> String
getMail' = fromMaybe "no mail" <<< _.mail <<< unwrap
contactInfos :: HyperdataContact -> Array ReactElement
contactInfos (HyperdataContact {who:who, ou:ou}) =
[ ul [className "list-group"] (infoRender (Tuple "Last Name" $ getLastName who))
, ul [className "list-group"] (infoRender (Tuple "First name" $ getFirstName who))
, ul [className "list-group"] (infoRender (Tuple "Role" $ getRole ou))
-- , ul [className "list-group"] (infoRender (Tuple "Phone" $ getPhone "Phone" ou))
-- , ul [className "list-group"] (infoRender (Tuple "Mail" $ getMail "Mail"))
[ ul [className "list-group"] (infoRender (Tuple "Last Name" $ " " <> getLastName who))
, ul [className "list-group"] (infoRender (Tuple "First name" $ " " <> getFirstName who))
, ul [className "list-group"] (infoRender (Tuple "Role" $ " " <> getRole ou ))
, ul [className "list-group"] (infoRender (Tuple "Phone" $ " " <> getPhone ou ))
, ul [className "list-group"] (infoRender (Tuple "Mail" $ " " <> getMail ou ))
]
......
......@@ -5,7 +5,7 @@ import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??))
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Map (Map(..))
import React (ReactElement)
......@@ -31,8 +31,8 @@ newtype ContactWho =
ContactWho { idWho :: Maybe String
, firstName :: Maybe String
, lastName :: Maybe String
, keywords :: Maybe (Array String)
, freetags :: Maybe (Array String)
, keywords :: (Array String)
, freetags :: (Array String)
}
derive instance newtypeContactWho :: Newtype ContactWho _
......@@ -46,11 +46,15 @@ instance decodeContactWho :: DecodeJson ContactWho
lastName <- obj .?? "lastName"
keywords <- obj .?? "keywords"
freetags <- obj .?? "freetags"
pure $ ContactWho {idWho, firstName, lastName, keywords, freetags}
let k = fromMaybe [] keywords
let f = fromMaybe [] freetags
pure $ ContactWho {idWho, firstName, lastName, keywords:k, freetags:f}
newtype ContactWhere =
ContactWhere { organization :: Maybe (Array String)
, labTeamDepts :: Maybe (Array String)
ContactWhere { organization :: (Array String)
, labTeamDepts :: (Array String)
, role :: Maybe String
......@@ -78,7 +82,11 @@ instance decodeContactWhere :: DecodeJson ContactWhere
touch <- obj .?? "touch"
entry <- obj .?? "entry"
exit <- obj .?? "exit"
pure $ ContactWhere {organization, labTeamDepts, role, office, country, city, touch, entry, exit}
let o = fromMaybe [] organization
let l = fromMaybe [] labTeamDepts
pure $ ContactWhere {organization:o, labTeamDepts:l, role, office, country, city, touch, entry, exit}
newtype ContactTouch =
ContactTouch { mail :: Maybe String
......@@ -100,7 +108,7 @@ instance decodeContactTouch :: DecodeJson ContactTouch
newtype HyperdataContact =
HyperdataContact { bdd :: Maybe String
, who :: Maybe ContactWho
, ou :: Maybe (Array ContactWhere)
, ou :: (Array ContactWhere)
, title :: Maybe String
, source :: Maybe String
, lastValidation :: Maybe String
......@@ -122,7 +130,9 @@ instance decodeHyperdataContact :: DecodeJson HyperdataContact
uniqId <- obj .?? "uniqId"
uniqIdBdd <- obj .?? "uniqIdBdd"
pure $ HyperdataContact {bdd, who, ou, title, source, lastValidation, uniqId, uniqIdBdd}
let ou' = fromMaybe [] ou
pure $ HyperdataContact {bdd, who, ou:ou', title, source, lastValidation, uniqId, uniqIdBdd}
newtype HyperData c s =
......
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