diff 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
line wrap: on
line diff
--- a/demo/tree.ur	Thu Nov 06 18:49:38 2008 -0500
+++ b/demo/tree.ur	Thu Nov 06 19:43:48 2008 -0500
@@ -1,3 +1,4 @@
+sequence s
 table t : { Id : int, Parent : option int, Nam : string }
 
 open TreeFun.Make(struct
@@ -5,11 +6,28 @@
                   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 ()