/**
* Created by Jacky.gao on 2016/2/24.
*/
ActionTreeNode=function(parentNode){
TreeNode.call(this,parentNode);
this.actionTypes=[];
this.initNode();
};
ActionTreeNode.prototype=Object.create(TreeNode.prototype);
ActionTreeNode.prototype.constructor=ActionTreeNode;
ActionTreeNode.prototype.initNode=function(){
this.nodeContainer=$("
");
this.col.append(this.nodeContainer);
this.actionsContainer=$("
");
this.nodeContainer.append(this.actionsContainer);
this.addAction();
var self=this;
var operations=$("");
this.nodeContainer.append(operations);
var menuItems=[];
menuItems.push({
name:"delete",
label:"删除",
onClick:function(){
URule.confirm("真的要删除当前节点?",function(){
self.delete();
});
}
});
menuItems.push({
name:"addAction",
label:"添加动作",
onClick:function(){
self.addAction(true);
}
});
var menu=new URule.menu.Menu({menuItems:menuItems});
operations.click(function(e){
menu.show(e);
});
};
ActionTreeNode.prototype.addAction=function(notfirst){
var actionContainer=$("");
if(notfirst){
actionContainer.css("display","block");
}
var delIcon=$("");
actionContainer.append(delIcon);
this.actionsContainer.append(actionContainer);
var newActionType=new urule.ActionType(actionContainer);
this.actionTypes.push(newActionType);
actionContainer.actionType=newActionType;
var self=this;
delIcon.click(function(){
if(self.actionTypes.length===1){
URule.alert("动作至少要有一个.");
return;
}
var pos=-1;
$.each(self.actionTypes,function(i,at){
if(at===actionContainer.actionType){
pos=i;
return false;
}
});
if(pos!==-1){
self.actionTypes.splice(pos,1);
actionContainer.remove();
}else{
URule.alert("未找到要删除的动作对象.");
}
});
return newActionType;
};
ActionTreeNode.prototype.initData=function(data){
if(!data){
return;
}
var actions=data["actions"];
if(!actions || actions.length===0){
return;
}
this.actionTypes[0].parentContainer.remove();
this.actionTypes.splice(0,1);
for(var i=0;i";
return xml;
};