ソースを参照

添加调试信息输出选项控制,一旦打开则会向控制台输出调试信息,同时可通过urule.debug属性将其统一关闭

jacky6024 8 年 前
コミット
97b75a00c6

+ 10 - 0
urule-console-js/src/editor/decisiontable/DecisionTable.js

@@ -96,6 +96,12 @@ window._setDirty=function(){
 				defaultValue:true,
 				editorType:3,
 				onClick:onClick
+			},{
+				label:"允许调试信息输出",
+				name:"debug",
+				defaultValue:true,
+				editorType:3,
+				onClick:onClick
 			}]
 		});
 		addProp.click(function(e){
@@ -998,6 +1004,10 @@ window._setDirty=function(){
 					if(enabled!=null){
 						self.addProperty(new urule.RuleProperty(self,"enabled",enabled,3));
 					}
+					var debug=decisionTable["debug"];
+					if(debug!=null){
+						self.addProperty(new urule.RuleProperty(self,"debug",debug,3));
+					}
 
 					var libraries=decisionTable.libraries||[];
 					$.each(libraries,function(index,library){

+ 10 - 0
urule-console-js/src/editor/decisiontree/new/DecisionTree.js

@@ -70,6 +70,12 @@ export default class DecisionTree{
                 defaultValue:true,
                 editorType:3,
                 onClick:onClick
+            },{
+                label:"允许调试信息输出",
+                name:"debug",
+                defaultValue:true,
+                editorType:3,
+                onClick:onClick
             }]
         });
         addProp.click(function(e){
@@ -237,6 +243,10 @@ export default class DecisionTree{
                     if(enabled!=null){
                         self.addProperty(new urule.RuleProperty(self,"enabled",enabled,3));
                     }
+                    var debug=treeData["debug"];
+                    if(debug!=null){
+                        self.addProperty(new urule.RuleProperty(self,"debug",debug,3));
+                    }
 
                     var libraries=treeData["libraries"];
                     if(libraries){

+ 1 - 1
urule-console-js/src/editor/ul/urule-hint.js

@@ -105,7 +105,7 @@ function scriptHint(editor, keywords, getToken, options) {
 	CodeMirror.registerHelper("hint", "urule", uruleHint);
 
 	var importKeywords=( "importVariableLibrary importConstrantLibrary importActionLibrary import function").split(" ");
-	var ruleKeywords = ( "salience effective-date expires-date enabled activation-group agenda-group auto-focus ruleflow-group").split(" ");
+	var ruleKeywords = ( "salience effective-date expires-date enabled debug activation-group agenda-group auto-focus ruleflow-group").split(" ");
 	var ifKeywords = ( "参数 > >= < <= == != Endwith NotEndwith Startwith NotStartwith In NotIn Match NotMatch EqualsIgnoreCase NotEqualsIgnoreCase eval()").split(" ");
 	var thenKeywords = ( "参数 out").split(" ");
 	var endKeywords = ( "function").split(" ");

+ 1 - 1
urule-console-js/src/editor/ul/urule_mode.js

@@ -15,7 +15,7 @@ CodeMirror.defineSimpleMode("urule", {
     // no ambiguity between this one and the one above
     {regex: /(rule|loopRule|loopTarget|loopStart|loopEnd|if|then|else|end)\b/, token: "keyword"},
     {regex: /(\u89C4\u5219|\u5faa\u73af\u89c4\u5219|\u5faa\u73af\u5bf9\u8c61|\u5f00\u59cb\u524d\u52a8\u4f5c|\u7ed3\u675f\u540e\u52a8\u4f5c|\u5982\u679C|\u90A3\u4E48|\u5426\u5219|\u7ED3\u675F)/, token: "keyword"},
-    {regex: /(true|false|null|and|or|importParameterLibrary|importVariableLibrary|importConstantLibrary|importActionLibrary|salience|loop|effective-date|expires-date|enabled|activation-group|agenda-group|auto-focus)\b/, token: "atom"},
+    {regex: /(true|false|null|and|or|importParameterLibrary|importVariableLibrary|importConstantLibrary|importActionLibrary|salience|loop|effective-date|expires-date|enabled|debug|activation-group|agenda-group|auto-focus)\b/, token: "atom"},
     {regex: /\s+(\u6216\u8005|\u6216|\u5E76\u4E14|\u4E14)\s+/, token: "atom"},
     {regex: /\u53C2\u6570/, token: "atom-2"},
     {regex: /(out|eval|all|exist|collect|count)\b/, token: "atom-3"},

+ 10 - 0
urule-console-js/src/editor/urule/Rule.js

@@ -52,6 +52,10 @@ urule.Rule.prototype.initData=function(){
 	if(enabled!=null){
 		this.addProperty(new urule.RuleProperty(this,"enabled",enabled,3));
 	}
+	var debug=this.data["debug"];
+	if(debug!=null){
+		this.addProperty(new urule.RuleProperty(this,"debug",debug,3));
+	}
 	var activationGroup=this.data["activationGroup"];
 	if(activationGroup){
 		this.addProperty(new urule.RuleProperty(this,"activation-group",activationGroup,1));
@@ -212,6 +216,12 @@ urule.Rule.prototype.initHeader=function(){
 			defaultValue:true,
 			editorType:3,
 			onClick:onClick
+		},{
+			label:"允许调试信息输出",
+			name:"debug",
+			defaultValue:true,
+			editorType:3,
+			onClick:onClick
 		},{
 			label:"互斥组",
 			name:"activation-group",

+ 2 - 0
urule-console-js/src/editor/urule/RuleProperty.js

@@ -97,6 +97,8 @@ urule.RuleProperty.prototype.getLabel=function(){
 		label="失效日期";
 	}else if(this.name=="enabled"){
 		label="是否启用";
+	}else if(this.name=="debug"){
+		label="允许调试信息输出";
 	}else if(this.name=="activation-group"){
 		label="互斥组";
 	}else if(this.name=="agenda-group"){

+ 17 - 1
urule-console-js/src/flow/RuleFlowDesigner.js

@@ -34,8 +34,12 @@ export default class RuleFlowDesigner extends FlowDesigner{
             MsgBox.alert('决策流至少要包含一个开始节点和一个其它类型节点!');
             return;
         }
+        let debug=false;
+        if(this.debug!==undefined && this.debug!==null){
+            debug=this.debug;
+        }
         let xml='<?xml version="1.0" encoding="utf-8"?>';
-        xml+=`<rule-flow id="${this.flowId}">`;
+        xml+=`<rule-flow id="${this.flowId}" debug="${debug}">`;
         for(let lib of this.importVariableLibraries){
             xml+=`<import-variable-library path="${lib}"/>`;
         }
@@ -60,6 +64,7 @@ export default class RuleFlowDesigner extends FlowDesigner{
 
     fromJson(json){
         this.flowId=json.id;
+        this.debug=json.debug;
         const libs=json.libraries || [];
         for(let lib of libs){
             switch (lib.type){
@@ -149,6 +154,17 @@ export default class RuleFlowDesigner extends FlowDesigner{
             flowIdText.val(this.flowId);
             g.append(flowIdGroup);
 
+            const debugGroup=$(`<div class="form-group"><label>允许调试信息输出</label></div>`);
+            const debugSelect=$(`<select class="form-control">
+                <option value="true" ${_this.debug ? "selected" : ""}>是</option>
+                <option value="false" ${_this.debug ? "" : "selected"}>否</option>
+            </select>`);
+            debugGroup.append(debugSelect);
+            debugSelect.change(function(){
+                _this.debug=$(this).val();
+            });
+            g.append(debugGroup);
+
             const libGroup=$('<div class="form-group"><label>库文件</label></div>');
             const addButton=$(`<span style="float: right;"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-plus"></i> 添加</button></span>`);
             libGroup.append(addButton);

+ 1 - 1
urule-console-js/src/scorecard/TableAction.js

@@ -48,7 +48,7 @@ export default class TableAction{
     initScoringSetting(){
         const scoringSettingContainer=$(`<div style="margin: 5px;">得分计算方式:</div>`);
         this.container.append(scoringSettingContainer);
-        this.scoringSettingSelect=$(`<select class="form-control" style="display: inline-block;width:120px;height:30px;"></select>`);
+        this.scoringSettingSelect=$(`<select class="form-control" style="display: inline-block;width:120px;height:30px;padding: 3px;"></select>`);
         scoringSettingContainer.append(this.scoringSettingSelect);
         this.scoringSettingSelect.append(`<option value="sum">求和</option>`);
         this.scoringSettingSelect.append(`<option value="weightsum">加权求和</option>`);