comparison demo/more/bulkEdit.ur @ 1004:a87495bcaeec

Start of user management
author Adam Chlipala <adamc@hcoop.net>
date Tue, 20 Oct 2009 12:48:53 -0400
parents
children c6e948ec79e9
comparison
equal deleted inserted replaced
1003:61c30f0742d7 1004:a87495bcaeec
1 open Meta
2
3 functor Make(M : sig
4 con keyName :: Name
5 con keyType :: Type
6 val showKey : show keyType
7
8 con visible :: {(Type * Type)}
9 constraint [keyName] ~ visible
10 val folder : folder visible
11 val visible : $(map Meta.meta visible)
12
13 con invisible :: {Type}
14 constraint [keyName] ~ invisible
15 constraint visible ~ invisible
16
17 val title : string
18 val isAllowed : transaction bool
19 table t : ([keyName = keyType] ++ map fst visible ++ invisible)
20 end) = struct
21
22 open M
23
24 fun main () =
25 items <- queryX (SELECT t.{keyName}, t.{{map fst visible}} FROM t)
26 (fn r => <xml><entry><tr>
27 <hidden{keyName} value={show r.T.keyName}/>
28 {useMore (foldR2 [meta] [fst] [fn cols :: {(Type * Type)} =>
29 xml [Body, Form, Tr] [] (map snd cols)]
30 (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest]
31 (m : meta p) v (acc : xml [Body, Form, Tr] [] (map snd rest)) =>
32 <xml>
33 <td>{m.WidgetPopulated [nm] v}</td>
34 {useMore acc}
35 </xml>)
36 <xml/>
37 [_] folder visible (r.T -- keyName))}
38 </tr></entry></xml>);
39
40 return <xml><body>
41 <h1>{[title]}</h1>
42
43 <form><table>
44 <tr>{foldRX [meta] [_]
45 (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] m =>
46 <xml><th>{[m.Nam]}</th></xml>) [_] folder visible}</tr>
47 <subforms{#Users}>{items}</subforms>
48 </table></form>
49 </body></xml>
50
51 end