Mercurial > urweb
comparison demo/tree.ur @ 471:20fab0e96217
Tree demo working (and other assorted regressions fixed)
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 06 Nov 2008 19:43:48 -0500 |
parents | b393c2fc80f8 |
children | 1a317a707d71 |
comparison
equal
deleted
inserted
replaced
470:7cb418e9714f | 471:20fab0e96217 |
---|---|
1 sequence s | |
1 table t : { Id : int, Parent : option int, Nam : string } | 2 table t : { Id : int, Parent : option int, Nam : string } |
2 | 3 |
3 open TreeFun.Make(struct | 4 open TreeFun.Make(struct |
4 val tab = t | 5 val tab = t |
5 end) | 6 end) |
6 | 7 |
7 fun row r = <xml> | 8 fun row r = <xml> |
8 #{[r.Id]}: {[r.Nam]} | 9 #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a> |
10 | |
11 <form> | |
12 Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/> | |
13 </form> | |
9 </xml> | 14 </xml> |
10 | 15 |
11 fun main () = | 16 and main () = |
12 xml <- tree row None; | 17 xml <- tree row None; |
13 return <xml><body> | 18 return <xml><body> |
14 {xml} | 19 {xml} |
20 | |
21 <form> | |
22 Add a top-level node: <textbox{#Nam}/> <submit action={add None}/> | |
23 </form> | |
15 </body></xml> | 24 </body></xml> |
25 | |
26 and add parent r = | |
27 id <- nextval s; | |
28 dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]})); | |
29 main () | |
30 | |
31 and del id = | |
32 dml (DELETE FROM t WHERE Id = {[id]}); | |
33 main () |