creat and edit csvprovider plugin
creat and edit csvprovider plugin
This commit is contained in:
parent
1f031c4cad
commit
4c8a1bb9af
|
@ -1,5 +1,4 @@
|
|||
$(function() {
|
||||
$(document).ready(function(){
|
||||
$(function() {
|
||||
$("#behaviorEditor").on("focusout",".editor input",function(){
|
||||
var input = $(this);
|
||||
if(input.attr("required") == "required" && input.val() == ""){
|
||||
|
@ -7,7 +6,14 @@ $(function() {
|
|||
input.focus();
|
||||
}
|
||||
})
|
||||
});
|
||||
$("#pluginEditor").on("focusout",".editor input",function(){
|
||||
var input = $(this);
|
||||
if(input.attr("required") == "required" && input.val() == ""){
|
||||
if (input.attr("type") != "file")
|
||||
information("Please fill in the parameter");
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function checkPluginsInput(plugins) {
|
||||
|
|
|
@ -4,11 +4,12 @@ $(function() {
|
|||
// usePlugin.getPluginList();
|
||||
|
||||
$("#submitScript").click(function() {
|
||||
var plugins = usePlugin.getPlugins();
|
||||
var formData = new FormData();
|
||||
var plugins = usePlugin.getPlugins( formData );
|
||||
var pages = usePlugin.getPages();
|
||||
if(checkPluginsInput(plugins) && checkPagesInput(pages))
|
||||
submitScript(pages,plugins);
|
||||
submitScript(pages, plugins, formData);
|
||||
else
|
||||
information("必填的参数没有填写完整,请补充完整后提交");
|
||||
information("Please complete the required parameters.");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,6 +43,30 @@ DataCollector.prototype.fieldData = function(editor) {
|
|||
check = "false";
|
||||
return new Parameter(name, value, check);
|
||||
};
|
||||
|
||||
DataCollector.prototype.fileData = function(editor, formData) {
|
||||
|
||||
var check = "true";
|
||||
var value = null;
|
||||
var inputs = editor.find("input");
|
||||
if ($(inputs[0]).attr("checkFile") != undefined){
|
||||
value = $(inputs[0]).attr("checkFile");
|
||||
}
|
||||
else{
|
||||
if (inputs[0].files.length == 0){
|
||||
check = "false";
|
||||
}
|
||||
else{
|
||||
var file = inputs[0].files[0];
|
||||
formData.append("paramFiles", file);
|
||||
value = file.name;
|
||||
}
|
||||
}
|
||||
var name = editor.attr("id");
|
||||
|
||||
return new Parameter(name, value, check);
|
||||
}
|
||||
|
||||
DataCollector.prototype.dateData = function(editor) {
|
||||
var name = editor.attr("id");
|
||||
var value = editor.children("input").val();
|
||||
|
@ -126,7 +150,7 @@ DataCollector.prototype.selectData = function(editor) {
|
|||
return new Parameter(name, value);
|
||||
};
|
||||
|
||||
DataCollector.prototype.getUnitParams = function(paramEditors) {
|
||||
DataCollector.prototype.getUnitParams = function(paramEditors,formData) {
|
||||
var params = new Array();
|
||||
for ( var i = 0; i < paramEditors.length; i++) {
|
||||
var editor = $(paramEditors[i]);
|
||||
|
@ -171,7 +195,10 @@ DataCollector.prototype.getUnitParams = function(paramEditors) {
|
|||
return;
|
||||
}
|
||||
params.push(data);
|
||||
} else {
|
||||
}else if (editorType == "file"){
|
||||
data = this.fileData(editor, formData);
|
||||
params.push(data);
|
||||
}else {
|
||||
information($.i18n.prop('dataCollect-errorType'));
|
||||
}
|
||||
|
||||
|
|
|
@ -124,12 +124,18 @@ EditorFactory.prototype.createFile = function(label, name, required, size, id, v
|
|||
$(fieldName).html(name);
|
||||
var file = document.createElement("input");
|
||||
$(file).attr("type", "file");
|
||||
if(value != ""){
|
||||
$(file).attr("checkFile", value);
|
||||
}
|
||||
if(required == "true"){
|
||||
$(file).attr("required", "required");
|
||||
}
|
||||
// $(field).attr("maxlength", size);
|
||||
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
|
||||
$(div).children(".editor").append(fileEditor);
|
||||
var label = document.createElement("label");
|
||||
$(label).html(value);
|
||||
$(div).append(label);
|
||||
return div;
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ function CollectScriptData(behavior) {
|
|||
// this.behaviors = behaviors;
|
||||
//}
|
||||
|
||||
function submitScript(pages,usePlugins) {
|
||||
function submitScript(pages,usePlugins,formData) {
|
||||
|
||||
|
||||
var scriptName = $("#scriptName").val();
|
||||
|
@ -37,13 +37,13 @@ function submitScript(pages,usePlugins) {
|
|||
return;
|
||||
}
|
||||
var runScenarioModel = new RunScenarioModel(0,usePlugins,new Array(),pages);
|
||||
|
||||
formData.append("runScenarioModelStr", JSON.stringify(runScenarioModel));
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "submitScriptCreated" + "/" + scriptName,
|
||||
data :{runScenarioModelStr: JSON.stringify(runScenarioModel)},//JSON.stringify(runScenarioModel),
|
||||
// dataType : "json",
|
||||
// contentType : "application/json",
|
||||
data :formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
return;
|
||||
|
@ -54,20 +54,23 @@ function submitScript(pages,usePlugins) {
|
|||
});
|
||||
|
||||
}
|
||||
function updateScript(scriptId, pages, usePlugins){
|
||||
function updateScript(scriptId, pages, usePlugins, formData){
|
||||
var scriptName = $("#scriptName").val();
|
||||
if (scriptName == undefined || scriptName == "") {
|
||||
information("need a script name!");
|
||||
return;
|
||||
}
|
||||
var runScenarioModel = new RunScenarioModel(0,usePlugins,new Array(),pages);
|
||||
|
||||
formData.append("runScenarioModelStr", JSON.stringify(runScenarioModel));
|
||||
formData.append("scriptId",scriptId);
|
||||
formData.append("scriptName",scriptName);
|
||||
console.log(formData);
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "updateScript",
|
||||
data :{scriptId:scriptId,scriptName:scriptName, runScenarioModelStr: JSON.stringify(runScenarioModel)},//JSON.stringify(runScenarioModel),
|
||||
// dataType : "json",
|
||||
// contentType : "application/json",
|
||||
data :formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
return;
|
||||
|
|
|
@ -125,7 +125,7 @@ function UsePlugin(behaviorListContainerId) {
|
|||
return;
|
||||
}
|
||||
usePluginEditorMap.put($("#pluginEditor").attr("usePlugin"), $(
|
||||
"#pluginEditor div:first").clone());
|
||||
"#pluginEditor div:first").clone(true));
|
||||
$("#pluginEditor").attr("usePlugin", "");
|
||||
$("#pluginEditor").html("");
|
||||
|
||||
|
@ -175,7 +175,7 @@ function UsePlugin(behaviorListContainerId) {
|
|||
return containerId;
|
||||
}
|
||||
//this is for submit
|
||||
this.getPlugins = function() {
|
||||
this.getPlugins = function(formData) {
|
||||
updateUsePlugin();
|
||||
var keys = map.getKeys();
|
||||
var usePlugins = new Array();
|
||||
|
@ -184,7 +184,7 @@ function UsePlugin(behaviorListContainerId) {
|
|||
var usePluginViewModel = map.get(id);
|
||||
var usePluginContainer = usePluginEditorMap.get(id);
|
||||
var params = paramDataCollector.getUnitParams($(
|
||||
usePluginContainer).find(".editor"));
|
||||
usePluginContainer).find(".editor"), formData);
|
||||
usePlugins.push(new UsePluginModel(usePluginViewModel.id, usePluginViewModel.name,usePluginViewModel.nickName, params));
|
||||
}
|
||||
return usePlugins;
|
||||
|
|
Loading…
Reference in New Issue