1 {-# OPTIONS -fcontext-stack=30 -fglasgow-exts -fth -fallow-undecidable-instances #-}
9 import HAppS.State.Transaction
10 import HAppS.Server.SimpleHTTP
14 $( deriveAll [''Ord,''Eq,''Read,''Show,''Default]
16 newtype FormData = FormData String
19 plainEdit :: ( UpdateEvent ue (),
21 QueryEvent qe a) => qe -> (a -> ue) -> [ServerPart]
23 plainEdit getter setter = [
24 method GET $ query getter >>= ok . toDataForm "." "POST" . pshow,
25 withData $ \(FormData fdat) -> [ method POST $ update (setter (read fdat)) >> redirect "." ]
29 -- Just a copy from HAppS/Data/Pairs.hs, with textfield instead of input
30 toDataForm action method fdat
32 Attr "xmlns" "http://www.w3.org/1999/xhtml" :
33 Attr "action" action :
34 Attr "method" method :
38 Attr "name" "formData"
43 Elem "input" [Attr "type" "submit"] :