blob: 0226c3dddb3815c4e4404259b4114d6df9524b13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
open Meta
functor Make(M : sig
con keyName :: Name
con keyType :: Type
val showKey : show keyType
val readKey : read keyType
val injKey : sql_injectable keyType
con visible :: {(Type * Type)}
constraint [keyName] ~ visible
val folder : folder visible
val visible : $(map Meta.meta visible)
con invisible :: {Type}
constraint [keyName] ~ invisible
constraint visible ~ invisible
val title : string
val isAllowed : transaction bool
table t : ([keyName = keyType] ++ map fst visible ++ invisible)
end) = struct
open M
fun main () =
items <- queryX (SELECT t.{keyName}, t.{{map fst visible}} FROM t)
(fn r => <xml><entry><tr>
<hidden{keyName} value={show r.T.keyName}/>
{useMore (allPopulatedTr visible (r.T -- keyName) folder)}
</tr></entry></xml>);
return <xml><body>
<h1>{[title]}</h1>
<form><table>
<tr>{foldRX [meta] [_]
(fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] m =>
<xml><th>{[m.Nam]}</th></xml>) [_] folder visible}</tr>
<subforms{#Users}>{items}</subforms>
<tr> <td><submit value="Save" action={save}/></td> </tr>
</table></form>
</body></xml>
and save r =
List.app (fn user => dml (update [map fst visible] !
(ensql visible (user -- keyName) folder)
t
(WHERE t.{keyName} = {[readError user.keyName]}))) r.Users;
main ()
end
|