aboutsummaryrefslogtreecommitdiffhomepage
path: root/demo/tree.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-11-06 19:43:48 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-11-06 19:43:48 -0500
commit24b68e6d7408f50023272e765687eab777596363 (patch)
tree36109508292ec57f01529ab31699ed8837d3f0c8 /demo/tree.ur
parentdd4d718ac9f0a9862ebef19beb568bbedcc85848 (diff)
Tree demo working (and other assorted regressions fixed)
Diffstat (limited to 'demo/tree.ur')
-rw-r--r--demo/tree.ur22
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 ()