Commit 8a080313 authored by Raph El's avatar Raph El

Form : Hotfix multi save

parent 0a6eba0d
......@@ -105,7 +105,7 @@
<?php
$cle = $key ;
$value = (!empty($answers)) ? " value='".$answers."' " : "";
$inpClass = " saveOneByOne";
......@@ -440,7 +440,7 @@ jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/multiCheckbox.php");
answer = {};
$('.ckbCo').change(function(){
$('#question<?php echo $cle ?> .ckbCo').change(function(){
var allckd = [];
// alert('<?php echo $kunik ?>');
$("input:checkbox[name='"+$(this).attr("name")+"']:checked").each(function(){
......@@ -462,7 +462,7 @@ jQuery(document).ready(function() {
});
});
$('.inputckbCo').keyup(function(){
$('#question<?php echo $cle ?> .inputckbCo').keyup(function(){
if($('input[value="' + $(this).data("imp") + '"]').is(':checked')) {
var allckd = [];
......
......@@ -93,7 +93,7 @@
<?php
$cle = $key ;
$value = (!empty($answers)) ? " value='".$answers."' " : "";
$inpClass = " saveOneByOne";
......@@ -383,7 +383,7 @@ jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/multiCheckbox.php");
answer = {};
$('.radioCo').change(function(){
$('#question<?php echo $cle ?> .radioCo').change(function(){
if($(this).data("type") == "simple"){
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
......@@ -403,7 +403,8 @@ jQuery(document).ready(function() {
}
});
$('.inputRadioCo').keyup(function(){
$('#question<?php echo $cle ?> .inputRadioCo').keyup(function(){
if($('input[value="' + $(this).data("imp") + '"]').is(':checked')) {
console.log('here');
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
......@@ -415,52 +416,51 @@ jQuery(document).ready(function() {
//toastr.success('saved');
} );
}
})
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
list : {
inputType : "array",
label : "Liste de bouton radio",
values : sectionDyf.<?php echo $kunik ?>ParamsData.list
},
width : {
inputType : "select",
label : "Nombre d'element par ligne",
options : sectionDyf.<?php echo $kunik ?>ParamsData.width,
value : "<?php echo (isset($parentForm["params"][$kunik]['global']['width']) and $parentForm["params"][$kunik]['global']['width'] != "") ? $paramsData["width"][strval($parentForm["params"][$kunik]['global']['width'])] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
});
}
}
};
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
list : {
inputType : "array",
label : "Liste de bouton radio",
values : sectionDyf.<?php echo $kunik ?>ParamsData.list
},
width : {
inputType : "select",
label : "Nombre d'element par ligne",
options : sectionDyf.<?php echo $kunik ?>ParamsData.width,
value : "<?php echo (isset($parentForm["params"][$kunik]['global']['width']) and $parentForm["params"][$kunik]['global']['width'] != "") ? $paramsData["width"][strval($parentForm["params"][$kunik]['global']['width'])] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
<?php if(count($paramsData["list"]) != 0){
......
......@@ -194,7 +194,7 @@ if($mode == "r"){ ?>
}else{
?>
<div class="input-grp " style="position: relative; padding-top: 50px; text-transform: unset;">
<label for="<?php echo $key ?>"><h4 style="text-transform: unset; color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<label for="<?php echo $key ?>"><h4 style="text-transform: unset; color <?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $kunik ; ?><?php echo $label.$editQuestionBtn ?></h4></label>
<br/>
<div class="multiinput" data-validate="Valid email is required: ex@abc.xyz">
......@@ -230,93 +230,93 @@ if($mode == "r"){ ?>
mylog.log("render form input","/modules/costum/views/tpls/forms/text.php");
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
validation : {
inputType : "select",
label : "type de l'input",
options : sectionDyf.<?php echo $kunik ?>ParamsData.validation,
values : "<?php echo (isset($parentForm["params"][$kunik]["validation"])) ? $parentForm["params"][$kunik]["validation"] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
$(".edit<?php echo $kunik ?>ParamsMt").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
});
$('.effect-2').each(function(){
$(this).on('blur', function(){
if($(this).val().trim() != "") {
$(this).addClass('has-val');
}
else {
$(this).removeClass('has-val');
}
})
})
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
validation : {
inputType : "select",
label : "type de l'input",
options : sectionDyf.<?php echo $kunik ?>ParamsData.validation,
values : "<?php echo (isset($parentForm["params"][$kunik]["validation"])) ? $parentForm["params"][$kunik]["validation"] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
$(".edit<?php echo $kunik ?>ParamsMt").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
$('.effect-2').each(function(){
$(this).on('blur', function(){
if(validate(this) == false){
showValidate(this);
}
else {
if($(this).attr('type') == 'email' ) {
$(this).parent().addClass('true-validate');
$('#question<?php echo $key ?> .effect-2').each(function(){
$(this).on('blur', function(){
if($(this).val().trim() != "") {
$(this).addClass('has-val');
}
else {
$(this).removeClass('has-val');
}
})
})
$('#question<?php echo $key ?> .effect-2').each(function(){
$(this).on('blur', function(){
if(validate(this) == false){
showValidate(this);
} else {
if($(this).attr('type') == 'email' ) {
$(this).parent().addClass('true-validate');
}
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = $(this).val();
dataHelper.path2Value(answer , function(params) {
//toastr.success('saved');
});
}
})
});
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = $(this).val();
dataHelper.path2Value(answer , function(params) {
//toastr.success('saved');
});
}
})
})
$('.effect-2').each(function(){
$(this).focus(function(){
hideValidate(this);
$(this).parent().removeClass('true-validate');
$('#question<?php echo $key ?> .effect-2').each(function(){
$(this).focus(function(){
hideValidate(this);
$(this).parent().removeClass('true-validate');
});
});
});
});
function validate (input) {
if($(input).attr('type') == 'email' ) {
if($(input).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) {
......
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