Skip to content

Commit d231409

Browse files
committed
full reset button
1 parent bdbb0a9 commit d231409

File tree

2 files changed

+36
-14
lines changed
  • ghcjs
    • delivery-calculator/src/App/Widgets
    • miso-functora/src/Functora/Miso/Widgets

2 files changed

+36
-14
lines changed

ghcjs/delivery-calculator/src/App/Widgets/Menu.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ menu st =
208208
}
209209
]
210210
)
211+
<> [ Field.labeled
212+
"Full reset"
213+
mempty
214+
[ button_
215+
[type_ "reset", fullResetOnClick]
216+
[icon Icon.IconDelete, text " Full reset"]
217+
]
218+
]
211219
}
212220
where
213221
shareOnClick :: Attribute Action
@@ -219,6 +227,12 @@ menu st =
219227
. from @String @Unicode
220228
. either impureThrow URI.renderStr
221229
$ stUri st
230+
fullResetOnClick :: Attribute Action
231+
fullResetOnClick =
232+
onClick . PushUpdate . Instant . ImpureUpdate $ do
233+
doc <- liftIO newSt
234+
Jsm.popupText @Unicode "Full reset success!"
235+
pure $ (#modelMenu .~ Closed) . (#modelState .~ doc)
222236

223237
qrButton :: Model -> View Action
224238
qrButton st =

ghcjs/miso-functora/src/Functora/Miso/Widgets/Field.hs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Functora.Miso.Widgets.Field
88
ModalWidget' (..),
99
truncateUnicode,
1010
expandDynamicField,
11+
labeled,
1112
field,
1213
ratioField,
1314
textField,
@@ -134,6 +135,24 @@ data ModalWidget' model where
134135
ATraversal' model (Field a Unique) ->
135136
ModalWidget' model
136137

138+
labeled :: Unicode -> [Attribute action] -> [View action] -> View action
139+
labeled label attrs =
140+
label_
141+
( style_
142+
[ ("display", "flex"),
143+
("flex-wrap", "wrap"),
144+
("flex-direction", "row"),
145+
("align-items", "center")
146+
]
147+
: attrs
148+
)
149+
. ( ( span_
150+
[style_ [("width", "100%")]]
151+
[text label]
152+
)
153+
:
154+
)
155+
137156
field ::
138157
Full model action t Unique ->
139158
Opts model action ->
@@ -151,22 +170,11 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
151170
Just x ->
152171
singleton
153172
. keyed ("field-" <> uidTxt)
154-
. label_
155-
[ style_
156-
[ ("display", "flex"),
157-
("flex-wrap", "wrap"),
158-
("flex-direction", "row"),
159-
("align-items", "center")
160-
],
161-
onBlur onBlurAction,
173+
. labeled
174+
x
175+
[ onBlur onBlurAction,
162176
onFocus onFocusAction
163177
]
164-
. ( ( span_
165-
[style_ [("width", "100%")]]
166-
[text x]
167-
)
168-
:
169-
)
170178
)
171179
( [ input_
172180
$ ( catMaybes

0 commit comments

Comments
 (0)