Mercurial > urweb
comparison tests/crud.ur @ 337:18d5affa790d
Deletion for Crud
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 13 Sep 2008 20:15:30 -0400 |
parents | 34847732cefc |
children | 075b36dbb1a4 |
comparison
equal
deleted
inserted
replaced
336:34847732cefc | 337:18d5affa790d |
---|---|
12 end) = struct | 12 end) = struct |
13 | 13 |
14 open constraints M | 14 open constraints M |
15 val tab = M.tab | 15 val tab = M.tab |
16 | 16 |
17 fun delete (id : int) = | |
18 () <- dml (DELETE FROM tab WHERE Id = {id}); | |
19 return <html><body> | |
20 The deed is done. | |
21 </body></html> | |
22 | |
23 fun confirm (id : int) = return <html><body> | |
24 <p>Are you sure you want to delete ID #{txt _ id}?</p> | |
25 | |
26 <p><a link={delete id}>I was born sure!</a></p> | |
27 </body></html> | |
28 | |
17 fun main () : transaction page = | 29 fun main () : transaction page = |
18 rows <- queryX (SELECT * FROM tab AS T) | 30 rows <- queryX (SELECT * FROM tab AS T) |
19 (fn (fs : {T : $([Id = int] ++ M.cols)}) => <body> | 31 (fn (fs : {T : $([Id = int] ++ M.cols)}) => <body> |
20 <tr> | 32 <tr> |
21 <td>{txt _ fs.T.Id}</td> | 33 <td>{txt _ fs.T.Id}</td> |
24 [[nm] ~ rest] => | 36 [[nm] ~ rest] => |
25 fn v col => <tr> | 37 fn v col => <tr> |
26 <td>{col.Show v}</td> | 38 <td>{col.Show v}</td> |
27 </tr>) | 39 </tr>) |
28 [M.cols] (fs.T -- #Id) M.cols} | 40 [M.cols] (fs.T -- #Id) M.cols} |
41 <td><a link={confirm fs.T.Id}>[Delete]</a></td> | |
29 </tr> | 42 </tr> |
30 </body>); | 43 </body>); |
31 return <html><head> | 44 return <html><head> |
32 <title>{cdata M.title}</title> | 45 <title>{cdata M.title}</title> |
33 | 46 |