diff options
Diffstat (limited to 'demo/tree.ur')
-rw-r--r-- | demo/tree.ur | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/demo/tree.ur b/demo/tree.ur index 06a30cf9..27e9aa21 100644 --- a/demo/tree.ur +++ b/demo/tree.ur @@ -1,3 +1,4 @@ +sequence s table t : { Id : int, Parent : option int, Nam : string } open TreeFun.Make(struct @@ -5,11 +6,28 @@ open TreeFun.Make(struct end) fun row r = <xml> - #{[r.Id]}: {[r.Nam]} + #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a> + + <form> + Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/> + </form> </xml> -fun main () = +and main () = xml <- tree row None; return <xml><body> {xml} + + <form> + Add a top-level node: <textbox{#Nam}/> <submit action={add None}/> + </form> </body></xml> + +and add parent r = + id <- nextval s; + dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]})); + main () + +and del id = + dml (DELETE FROM t WHERE Id = {[id]}); + main () |