use editSelectedGoalie for all goalie editing
This commit is contained in:
parent
52f1e34d49
commit
59026de077
|
@ -39,13 +39,12 @@ module Mtlstats.Prompt.EditGoalie
|
||||||
, editGoalieLtTiesPrompt
|
, editGoalieLtTiesPrompt
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Extra (whenJustM)
|
import Control.Monad.Trans.State (modify)
|
||||||
import Control.Monad.Trans.State (gets, modify)
|
import Lens.Micro ((.~))
|
||||||
import Lens.Micro ((^.), (.~), (%~))
|
|
||||||
|
|
||||||
|
import Mtlstats.Actions
|
||||||
import Mtlstats.Prompt
|
import Mtlstats.Prompt
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
import Mtlstats.Util
|
|
||||||
|
|
||||||
-- | Prompt to select a 'Goalie' for editing
|
-- | Prompt to select a 'Goalie' for editing
|
||||||
goalieToEditPrompt :: Prompt
|
goalieToEditPrompt :: Prompt
|
||||||
|
@ -62,7 +61,7 @@ editGoalieNamePrompt :: Prompt
|
||||||
editGoalieNamePrompt = namePrompt "Goalie name: " $ \name ->
|
editGoalieNamePrompt = namePrompt "Goalie name: " $ \name ->
|
||||||
if null name
|
if null name
|
||||||
then goto EGMenu
|
then goto EGMenu
|
||||||
else editGoalie EGMenu $ gName .~ name
|
else doEdit EGMenu $ gName .~ name
|
||||||
|
|
||||||
-- | Prompt to edit a goalie's YTD games played
|
-- | Prompt to edit a goalie's YTD games played
|
||||||
editGoalieYtdGamesPrompt
|
editGoalieYtdGamesPrompt
|
||||||
|
@ -213,12 +212,11 @@ editNum
|
||||||
-> Prompt
|
-> Prompt
|
||||||
editNum pStr mode f = numPromptWithFallback pStr
|
editNum pStr mode f = numPromptWithFallback pStr
|
||||||
(goto mode)
|
(goto mode)
|
||||||
(editGoalie mode . f)
|
(doEdit mode . f)
|
||||||
|
|
||||||
editGoalie :: EditGoalieMode -> (Goalie -> Goalie) -> Action ()
|
doEdit :: EditGoalieMode -> (Goalie -> Goalie) -> Action ()
|
||||||
editGoalie mode f =
|
doEdit mode f = do
|
||||||
whenJustM (gets (^.progMode.editGoalieStateL.egsSelectedGoalie)) $ \gid -> do
|
modify $ editSelectedGoalie f
|
||||||
modify $ database.dbGoalies %~ modifyNth gid f
|
|
||||||
goto mode
|
goto mode
|
||||||
|
|
||||||
goto :: EditGoalieMode -> Action ()
|
goto :: EditGoalieMode -> Action ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user