summaryrefslogtreecommitdiff
path: root/tests/crud.ur
diff options
context:
space:
mode:
Diffstat (limited to 'tests/crud.ur')
-rw-r--r--tests/crud.ur22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/crud.ur b/tests/crud.ur
index b22cb157..02405f78 100644
--- a/tests/crud.ur
+++ b/tests/crud.ur
@@ -8,6 +8,28 @@ con colMeta = fn t_formT :: (Type * Type) => {
}
con colsMeta = fn cols :: {(Type * Type)} => $(Top.mapT2T colMeta cols)
+fun default (t ::: Type) (sh : show t) (rd : read t) (inj : sql_injectable t)
+ name : colMeta (t, string) =
+ {Nam = name,
+ Show = txt _,
+ Widget = fn nm :: Name => <xml><textbox{nm}/></xml>,
+ WidgetPopulated = fn (nm :: Name) n =>
+ <xml><textbox{nm} value={show _ n}/></xml>,
+ Parse = readError _,
+ Inject = _}
+
+val int = default _ _ _
+val float = default _ _ _
+val string = default _ _ _
+
+fun bool name = {Nam = name,
+ Show = txt _,
+ Widget = fn nm :: Name => <xml><checkbox{nm}/></xml>,
+ WidgetPopulated = fn (nm :: Name) b =>
+ <xml><checkbox{nm} checked={b}/></xml>,
+ Parse = fn x => x,
+ Inject = _}
+
functor Make(M : sig
con cols :: {(Type * Type)}
constraint [Id] ~ cols