many styling tweaks, adds sourceName field

This commit is contained in:
2019-12-07 16:28:40 +01:00
parent ff375b6052
commit 903fdd816d
11 changed files with 294 additions and 150 deletions

View File

@@ -91,7 +91,7 @@ view page =
case Session.user session of
Session.Player data ->
( data.player.name
, [ navLink "fas fa-home" Route.Home page
, [ navLink "fas fa-dungeon" Route.Home page
, navLink "fas fa-store-alt" Route.Merchant page
, if data.player.id /= 0 then
navLink "fas fa-gem" Route.GroupChest page
@@ -103,7 +103,7 @@ view page =
Session.Admin _ ->
( "Administration"
, [ navLink "fas fa-home" Route.Home page
, [ navLink "fas fa-users" Route.Home page
, navLink "fas fa-store-alt" Route.Merchant page
]
)
@@ -115,9 +115,9 @@ view page =
in
( pageTitle
, { title = navbarTitle, links = navbarLinks }
, [ div [ class "container" ] <|
, [ div [ class "container box is-paddingless" ] <|
[ viewSessionBar (maybeSession page) pageTitle [ controls ]
, div [ class "section" ]
, section [ class "section" ]
content
]
]
@@ -139,7 +139,10 @@ viewNotification kind content =
NotifyError ->
"is-danger"
in
div [ class ("level-item notification " ++ className) ]
div
[ class ("level-item notification " ++ className)
, style "margin-left" "1.5rem"
]
[ text content
, a [ class "delete", onClick <| CloseNotification kind ] []
]
@@ -193,7 +196,7 @@ viewSessionBar session pageTitle pageControls =
p [ class "title" ] [ text pageTitle ]
in
section [ class "hero is-dark is-bold" ]
[ div [ class "hero-body" ]
[ div [ class "hero-body", style "padding" "3rem 1.5rem 1.5rem 1.5rem" ]
[ renderLevel notifications user
, renderLevel [ title ] pageControls
]
@@ -201,7 +204,7 @@ viewSessionBar session pageTitle pageControls =
renderLevel left right =
div [ class "level container" ]
div [ class "level" ]
[ div [ class "level-left" ] left
, div [ class "level-right" ] right
]
@@ -265,30 +268,6 @@ type PageMsg
-- Maps the page session to a function, if any
map func page =
case maybeSession page of
Nothing ->
page
Just session ->
case page of
Home model ->
Home <| Home.updateSession model (func session)
GroupChest model ->
GroupChest { model | session = func session }
Shop model ->
Shop { model | session = func session }
_ ->
page
-- Restores the page after an action has be resolved (either success or error)
@@ -349,7 +328,7 @@ update msg page =
-- Notifications
--
( CloseNotification kind, _, _ ) ->
( CloseNotification kind, _, Just session ) ->
( map
(case kind of
NotifySuccess ->
@@ -362,6 +341,9 @@ update msg page =
, Cmd.none
)
( CloseNotification _, _, _ ) ->
( page, Cmd.none )
-- Wealth viewer/editor
( Wealth wealthMsg, _, Just session ) ->
let
@@ -421,15 +403,15 @@ update msg page =
Cmd.none
)
-- |> setNotification notification
-- |> setError errors
-- |> update (ModeSwitched View)
Err r ->
Err error ->
let
_ =
Debug.log "ERR: ActionResult:" r
Debug.log "ApiError" error
in
( page, Cmd.none )
( page
|> map (Session.setError (Just "Oups! Cela n'a pas fonctionné"))
, Cmd.none
)
( ApiMsg apiMsg, _, Nothing ) ->
let
@@ -445,15 +427,32 @@ updatePage toPage toMsg ( subModel, subMsg ) =
)
-- Maps the page session to a function, if any
map func page =
case maybeSession page of
Nothing ->
page
Just session ->
case page of
Home model ->
Home <| Home.updateSession model (func session)
GroupChest model ->
GroupChest { model | session = func session }
Shop model ->
Shop { model | session = func session }
_ ->
page
applyUpdate : Api.Update -> Session.User -> Session.User
applyUpdate u user =
let
_ =
Debug.log "applyUpdate" u
_ =
Debug.log "on" user
in
{- Note: DbUpdates always refer to the active player -}
case user of
Session.Player data ->