modify MethodParamModel in pluginModel.js and createFields function in
plugin-new.js
This commit is contained in:
parent
35e7446e92
commit
f74ba85870
|
@ -40,7 +40,6 @@ function getMethod(pluglin) {
|
|||
}
|
||||
|
||||
function addPlugin() {
|
||||
|
||||
var html = "";
|
||||
for (var j = 0; j < pluginList.length; j++) {
|
||||
var textNode = document.createTextNode(pluginList[j]);
|
||||
|
@ -74,7 +73,7 @@ function pluginFinish() {
|
|||
data = item + "_" + num;
|
||||
pluginChoosedList.push(data);
|
||||
num++;
|
||||
|
||||
|
||||
var div = document.createElement("div");
|
||||
var p = document.createElement("p");
|
||||
var textNode = document.createTextNode(data);
|
||||
|
@ -107,8 +106,8 @@ function showInsertPlugin(selectNode) {
|
|||
getMethodList(methodData);
|
||||
}
|
||||
|
||||
function removeInsertPlugin(){
|
||||
var last=document.getElementById("behaviorArea").lastChild;
|
||||
function removeInsertPlugin() {
|
||||
var last = document.getElementById("behaviorArea").lastChild;
|
||||
document.getElementById("behaviorArea").removeChild(last);
|
||||
}
|
||||
|
||||
|
@ -213,26 +212,44 @@ function loadMethodParams(behaviorData, behaviorIndex) {
|
|||
for (var i = 0; i < data.length; i++) {
|
||||
methodParams.push(data[i]);
|
||||
}
|
||||
|
||||
for (var j = 0; j < methodParams.length; j++) {
|
||||
var methodParamModel = new MethodParamModel(
|
||||
methodParams[j].name,
|
||||
methodParams[j].lable,
|
||||
methodParams[j].paramTypeModel);
|
||||
var paramTypeModel = methodParamModel.paramTypeModel;
|
||||
if (paramTypeModel.type == "field") {
|
||||
methodParams[j].valueSeperator,
|
||||
methodParams[j].fieldSeperator,
|
||||
methodParams[j].paramType,
|
||||
methodParams[j].methodParamPropertyModelSet);
|
||||
var methodParamPropertyModelSet = methodParamModel.methodParamPropertyModelSet;
|
||||
var type = methodParamModel.paramType;
|
||||
var size = 0, cols = "", rows = "";
|
||||
for (var p = 0; p < methodParamPropertyModelSet.length; p++) {
|
||||
var methodParamProertyModel = methodParamPropertyModelSet[p];
|
||||
if (methodParamProertyModel.key == "size") {
|
||||
size = methodParamProertyModel.value;
|
||||
} else if (methodParamProertyModel.key == "cols") {
|
||||
cols = methodParamProertyModel.value;
|
||||
} else if (methodParamProertyModel.key == "rows") {
|
||||
rows = methodParamProertyModel.value;
|
||||
}
|
||||
}
|
||||
if (type == "Field") {
|
||||
fieldHTML += createField(
|
||||
methodParamModel.lable,
|
||||
methodParamModel.name,
|
||||
paramTypeModel.size, behaviorIndex);
|
||||
} else if (paramTypeModel.type == "multiField") {
|
||||
methodParamModel.name, size,
|
||||
behaviorIndex);
|
||||
} else if (type == "MultiField") {
|
||||
fieldHTML += createMultiField(
|
||||
methodParamModel.lable,
|
||||
methodParamModel.name,
|
||||
paramTypeModel.size, behaviorIndex);
|
||||
} else if (paramTypeModel.type == "Table") {
|
||||
fieldHTML += createTable(methodParamModel);
|
||||
} else if (paramTypeModel.type == "CheckBox") {
|
||||
fieldHTML += createTable(methodParamModel);
|
||||
methodParamModel.name, size,
|
||||
behaviorIndex);
|
||||
} else if (type == "Table") {
|
||||
fieldHTML += createTable(methodParamModel,
|
||||
cols, behaviorIndex);
|
||||
} else if (type == "CheckBox") {
|
||||
fieldHTML += createTable(methodParamModel,
|
||||
rows, behaviorIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,17 +274,41 @@ function loadMethodParams(behaviorData, behaviorIndex) {
|
|||
});
|
||||
}
|
||||
|
||||
//创建一个label加一个input的域
|
||||
// 创建一个label加一个input的域
|
||||
function createField(label, name, size, behaviorIndex) {
|
||||
if (size == 0) {
|
||||
size = 20;
|
||||
}
|
||||
/*
|
||||
var divNode = document.createElement("div");
|
||||
var p = document.createElement("p");
|
||||
var labelNode = document.createTextNode(label);
|
||||
var div = document.createElement("div");
|
||||
var nameNode = document.createTextNode(name + ":");
|
||||
var input = document.createElement("input");
|
||||
|
||||
$(divNode).attr("class", "Field sample_frame");
|
||||
$(divNode).attr("id", behaviorIndex + "_" + name);
|
||||
$(div).attr("class","sample_sub_frame");
|
||||
$(input).attr("type","text");
|
||||
$(input).Attr("size",size);
|
||||
$(input).attr("id",name+"_input");
|
||||
|
||||
p.appendChild(labelNode);
|
||||
div.appendChild(nameNode);
|
||||
div.appendChild(input);
|
||||
divNode.appendChild(p);
|
||||
divNode.appendChild(div);
|
||||
|
||||
return $(divNode).html();
|
||||
*/
|
||||
var fieldHTML = "<div class='Field sample_frame' id='" + behaviorIndex
|
||||
+ "_" + name + "'><p>" + label
|
||||
+ "</p><div class='sample_sub_frame'>" + name
|
||||
+ ":<input type='text' size=" + size + " id='" + name
|
||||
+ "_input' value=''></input></div></div>";
|
||||
return fieldHTML;
|
||||
|
||||
}
|
||||
|
||||
// 创建一个可以增加field的域
|
||||
|
@ -284,18 +325,20 @@ function createMultiField(label, name, size, behaviorIndex) {
|
|||
+ ":"
|
||||
+ label
|
||||
+ "</p><div class='sample_sub_frame'><button type='submit' onClick='addField("
|
||||
+ size+","+ behaviorIndex
|
||||
+ size
|
||||
+ ","
|
||||
+ behaviorIndex
|
||||
+ ");'>Add Field</button><button type='submit' onClick='removeField();'>RemoveAll</button><br><table id='addFieldTable_"
|
||||
+ behaviorIndex + "'></table></div></div>";
|
||||
+ behaviorIndex + "'></table></div></div>";
|
||||
return multiFieldHTML;
|
||||
}
|
||||
|
||||
var field;
|
||||
function addField(size,addId) {
|
||||
if(document.getElementById("addFieldTable_"+addId).childNodes.length==0){
|
||||
field=0;
|
||||
function addField(size, addId) {
|
||||
if (document.getElementById("addFieldTable_" + addId).childNodes.length == 0) {
|
||||
field = 0;
|
||||
}
|
||||
//alert("addId:"+addId+",field:"+field);
|
||||
// alert("addId:"+addId+",field:"+field);
|
||||
var data = "field_" + field + ":";
|
||||
field = field + 1;
|
||||
var newTrNode = document.createElement("tr");
|
||||
|
@ -320,7 +363,7 @@ function addField(size,addId) {
|
|||
newTrNode.appendChild(newTdNode1);
|
||||
newTrNode.appendChild(newTdNode2);
|
||||
newTrNode.appendChild(newTdNode3);
|
||||
document.getElementById("addFieldTable_"+addId).appendChild(newTrNode);
|
||||
document.getElementById("addFieldTable_" + addId).appendChild(newTrNode);
|
||||
}
|
||||
|
||||
function deleteField(selectedNode) {
|
||||
|
@ -330,13 +373,12 @@ function deleteField(selectedNode) {
|
|||
}
|
||||
|
||||
// 创建一个Table域
|
||||
function createTable(methodParamModel) {
|
||||
function createTable(methodParamModel, cols, behaviorIndex) {
|
||||
|
||||
var name = methodParamModel.name;
|
||||
var label = methodParamModel.label;
|
||||
var table = methodParamModel.paramTypeModel;
|
||||
var cols = table.cols;
|
||||
var table_content = cols.split(table.valueSeperator);
|
||||
var label = methodParamModel.lable;
|
||||
var valueSeperator = methodParamModel.valueSeperator;
|
||||
var table_content = cols.split(valueSeperator);
|
||||
/*
|
||||
* var divNode = document.createElement("div"); var p =
|
||||
* document.createElement("p"); var div = document.createElement("div"); var
|
||||
|
@ -364,12 +406,15 @@ function createTable(methodParamModel) {
|
|||
|
||||
var tableHead = th.innerHTML + tr_content.innerHTML;
|
||||
var tableHtml = "<div class='Table sample_frame'id="
|
||||
+ behaviorIndex
|
||||
+ "_"
|
||||
+ name
|
||||
+ "><p>"
|
||||
+ label
|
||||
+ "</p><div class='sample_sub_frame'>"
|
||||
+ name
|
||||
+ ":<br><button type='submit'onClick='addCol(this);'>addCol</button><button type='submit' onClick='removeCol(this);'>removeCol</button><br><table class='operateTableCols'>"
|
||||
+ ":<br><button type='submit'onClick='addCol(this);'>addCol</button><button type='submit' "
|
||||
+ "onClick='removeCol(this);'>removeCol</button><br><table class='operateTableCols'>"
|
||||
+ tableHead + "</table></div></div>";
|
||||
/*
|
||||
* // divNode.setAttribute("class","sample_frame");
|
||||
|
@ -413,12 +458,11 @@ function removeCol(selectedNode) {
|
|||
}
|
||||
|
||||
// 创建一个CheckBox域
|
||||
function createCheckBox(methodParamModel) {
|
||||
function createCheckBox(methodParamModel, rows, behaviorIndex) {
|
||||
var name = methodParamModel.name;
|
||||
var label = methodParamModel.label;
|
||||
var checkBox = methodParamModel.paramTypeModel;
|
||||
var rows = checkBox.rows;
|
||||
var cb_content = rows.split(checkBox.valueSeperator);
|
||||
var valueSeperator = methodParamModel.valueSeperator;
|
||||
var cb_content = rows.split(valueSeperator);
|
||||
|
||||
var divNode = document.createElement("div");
|
||||
var p = document.createElement("p");
|
||||
|
@ -427,9 +471,9 @@ function createCheckBox(methodParamModel) {
|
|||
var labelNode = document.createTextNode(label);
|
||||
var nameNode = document.createTextNode(name);
|
||||
|
||||
// divNode.setAttribute("class","sample_frame");
|
||||
divNode.setAttribute("class", "sample_frame");
|
||||
divNode.setAttribute("class", "CheckBox sample_frame");
|
||||
divNode.setAttribute("id", name);
|
||||
divNode.setAttribute("id", behaviorIndex + "_" + name);
|
||||
div.setAttribute("class", "sample_sub_frame");
|
||||
p.appendChild(labelNode);
|
||||
div.appendChild(nameNode + ":");
|
||||
|
@ -473,34 +517,34 @@ $('#behaviorCancel').click(function() {
|
|||
$('#myModal_Behavior').modal('hide');
|
||||
});
|
||||
|
||||
function uploadBehavior(selectedNode){
|
||||
function uploadBehavior(selectedNode) {
|
||||
var uploadNode = selectNode.parentNode.previousSibling;
|
||||
var div=uploadNode.childNodes;
|
||||
var length=div.length;
|
||||
|
||||
var fieldList="";
|
||||
var multiFieldList="";
|
||||
var tableList="";
|
||||
var checkList="";
|
||||
|
||||
for(var i=0;i<length;i++){
|
||||
var node=div[i];
|
||||
if(node.Attr("class")=="Field sample_frame"){
|
||||
fieldList+=$(node).find("input").val()+",";
|
||||
}else if(node.Attr("class")=="multiField sample_frame"){
|
||||
var fieldNode=$(node.lastNode).find("table").children();
|
||||
var fieldLength=fieldNode.length;
|
||||
for(var j=0;j<fieldLength;j++){
|
||||
multiFieldList+=$(fieldNode[j]).find("input").val()+",";
|
||||
var div = uploadNode.childNodes;
|
||||
var length = div.length;
|
||||
|
||||
var fieldList = "";
|
||||
var multiFieldList = "";
|
||||
var tableList = "";
|
||||
var checkList = "";
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
var node = div[i];
|
||||
if (node.Attr("class") == "Field sample_frame") {
|
||||
fieldList += $(node).find("input").val() + ",";
|
||||
} else if (node.Attr("class") == "multiField sample_frame") {
|
||||
var fieldNode = $(node.lastNode).find("table").children();
|
||||
var fieldLength = fieldNode.length;
|
||||
for (var j = 0; j < fieldLength; j++) {
|
||||
multiFieldList += $(fieldNode[j]).find("input").val() + ",";
|
||||
}
|
||||
//多个multiField如何解决
|
||||
}else if(node.Attr("class")=="Table sample_frame"){
|
||||
|
||||
}else if(node.Attr("class")=="CheckBox sample_frame"){
|
||||
|
||||
// 多个multiField如何解决
|
||||
} else if (node.Attr("class") == "Table sample_frame") {
|
||||
|
||||
} else if (node.Attr("class") == "CheckBox sample_frame") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var uploadBehavior = new UploadBehaviorRequestModel(tableList, checkList,
|
||||
fieldList, multiFieldList);
|
||||
upload(uploadBehavior);
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
// 创建一个MethodParamModel对象
|
||||
function MethodParamModel(name, lable, paramTypeModel) {
|
||||
function MethodParamModel(name, lable, valueSeperator,fieldSeperator,paramType, methodParamPropertyModelSet) {
|
||||
this.name = name;
|
||||
this.lable = lable;
|
||||
this.paramTypeModel = paramTypeModel;
|
||||
this.valueSeperator=valueSeperator;
|
||||
this.fieldSeperator=fieldSeperator;
|
||||
this.paramType=paramType;
|
||||
this.methodParamPropertyModelSet=methodParamPropertyModelSet;
|
||||
}
|
||||
//创建一个MethodParamPropertyModel对象
|
||||
function MethodParamPropertyModel(key,value){
|
||||
this.key=key;
|
||||
this.value=value;
|
||||
}
|
||||
// 创建一个ParamTypeModel对象
|
||||
function ParamTypeModel(type, valueSeperator, fieldSeperator, size, rows, cols) {
|
||||
|
|
Loading…
Reference in New Issue