aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Dialog.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Dialog.elm')
-rw-r--r--src/client/elm/Dialog.elm30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/client/elm/Dialog.elm b/src/client/elm/Dialog.elm
index 0fb43db..4b5b4cd 100644
--- a/src/client/elm/Dialog.elm
+++ b/src/client/elm/Dialog.elm
@@ -8,7 +8,7 @@ module Dialog exposing
)
import Platform.Cmd exposing (Cmd)
-import Task
+import Task exposing (Task)
import Html exposing (..)
import Html.Attributes exposing (..)
@@ -25,7 +25,7 @@ type alias Config model msg =
{ title : String
, body : model -> Html msg
, confirm : String
- , confirmMsg : msg
+ , confirmMsg : model -> Result msg msg
, undo : String
}
@@ -39,12 +39,12 @@ init mapMsg =
type Msg model msg =
NoOp
- | ConfirmMsg msg
+ | ConfirmMsg (model -> Result msg msg)
| Open (Config model msg)
| Close
-update : Msg model msg -> Model model msg -> (Model model msg, Cmd msg)
-update msg model =
+update : Msg model msg -> model -> Model model msg -> (Model model msg, Cmd msg)
+update msg baseModel model =
case msg of
NoOp ->
( model
@@ -52,10 +52,15 @@ update msg model =
)
ConfirmMsg confirmMsg ->
- ( { model | config = Nothing }
- , Task.succeed msg
- |> Task.perform (always confirmMsg) (always confirmMsg)
- )
+ case confirmMsg baseModel of
+ Ok msg ->
+ ( { model | config = Nothing }
+ , Task.perform (always msg) (always msg) (Task.succeed NoOp)
+ )
+ Err msg ->
+ ( model
+ , Task.perform (always msg) (always msg) (Task.succeed NoOp)
+ )
Open config ->
( { model | config = Just config }
@@ -90,7 +95,7 @@ curtain mapMsg isVisible =
div
[ class "curtain"
, style
- [ ("position", "absolute")
+ [ ("position", "fixed")
, ("top", "0")
, ("left", "0")
, ("width", "100%")
@@ -109,11 +114,10 @@ dialog model mapMsg { title, body, confirm, confirmMsg, undo } =
div
[ class "content"
, style
- [ ("min-width", "300px")
- , ("position", "absolute")
+ [ ("position", "fixed")
, ("top", "25%")
, ("left", "50%")
- , ("transform", "translate(-50%, -50%)")
+ , ("transform", "translate(-50%, -25%)")
, ("z-index", "1000")
, ("background-color", "white")
, ("padding", "20px")