comparison demo/more/bulkEdit.ur @ 1008:1911e84df461

Move stuff from bulkEdit to meta
author Adam Chlipala <adamc@hcoop.net>
date Thu, 22 Oct 2009 11:51:31 -0400
parents c6e948ec79e9
children
comparison
equal deleted inserted replaced
1007:d3af9e54c828 1008:1911e84df461
21 table t : ([keyName = keyType] ++ map fst visible ++ invisible) 21 table t : ([keyName = keyType] ++ map fst visible ++ invisible)
22 end) = struct 22 end) = struct
23 23
24 open M 24 open M
25 25
26 fun ensql [avail] (r : $(map snd visible)) : $(map (sql_exp avail [] []) (map fst visible)) =
27 map2 [meta] [snd] [fn ts :: (Type * Type) => sql_exp avail [] [] ts.1]
28 (fn [ts] meta v => @sql_inject meta.Inject (meta.Parse v))
29 [_] folder visible r
30
31 fun main () = 26 fun main () =
32 items <- queryX (SELECT t.{keyName}, t.{{map fst visible}} FROM t) 27 items <- queryX (SELECT t.{keyName}, t.{{map fst visible}} FROM t)
33 (fn r => <xml><entry><tr> 28 (fn r => <xml><entry><tr>
34 <hidden{keyName} value={show r.T.keyName}/> 29 <hidden{keyName} value={show r.T.keyName}/>
35 {useMore (foldR2 [meta] [fst] [fn cols :: {(Type * Type)} => 30 {useMore (allPopulatedTr visible (r.T -- keyName) folder)}
36 xml [Body, Form, Tr] [] (map snd cols)]
37 (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest]
38 (m : meta p) v (acc : xml [Body, Form, Tr] [] (map snd rest)) =>
39 <xml>
40 <td>{m.WidgetPopulated [nm] v}</td>
41 {useMore acc}
42 </xml>)
43 <xml/>
44 [_] folder visible (r.T -- keyName))}
45 </tr></entry></xml>); 31 </tr></entry></xml>);
46 32
47 return <xml><body> 33 return <xml><body>
48 <h1>{[title]}</h1> 34 <h1>{[title]}</h1>
49 35
56 </table></form> 42 </table></form>
57 </body></xml> 43 </body></xml>
58 44
59 and save r = 45 and save r =
60 List.app (fn user => dml (update [map fst visible] ! 46 List.app (fn user => dml (update [map fst visible] !
61 (ensql (user -- keyName)) 47 (ensql visible (user -- keyName) folder)
62 t 48 t
63 (WHERE t.{keyName} = {[readError user.keyName]}))) r.Users; 49 (WHERE t.{keyName} = {[readError user.keyName]}))) r.Users;
64 main () 50 main ()
65 51
66 end 52 end