[Rt-commit] rt branch, lcore, updated. 666756cf63f33421cef4670a8af2ad18f7d5ee96

clkao at bestpractical.com clkao at bestpractical.com
Fri Sep 18 05:39:17 EDT 2009


The branch, lcore has been updated
       via  666756cf63f33421cef4670a8af2ad18f7d5ee96 (commit)
       via  a6bd95c4e2c4e5c6be99ea9969337f00a466abdb (commit)
      from  ebe31ab64609019a51120f8f0e9e31b219739087 (commit)

Summary of changes:
 share/web/static/js/rulebuilder.js |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

- Log -----------------------------------------------------------------
commit a6bd95c4e2c4e5c6be99ea9969337f00a466abdb
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Fri Sep 18 16:22:29 2009 +0800

    remove debug messages.

diff --git a/share/web/static/js/rulebuilder.js b/share/web/static/js/rulebuilder.js
index 7adae56..ed3026c 100644
--- a/share/web/static/js/rulebuilder.js
+++ b/share/web/static/js/rulebuilder.js
@@ -56,7 +56,7 @@ RuleBuilder.prototype.load_expressions = function (node, ctx) {
 
     }
     else {
-        console.log('unknown node type');
+        alert('unknown node type');
     }
 }
 
@@ -382,11 +382,8 @@ RuleBuilder.Context.prototype.state = function() {
     }
     else if ( this.func_name ) {
         var type_complete = false;
-        console.log(this.children);
         for (var i in this.children) {
             var child = this.children[i];
-            console.log(i);
-            console.log(this.children[i]);
             var state = child.state();
             if (state == 'pending')
                 return 'pending';

commit 666756cf63f33421cef4670a8af2ad18f7d5ee96
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Fri Sep 18 17:09:41 2009 +0800

    hook rulebilder into admin/rules/edit.

diff --git a/share/web/static/js/rulebuilder.js b/share/web/static/js/rulebuilder.js
index ed3026c..42f5da2 100644
--- a/share/web/static/js/rulebuilder.js
+++ b/share/web/static/js/rulebuilder.js
@@ -27,10 +27,19 @@ RuleBuilder.load_and_edit_lambda = function (params, return_type, el) {
     var lambda_text = jQuery(el).prev('textarea').text();
     jQuery.post('/rulebuilder/parse_lambda.json', { lambda_text: lambda_text },
                function(response, status) {
-                   new RuleBuilder("#expressionbuilder",
-                                   function () {
-                                       this.load_expressions(response, this.top_context);
-                                   });
+                   var rb = new RuleBuilder("#expressionbuilder",
+                                            function () {
+                                                this.load_expressions(response, this.top_context);
+                                            });
+                   rb.finalize = function() {
+                       var body = this.top_context.serialize();
+                       var lambda = '(lambda ('
+                           +jQuery.map(params,
+                                       function(val) { return val.expression }).join(" ")+') '
+                           +body+')';
+                       jQuery(el).prev('textarea').text(lambda);
+                       this.ebuilder.html('');
+                   };
                },
                'json'); // XXX: handle errors.
 };
@@ -60,6 +69,7 @@ RuleBuilder.prototype.load_expressions = function (node, ctx) {
     }
 }
 
+
 RuleBuilder.prototype.init = function () {
     var sel = this.sel;
     var ebuilder = jQuery(sel);
@@ -125,6 +135,14 @@ RuleBuilder.prototype.init = function () {
             alert(that.top_context.serialize())})
         .prependTo(ebuilder);
 
+    jQuery._div_({'class': 'done'})
+        .text("Done")
+        .click(function(e){
+            if (that.finalize)
+                that.finalize.apply(that);
+        })
+        .prependTo(ebuilder);
+
 };
 
 RuleBuilder.prototype.push_application = function(func_name) {
@@ -410,8 +428,8 @@ RuleBuilder.Context.prototype.update_return_type = function(type) {
     }
     else {
         el.removeClass("matched").addClass("unmatched");
-        this.transformMenu(el);
     }
+    this.transformMenu(el);
 }
 
 RuleBuilder.Context.prototype.clear = function() {

-----------------------------------------------------------------------


More information about the Rt-commit mailing list