re-org Annuaire.User.Users.* modules

parent 6d590bf1
...@@ -15,7 +15,7 @@ import Thermite (Render, Spec ...@@ -15,7 +15,7 @@ import Thermite (Render, Spec
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), TabType(..), End(..)) import Gargantext.Config (toUrl, NodeType(..), TabType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..)) import Gargantext.Pages.Annuaire.User.Users.Types (User(..), HyperData(..))
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.?))
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
type State = { info :: Maybe AnnuaireInfo type State = { info :: Maybe AnnuaireInfo
......
module Gargantext.Pages.Annuaire.User.Users.Specs module Gargantext.Pages.Annuaire.User.Users.Specs
(module Gargantext.Pages.Annuaire.User.Users.Specs.Renders, (module Gargantext.Pages.Annuaire.User.Users.Specs.Renders,
brevetSpec,
projectSpec,
facets,
layoutUser) layoutUser)
where where
import Thermite (PerformAction, Spec, simpleSpec) import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Thermite (Render, PerformAction, Spec, focus, noState, defaultPerformAction, simpleSpec)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Pages.Annuaire.User.Users.Types (Action(..), State) import Gargantext.Components.Tab as Tab
import Gargantext.Pages.Annuaire.User.Brevets as B
import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P
import Gargantext.Pages.Annuaire.User.Users.Types (Action(..), State, _tablens, _tabAction)
import Gargantext.Pages.Annuaire.User.Users.API (fetchUser) import Gargantext.Pages.Annuaire.User.Users.API (fetchUser)
import Gargantext.Pages.Annuaire.User.Users.Specs.Renders (render) import Gargantext.Pages.Annuaire.User.Users.Specs.Renders (render)
...@@ -16,3 +24,26 @@ layoutUser = simpleSpec performAction render ...@@ -16,3 +24,26 @@ layoutUser = simpleSpec performAction render
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
performAction (FetchUser userId) _ _ = fetchUser userId performAction (FetchUser userId) _ _ = fetchUser userId
performAction (TabA _) _ _ = pure unit performAction (TabA _) _ _ = pure unit
brevetSpec :: Spec State {} Action
brevetSpec = noState B.brevetsSpec
projets :: Spec {} {} Void
projets = simpleSpec defaultPerformAction render
where
render :: Render {} {} Void
render dispatch _ state _ =
[]
projectSpec :: Spec State {} Action
projectSpec = noState projets
publicationSpec :: Spec State {} Action
publicationSpec = noState P.publicationSpec
facets :: Spec State {} Action
facets = Tab.tabs _tablens _tabAction $ fromFoldable
[ Tuple "Publications (12)" publicationSpec
, Tuple "Brevets (2)" brevetSpec
, Tuple "Projets IMT (5)" projectSpec
]
module Gargantext.Pages.Annuaire.User.Users.Types module Gargantext.Pages.Annuaire.User.Users.Types where
(module Gargantext.Pages.Annuaire.User.Users.Types.Types,
module Gargantext.Pages.Annuaire.User.Users.Types.Lens,
module Gargantext.Pages.Annuaire.User.Users.Types.States,
brevetSpec,
projectSpec,
facets
)
where
import Prelude import Prelude
import Gargantext.Pages.Annuaire.User.Users.Types.Lens import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Gargantext.Pages.Annuaire.User.Users.Types.Types import Data.Either (Either(..))
import Gargantext.Pages.Annuaire.User.Users.Types.States import Data.Lens (Lens', Prism', lens, prism)
import Gargantext.Pages.Annuaire.User.Brevets as B import Data.Maybe (Maybe(..))
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..)) import Gargantext.Components.Tab as Tab
import Gargantext.Components.Tab (tabs) import Gargantext.Utils.DecodeMaybe ((.?|))
import Thermite (Render, Spec, focus, noState, defaultPerformAction, simpleSpec)
newtype User =
brevetSpec :: Spec State {} Action User { id :: Int
brevetSpec = noState B.brevetsSpec , typename :: Maybe Int
, userId :: Int
projets :: Spec {} {} Void , parentId :: Int
projets = simpleSpec defaultPerformAction render , name :: String
where , date :: Maybe String
render :: Render {} {} Void , hyperdata :: HyperData
render dispatch _ state _ = }
[]
newtype HyperData =
projectSpec :: Spec State {} Action HyperData
projectSpec = noState projets { bureau :: Maybe String
, atel :: Maybe String
facets :: Spec State {} Action , fax :: Maybe String
facets = tabs _tablens _tabAction $ fromFoldable , aprecision :: Maybe String
[ Tuple "Publications (12)" publicationSpec , service :: Maybe String
, Tuple "Brevets (2)" brevetSpec , service2 :: Maybe String
, Tuple "Projets IMT (5)" projectSpec , groupe :: Maybe String
] , lieu :: Maybe String
, pservice :: Maybe String
, date_modification :: Maybe String
, fonction :: Maybe String
, pfonction :: Maybe String
, url :: Maybe String
, prenom :: Maybe String
, nom :: Maybe String
, idutilentite :: Maybe String
, afonction :: Maybe String
, grprech :: Maybe String
, entite :: Maybe String
, entite2 :: Maybe String
, mail :: Maybe String
}
instance decodeUserHyperData :: DecodeJson HyperData where
decodeJson json = do
obj <- decodeJson json
bureau <- obj .?| "bureau"
atel <- obj .?| "atel"
fax <- obj .?| "fax"
aprecision <- obj .?| "aprecision"
service <- obj .?| "service"
service2 <- obj .?| "service2"
groupe <- obj .?| "groupe"
lieu <- obj .?| "lieu"
pservice <- obj .?| "pservice"
date_modification <- obj .?| "date_modification"
fonction <- obj .?| "fonction"
pfonction <- obj .?| "pfonction"
url <- obj .?| "url"
prenom <- obj .?| "prenom"
nom <- obj .?| "nom"
idutilentite <- obj .?| "idutilentite"
afonction <- obj .?| "afonction"
grprech <- obj .?| "grprech"
entite <- obj .?| "entite"
entite2 <- obj .?| "entite2"
mail <- obj .?| "mail"
pure $ HyperData { bureau, atel, fax
, aprecision, service
, service2, groupe, lieu
, pservice, date_modification
, fonction, pfonction, url
, prenom, nom, idutilentite
, afonction, grprech, entite
, entite2, mail
}
instance decodeUser :: DecodeJson User where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
typename <- obj .?| "typename"
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
date <- obj .?| "date"
hyperdata <- obj .? "hyperdata"
pure $ User { id, typename, userId
, parentId, name, date
, hyperdata
}
data Action
= TabA Tab.Action
| FetchUser Int
type State =
{ activeTab :: Int
, user :: Maybe User
}
initialState :: State
initialState =
{ activeTab : 0
, user: Nothing
}
_user :: Lens' State (Maybe User)
_user = lens (\s -> s.user) (\s ss -> s{user = ss})
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabA \ action ->
case action of
TabA laction -> Right laction
_-> Left action
module Gargantext.Pages.Annuaire.User.Users.Types.Lens where
import Gargantext.Pages.Annuaire.User.Brevets as B
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (Maybe)
import Gargantext.Pages.Annuaire.User.Users.Types.States (Action(..), State)
import Gargantext.Pages.Annuaire.User.Users.Types.Types (User)
import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P
import Gargantext.Components.Tab as Tab
import Thermite (Spec, noState)
_user :: Lens' State (Maybe User)
_user = lens (\s -> s.user) (\s ss -> s{user = ss})
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabA \ action ->
case action of
TabA laction -> Right laction
_-> Left action
publicationSpec :: Spec State {} Action
publicationSpec = noState P.publicationSpec
module Gargantext.Pages.Annuaire.User.Users.Types.States where
import Data.Maybe (Maybe(..))
import Gargantext.Pages.Annuaire.User.Users.Types.Types (User)
import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P
import Gargantext.Components.Tab as Tab
data Action
= TabA Tab.Action
| FetchUser Int
type State =
{ activeTab :: Int
, user :: Maybe User
}
initialState :: State
initialState =
{ activeTab : 0
, user: Nothing
}
module Gargantext.Pages.Annuaire.User.Users.Types.Types where
import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Maybe (Maybe)
import Gargantext.Utils.DecodeMaybe ((.?|))
newtype User =
User { id :: Int
, typename :: Maybe Int
, userId :: Int
, parentId :: Int
, name :: String
, date :: Maybe String
, hyperdata :: HyperData
}
newtype HyperData =
HyperData
{ bureau :: Maybe String
, atel :: Maybe String
, fax :: Maybe String
, aprecision :: Maybe String
, service :: Maybe String
, service2 :: Maybe String
, groupe :: Maybe String
, lieu :: Maybe String
, pservice :: Maybe String
, date_modification :: Maybe String
, fonction :: Maybe String
, pfonction :: Maybe String
, url :: Maybe String
, prenom :: Maybe String
, nom :: Maybe String
, idutilentite :: Maybe String
, afonction :: Maybe String
, grprech :: Maybe String
, entite :: Maybe String
, entite2 :: Maybe String
, mail :: Maybe String
}
instance decodeUserHyperData :: DecodeJson HyperData where
decodeJson json = do
obj <- decodeJson json
bureau <- obj .?| "bureau"
atel <- obj .?| "atel"
fax <- obj .?| "fax"
aprecision <- obj .?| "aprecision"
service <- obj .?| "service"
service2 <- obj .?| "service2"
groupe <- obj .?| "groupe"
lieu <- obj .?| "lieu"
pservice <- obj .?| "pservice"
date_modification <- obj .?| "date_modification"
fonction <- obj .?| "fonction"
pfonction <- obj .?| "pfonction"
url <- obj .?| "url"
prenom <- obj .?| "prenom"
nom <- obj .?| "nom"
idutilentite <- obj .?| "idutilentite"
afonction <- obj .?| "afonction"
grprech <- obj .?| "grprech"
entite <- obj .?| "entite"
entite2 <- obj .?| "entite2"
mail <- obj .?| "mail"
pure $ HyperData { bureau, atel, fax
, aprecision, service
, service2, groupe, lieu
, pservice, date_modification
, fonction, pfonction, url
, prenom, nom, idutilentite
, afonction, grprech, entite
, entite2, mail
}
instance decodeUser :: DecodeJson User where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
typename <- obj .?| "typename"
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
date <- obj .?| "date"
hyperdata <- obj .? "hyperdata"
pure $ User { id, typename, userId
, parentId, name, date
, hyperdata
}
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