@@ -8,6 +8,7 @@ module UI.Modal exposing
8
8
, modal
9
9
, modal_
10
10
, view
11
+ , withAccept
11
12
, withActions
12
13
, withActionsIf
13
14
, withAttributes
@@ -35,6 +36,7 @@ type Content msg
35
36
type alias Modal msg =
36
37
{ id : String
37
38
, closeMsg : Maybe msg
39
+ , acceptMsg : Maybe msg
38
40
, attributes : List ( Attribute msg)
39
41
, header : Maybe ( Html msg)
40
42
, footer :
@@ -59,6 +61,7 @@ modal_ : String -> Content msg -> Modal msg
59
61
modal_ id content_ =
60
62
{ id = id
61
63
, closeMsg = Nothing
64
+ , acceptMsg = Nothing
62
65
, attributes = []
63
66
, header = Nothing
64
67
, footer = { leftSide = [], actions = [] }
@@ -109,6 +112,7 @@ map : (a -> b) -> Modal a -> Modal b
109
112
map f m =
110
113
{ id = m. id
111
114
, closeMsg = Maybe . map f m. closeMsg
115
+ , acceptMsg = Maybe . map f m. acceptMsg
112
116
, attributes = List . map ( Attributes . map f) m. attributes
113
117
, header = Maybe . map ( Html . map f) m. header
114
118
, footer =
@@ -129,6 +133,11 @@ withClose closeMsg modal__ =
129
133
{ modal__ | closeMsg = Just closeMsg }
130
134
131
135
136
+ withAccept : msg -> Modal msg -> Modal msg
137
+ withAccept acceptMsg modal__ =
138
+ { modal__ | acceptMsg = Just acceptMsg }
139
+
140
+
132
141
withHeader : String -> Modal msg -> Modal msg
133
142
withHeader title modal__ =
134
143
{ modal__ | header = Just ( text title) }
@@ -231,6 +240,7 @@ view modal__ =
231
240
in
232
241
view_
233
242
modal__. closeMsg
243
+ modal__. acceptMsg
234
244
( id modal__. id
235
245
:: classList [ ( " modal_dim-overlay" , modal__. dimOverlay ) ]
236
246
:: modal__. attributes
@@ -242,8 +252,8 @@ view modal__ =
242
252
-- INTERNALS
243
253
244
254
245
- view_ : Maybe msg -> List (Attribute msg ) -> List (Html msg ) -> Html msg
246
- view_ closeMsg attrs content_ =
255
+ view_ : Maybe msg -> Maybe msg -> List (Attribute msg ) -> List (Html msg ) -> Html msg
256
+ view_ closeMsg acceptMsg attrs content_ =
247
257
let
248
258
( modalContent, onEsc ) =
249
259
case closeMsg of
@@ -264,7 +274,7 @@ view_ closeMsg attrs content_ =
264
274
, Nothing
265
275
)
266
276
in
267
- modalOverlay onEsc modalContent
277
+ modalOverlay onEsc acceptMsg modalContent
268
278
269
279
270
280
overlayId : String
0 commit comments