Commit ac366bf3 authored by Celine Noirot's avatar Celine Noirot
Browse files

Debbug multifilelist with choices.

parent 67bbdde2
......@@ -192,6 +192,7 @@ jQuery.validator.addMethod("maxfilesize", function(value, element, params) {
}, jQuery.validator.format("Selected file(s) exceeds size limits: {1}"));
jQuery.validator.addMethod("multinumber", function(value, element, params) {
var values = value.split(/\n/),
fvalid = true;
for (var i in values) {
......@@ -221,6 +222,9 @@ jQuery.validator.addMethod("mparam", function(value, element, params) {
return true;
});
jQuery.validator.addMethod("inputfiles", function(value, element, params) {
return true;
});
var handsontables = {};
// handle bootstrap datepicker with handsontable
......@@ -392,7 +396,7 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
}
}
var _validateAndSubmitForm = function($this) {
var _validateAndSubmitForm = function($this) { //call when run button
$this.$element.find(".error-wf").remove();
// check if the form is valid
if ($("#workflow_form").valid()) {
......@@ -433,7 +437,12 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
} else if( kv.value != "" ) { //Empty are not sended
// if a multiple string, this is a textarea, split by lines
if ($("#"+kv.name).hasClass("list")) {
hash_param[kv.name] = $("#"+kv.name).val().split(/\n/);
//BUG CORRECTION MULTIPLE FILES
if (~$("#"+kv.name).val().indexOf("\n")){
hash_param[kv.name] = $("#"+kv.name).val().split(/\n/);
} else {
hash_param[kv.name]=new Array(kv.value);
}
} else {
hash_param[kv.name] = new Array(kv.value);
}
......@@ -535,8 +544,12 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
if ($("#"+tid).val()) {
// if a multiple string, this is a textarea, split by lines
if ($("#"+tid).hasClass("list")) {
var allfiles = $("#"+tid).val().split(/\n/),
newtidval = "";
var allfiles = $("#"+tid).val();
if (~allfiles.indexOf("\n")){ //BUG .split(/\n/) si deja array,
allfiles = allfiles.split(/\n/);
}
var newtidval = "";
for (var j = 0; j < allfiles.length; j++) {
newtidval += $this.uploadfiles[tid] + "/" + allfiles[j];
newtidval.replace(/C:\\fakepath\\/i,'').replace(/C:\\fake_path\\/i,'');
......@@ -864,6 +877,7 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
var p_cols = $(this).attr("paired_columns");
var cap = p_cols.match(/(.+)\[(.+)]/)
var format = cap[1];
var paired = cap[2].split(",");
var input = $(this).attr("for");
for (var np=0; np < paired.length; np++) {
......@@ -993,7 +1007,7 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
} else if (!allRequired[$cthis.prop] && (value == null || value == "")) {
callback(true);
$("#error_handsontable_"+param_name).hide();
} else if ( allActions[$cthis.prop] != "append" && (value.split("\n").length > 1)) {
} else if ( allActions[$cthis.prop] != "append" && (~value.indexOf("\n"))) {
$("#error_handsontable_"+param_name).show();
$("#error_handsontable_"+param_name).html("This field does not accept multiple values.");
$("#error_handsontable_"+param_name).parent().addClass("has-error");
......@@ -1220,7 +1234,7 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
nb_octet = size.substring(0, size.length-2) * val;
return nb_octet;
}
WFForm.prototype._getParameterRule = function(param, server_url) {
var crule = {};
crule["mparam"] = param;
......@@ -1236,6 +1250,10 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
var size = param.type.split(SIZE_LIMIT_SPLITER)[1];
crule["maxfilesize"] = [this.getNbOctet(size), size];
// if it is not a known type, check from the custom ones, using the validate_field address
} else if (param.type.indexOf("inputfiles") === 0 && param.action == "append" && param.choices != "undefined") {
//ASK Jerome HowTo debug
crule['inputfiles'] = true;
console.log(param);
} else if (param.type != "str" && param.type != "password" ) {
crule["remote"] = {
url: server_url + '/validate_field?callback=?',
......@@ -1247,7 +1265,6 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
};
}
crule["required"] = param.required;
crule["required"] = param.required;
return crule;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment