Mercurial > urweb
diff tests/crud.ur @ 362:24a31b35e08f
Reusable column handlers for Crud
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 14 Oct 2008 17:18:59 -0400 |
parents | 260b680a6a04 |
children | 28d3d7210687 |
line wrap: on
line diff
--- a/tests/crud.ur Tue Oct 14 16:41:48 2008 -0400 +++ b/tests/crud.ur Tue Oct 14 17:18:59 2008 -0400 @@ -8,6 +8,28 @@ } 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