From 8a0803137138f04a56670957e3ef7533b4873bef Mon Sep 17 00:00:00 2001 From: Rap RIV Date: Wed, 24 Jun 2020 20:56:09 +0400 Subject: [PATCH] Form : Hotfix multi save --- views/tpls/forms/cplx/multiCheckboxPlus.php | 6 +- views/tpls/forms/cplx/multiRadio.php | 96 +++++----- views/tpls/forms/cplx/multitextvalidation.php | 166 +++++++++--------- 3 files changed, 134 insertions(+), 134 deletions(-) diff --git a/views/tpls/forms/cplx/multiCheckboxPlus.php b/views/tpls/forms/cplx/multiCheckboxPlus.php index f35c5ce..64ee96b 100644 --- a/views/tpls/forms/cplx/multiCheckboxPlus.php +++ b/views/tpls/forms/cplx/multiCheckboxPlus.php @@ -105,7 +105,7 @@ .ckbCo').change(function(){ var allckd = []; // alert(''); $("input:checkbox[name='"+$(this).attr("name")+"']:checked").each(function(){ @@ -462,7 +462,7 @@ jQuery(document).ready(function() { }); }); - $('.inputckbCo').keyup(function(){ + $('#question .inputckbCo').keyup(function(){ if($('input[value="' + $(this).data("imp") + '"]').is(':checked')) { var allckd = []; diff --git a/views/tpls/forms/cplx/multiRadio.php b/views/tpls/forms/cplx/multiRadio.php index 9f8548a..c963497 100644 --- a/views/tpls/forms/cplx/multiRadio.php +++ b/views/tpls/forms/cplx/multiRadio.php @@ -93,7 +93,7 @@ .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 .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.Params = { - "jsonSchema" : { - "title" : " config", - "icon" : "fa-cog", - "properties" : { - list : { - inputType : "array", - label : "Liste de bouton radio", - values : sectionDyf.ParamsData.list - }, - width : { - inputType : "select", - label : "Nombre d'element par ligne", - options : sectionDyf.ParamsData.width, - value : "" - } - }, - save : function () { - tplCtx.value = {}; - $.each( sectionDyf.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.Params = { + "jsonSchema" : { + "title" : " config", + "icon" : "fa-cog", + "properties" : { + list : { + inputType : "array", + label : "Liste de bouton radio", + values : sectionDyf.ParamsData.list + }, + width : { + inputType : "select", + label : "Nombre d'element par ligne", + options : sectionDyf.ParamsData.width, + value : "" + } + }, + save : function () { + tplCtx.value = {}; + $.each( sectionDyf.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(); + } ); + } + + } + } + }; }else{ ?>
- +
@@ -230,93 +230,93 @@ if($mode == "r"){ ?> mylog.log("render form input","/modules/costum/views/tpls/forms/text.php"); sectionDyf.Params = { - "jsonSchema" : { - "title" : " config", - "icon" : "fa-cog", - "properties" : { - validation : { - inputType : "select", - label : "type de l'input", - options : sectionDyf.ParamsData.validation, - values : "" - } - }, - save : function () { - tplCtx.value = {}; - $.each( sectionDyf.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(); - } ); - } - - } - } - }; - - $(".editParamsMt").off().on("click",function() { - tplCtx.id = $(this).data("id"); - tplCtx.collection = $(this).data("collection"); - tplCtx.path = $(this).data("path"); - //mylog.log(".editParams",tplCtx,sectionDyf.ParamsData); - dyFObj.openForm( sectionDyf.Params,null, sectionDyf.ParamsData); - }); - - }); - - $('.effect-2').each(function(){ - $(this).on('blur', function(){ - if($(this).val().trim() != "") { - $(this).addClass('has-val'); - } - else { - $(this).removeClass('has-val'); - } - }) - }) + "jsonSchema" : { + "title" : " config", + "icon" : "fa-cog", + "properties" : { + validation : { + inputType : "select", + label : "type de l'input", + options : sectionDyf.ParamsData.validation, + values : "" + } + }, + save : function () { + tplCtx.value = {}; + $.each( sectionDyf.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(); + } ); + } + + } + } + }; + + $(".editParamsMt").off().on("click",function() { + tplCtx.id = $(this).data("id"); + tplCtx.collection = $(this).data("collection"); + tplCtx.path = $(this).data("path"); + //mylog.log(".editParams",tplCtx,sectionDyf.ParamsData); + dyFObj.openForm( sectionDyf.Params,null, sectionDyf.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 .effect-2').each(function(){ + $(this).on('blur', function(){ + if($(this).val().trim() != "") { + $(this).addClass('has-val'); } + else { + $(this).removeClass('has-val'); + } + }) + }) + + $('#question .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 = ""; + 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 = ""; - 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 .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) { -- GitLab