Commit cd1afa57 authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

open dynform

parent f717887a
...@@ -64,7 +64,7 @@ class Form { ...@@ -64,7 +64,7 @@ class Form {
"tpls.forms.cplx.subList" => "sublist : subliste", "tpls.forms.cplx.subList" => "sublist : subliste",
"tpls.forms.cplx.list" => "list : liste", "tpls.forms.cplx.list" => "list : liste",
"tpls.forms.cplx.multiList" => "multiList : multiListe", "tpls.forms.cplx.multiList" => "multiList : multiListe",
"tpls.forms.cplx.openDynform" => "Tableau ou liste de réponse", "tpls.forms.cplx.openDynform" => "Tableau ou liste de réponse (Open Dynamic Form)",
]; ];
......
...@@ -2,12 +2,17 @@ ...@@ -2,12 +2,17 @@
$debug = false; $debug = false;
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='".$answerPath."' class='add".$kunik." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : ""; $editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='".$answerPath."' class='add".$kunik." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : "";
$dynForm = PHDB::findOne(Form::COLLECTION,["id"=>"arrayDynFormPixel"]); $dynForm = PHDB::findOne(Form::COLLECTION,["id"=>$key]);
if(!isset($dynForm)){
echo "<h4>Form not found key : ".$key."</h4>";
exit;
}
$editParamsBtn = ($canEditForm) ? " <a href='javascript:;' data-id='".$dynForm["_id"]."' data-collection='".Form::COLLECTION."' data-path='inputs' class='previewTpl edit".$dynForm["id"]."Dynform btn btn-xs btn-danger'><i class='fa fa-cog'></i> Editer le formulaire </a>" : ""; $editParamsBtn = ($canEditForm) ? " <a href='javascript:;' data-id='".$dynForm["_id"]."' data-collection='".Form::COLLECTION."' data-path='inputs' class='previewTpl edit".$dynForm["id"]."Dynform btn btn-xs btn-danger'><i class='fa fa-cog'></i> Editer le formulaire </a>" : "";
//var_dump( PHDB::findOne( Form::COLLECTION,["id"=>"arrayDynFormPixel"] ) ); //var_dump( PHDB::findOne( Form::COLLECTION,["id"=>"arrayDynFormPixel"] ) );
$properties = $dynForm["inputs"] ; $properties = ( isset($dynForm["inputs"]) ) ? $dynForm["inputs"] : [];
?> ?>
<?php <?php
...@@ -43,7 +48,7 @@ if($mode != "r" && $mode != "pdf"){ ...@@ -43,7 +48,7 @@ if($mode != "r" && $mode != "pdf"){
#dynformUl li{ padding: 3px; } #dynformUl li{ padding: 3px; }
.miniTxt{font-size: 0.7em} .miniTxt{font-size: 0.7em}
</style> </style>
<div id="form-buildDynform" style="display:none; "> <div id="form-buildDynform<?php echo $dynForm["id"]?>" style="display:none; ">
<h4 class='text-center' style="margin-top: 50px">Construteur de formulaire</h4> <h4 class='text-center' style="margin-top: 50px">Construteur de formulaire</h4>
<ul id="dynformUl"> <ul id="dynformUl">
<?php <?php
...@@ -68,9 +73,8 @@ $(document).ready(function() { ...@@ -68,9 +73,8 @@ $(document).ready(function() {
sectionDyf.<?php echo $kunik ?> = { sectionDyf.<?php echo $kunik ?> = {
jsonSchema : { jsonSchema : {
title : "<?php echo $dynForm["name"] ?>", title : "<?php echo $input["label"]?>",
icon : "<?php echo $dynForm["icon"] ?>", icon : "fa-lists",
text : "<?php echo $dynForm["text"] ?>",
properties : <?php echo json_encode( $properties ); ?>, properties : <?php echo json_encode( $properties ); ?>,
save : function (formData) { save : function (formData) {
mylog.log('save tplCtx formData', formData) mylog.log('save tplCtx formData', formData)
...@@ -121,12 +125,6 @@ $(document).ready(function() { ...@@ -121,12 +125,6 @@ $(document).ready(function() {
delete formData.collection ; delete formData.collection ;
delete formData.id ; delete formData.id ;
delete tplCtx.key ;
delete tplCtx.form ;
delete tplCtx.costumId ;
delete tplCtx.costumType ;
delete tplCtx.costumSlug ;
delete tplCtx.form ;
tplCtx.value = formData; tplCtx.value = formData;
mylog.log("save tplCtx",tplCtx); mylog.log("save tplCtx",tplCtx);
...@@ -164,7 +162,7 @@ $(document).ready(function() { ...@@ -164,7 +162,7 @@ $(document).ready(function() {
$(".edit<?php echo $dynForm["id"]?>Dynform").off().click(function() { $(".edit<?php echo $dynForm["id"]?>Dynform").off().click(function() {
tplCtx.id = $(this).data("id"); tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection"); tplCtx.collection = $(this).data("collection");
smallMenu.open( $("#form-buildDynform").html(),"bootbox",null,function() { smallMenu.open( $("#form-buildDynform<?php echo $dynForm["id"]?>").html(),"bootbox",null,function() {
$(".addInputDynform_<?php echo $dynForm["id"]?>").off().click(function() { $(".addInputDynform_<?php echo $dynForm["id"]?>").off().click(function() {
tplCtx.path = "inputs.q<?php echo "_".time()."_".count( $properties ); ?>"; tplCtx.path = "inputs.q<?php echo "_".time()."_".count( $properties ); ?>";
mylog.log("addInput tplCtx",tplCtx); mylog.log("addInput tplCtx",tplCtx);
......
...@@ -92,27 +92,27 @@ if( isset( $form["inputs"] ) ){ ?> ...@@ -92,27 +92,27 @@ if( isset( $form["inputs"] ) ){ ?>
// var_dump($answerPath); // var_dump($answerPath);
// var_dump($answers); // var_dump($answers);
$p = [ $p = [
"el" => $el,
"parentForm"=> $parentForm,
"form" => $form,
"key" => $key,
"kunik" => $kunik,
"input" => $input, "input" => $input,
"type" => $input["type"], "type" => $input["type"],
"answerPath" => $answerPath, "answerPath"=> $answerPath,
"answer" => $answer, "answer" => $answer,
"answers" => $answers ,//sub answers for this input "answers" => $answers ,//sub answers for this input
"label" => $input["label"] ,//$ct." - ".$input["label"] , "label" => $input["label"] ,//$ct." - ".$input["label"] ,
"titleColor"=> (isset($this->costum["colors"]["pink"])) ? $this->costum["colors"]["pink"] : "#16A9B1", "titleColor"=> (isset($this->costum["colors"]["pink"])) ? $this->costum["colors"]["pink"] : "#000",
"info" => isset($input["info"]) ? $input["info"] : "" , "info" => isset($input["info"]) ? $input["info"] : "" ,
"placeholder" => isset($input["placeholder"]) ? $input["placeholder"] : "" , "placeholder" => isset($input["placeholder"]) ? $input["placeholder"] : "" ,
"parentForm" => $parentForm, "mode" => $mode,
"form" => $form,
"key" => $key,
"kunik" => $kunik,
"mode" => $mode,
"canEdit" => $canEdit, "canEdit" => $canEdit,
"canEditForm" => @$canEditForm, "canEditForm" => @$canEditForm,
"canAnswer" => $canAnswer, "canAnswer" => $canAnswer,
"editQuestionBtn" => @$editQuestionBtn, "editQuestionBtn" => @$editQuestionBtn,
"saveOneByOne" => $saveOneByOne, "saveOneByOne" => $saveOneByOne,
"wizard" => (isset($wizard) && $wizard == true) , "wizard" => (isset($wizard) && $wizard == true) ];
"el" => $el ];
if(isset($tplT[2]) && $tplT[2] == "select" && isset($input["options"])) if(isset($tplT[2]) && $tplT[2] == "select" && isset($input["options"]))
$p["options"] = $input["options"]; $p["options"] = $input["options"];
...@@ -447,21 +447,42 @@ jQuery(document).ready(function() { ...@@ -447,21 +447,42 @@ jQuery(document).ready(function() {
//alert("inputs."+tplCtx.form+inputCt); //alert("inputs."+tplCtx.form+inputCt);
tplCtx.path = "inputs."+tplCtx.form+inputCt; tplCtx.path = "inputs."+tplCtx.form+inputCt;
tplCtx.inputId = tplCtx.form+inputCt;
tplCtx.value = { tplCtx.value = {
label : $("#label").val(), label : $("#label").val(),
placeholder : $("#placeholder").val(),
info : $("#info").val(),
type : $("#type").val() type : $("#type").val()
}; };
if( $("#placeholder").val() != "" )
tplCtx.value.placeholder = $("#placeholder").val();
if( $("#info").val() != "" )
tplCtx.value.info = $("#info").val();
delete tplCtx.form; delete tplCtx.form;
mylog.log("activeForm save tplCtx",tplCtx); mylog.log("activeForm save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined") if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!'); toastr.error('value cannot be empty!');
else { else {
dataHelper.path2Value( tplCtx, function(params) { dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide'); if(tplCtx.value.type == "tpls.forms.cplx.openDynform" ){
//location.href = location.origin+location.pathname+"/form/<?php echo $formId ?>"; delete tplCtx.path;
urlCtrl.loadByHash(location.hash); delete tplCtx.id;
tplCtx.value = {
id : tplCtx.inputId,
name : tplCtx.value.label,
type : "dynform"
};
mylog.log("create openDynform save tplCtx",tplCtx);
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
urlCtrl.loadByHash(location.hash);
} );
} else {
$("#ajax-modal").modal('hide');
urlCtrl.loadByHash(location.hash);
}
} ); } );
} }
......
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