puts group chest almost back up
This commit is contained in:
65
src/Page.elm
65
src/Page.elm
@@ -1,4 +1,4 @@
|
||||
module Page exposing (Page(..), PageMsg, gotoHome, gotoShop, initHome, update, view)
|
||||
module Page exposing (Page(..), PageMsg, gotoGroupChest, gotoHome, gotoShop, initHome, update, view)
|
||||
|
||||
import Api
|
||||
import Api.Player
|
||||
@@ -101,11 +101,11 @@ view page =
|
||||
navLink "fas fa-gem"
|
||||
in
|
||||
[ navLink "fas fa-store-alt" "Marchand" "/marchand"
|
||||
, if player.id == 0 then
|
||||
linkWithGem "Nouveau loot" "/nouveau-tresor"
|
||||
, if player.id /= 0 then
|
||||
linkWithGem "Coffre de groupe" "/coffre"
|
||||
|
||||
else
|
||||
linkWithGem "Coffre de groupe" "/coffre"
|
||||
text ""
|
||||
]
|
||||
|
||||
Session.Admin ->
|
||||
@@ -118,6 +118,20 @@ view page =
|
||||
, { title = navbarTitle, links = navbarLinks }
|
||||
, [ div [ class "container" ] <|
|
||||
viewSessionBar (maybeSession page) [ controls ]
|
||||
:: (case Maybe.map Session.notification (maybeSession page) of
|
||||
Just (Just notify) ->
|
||||
div [ class "notification is-success" ] [ text notify ]
|
||||
|
||||
_ ->
|
||||
text ""
|
||||
)
|
||||
:: (case Maybe.map Session.error (maybeSession page) of
|
||||
Just (Just notify) ->
|
||||
div [ class "notification is-danger" ] [ text notify ]
|
||||
|
||||
_ ->
|
||||
text ""
|
||||
)
|
||||
:: content
|
||||
]
|
||||
)
|
||||
@@ -131,10 +145,6 @@ viewSessionBar session controls =
|
||||
[ text "" ]
|
||||
|
||||
Just (Session.Player player wealth _) ->
|
||||
let
|
||||
_ =
|
||||
Debug.log "viewSessionBar wealth" player.wealth
|
||||
in
|
||||
Wealth.view player.wealth wealth
|
||||
++ (if player.debt > 0 then
|
||||
[ div [ class "level-item" ]
|
||||
@@ -214,16 +224,12 @@ map func page =
|
||||
|
||||
update msg page =
|
||||
case ( msg, page, maybeSession page ) of
|
||||
( GotGroupChestMsg subMsg, GroupChest chest, _ ) ->
|
||||
GroupChest.update subMsg chest
|
||||
|> updatePage GroupChest GotGroupChestMsg
|
||||
|
||||
( GotGroupChestMsg _, _, _ ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
-- Dashboard page
|
||||
-- Capture API messages
|
||||
( GotDashboardMsg (Dashboard.Api apiMsg), Dashboard home, _ ) ->
|
||||
update (ApiMsg apiMsg) page
|
||||
|
||||
-- Relay others
|
||||
( GotDashboardMsg subMsg, Dashboard home, _ ) ->
|
||||
Dashboard.update subMsg home
|
||||
|> updatePage Dashboard GotDashboardMsg
|
||||
@@ -231,6 +237,18 @@ update msg page =
|
||||
( GotDashboardMsg _, _, _ ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
-- Group chest
|
||||
( GotGroupChestMsg (GroupChest.Api apiMsg), GroupChest _, _ ) ->
|
||||
update (ApiMsg apiMsg) page
|
||||
|
||||
( GotGroupChestMsg subMsg, GroupChest chest, _ ) ->
|
||||
GroupChest.update subMsg chest
|
||||
|> updatePage GroupChest GotGroupChestMsg
|
||||
|
||||
( GotGroupChestMsg _, _, _ ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
-- Shop page
|
||||
( GotShopMsg (Shop.Api apiMsg), Shop shop, _ ) ->
|
||||
update (ApiMsg apiMsg) page
|
||||
|
||||
@@ -241,6 +259,7 @@ update msg page =
|
||||
( GotShopMsg _, _, _ ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
-- Wealth viewer/editor
|
||||
( Wealth wealthMsg, _, Just session ) ->
|
||||
let
|
||||
wealthModel =
|
||||
@@ -271,6 +290,7 @@ update msg page =
|
||||
( Wealth wealthMsg, _, Nothing ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
-- Handle API messages
|
||||
( ApiMsg (Api.GotActionResult response), _, Just session ) ->
|
||||
let
|
||||
_ =
|
||||
@@ -282,17 +302,12 @@ update msg page =
|
||||
updates =
|
||||
Maybe.withDefault [] result.updates
|
||||
|
||||
notification =
|
||||
result.notification
|
||||
|
||||
errors =
|
||||
Maybe.withDefault "" result.errors
|
||||
|
||||
newUser =
|
||||
Debug.log "newUser" <|
|
||||
List.foldl applyUpdate (Session.user session) updates
|
||||
updatedUser =
|
||||
List.foldl applyUpdate (Session.user session) updates
|
||||
in
|
||||
( map (Session.updateUser newUser) page
|
||||
( page
|
||||
|> map (Session.updateUser updatedUser)
|
||||
|> map (Session.updateNotifications ( result.notification, result.errors ))
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user