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

open dynform

parent f717887a
......@@ -64,7 +64,7 @@ class Form {
"tpls.forms.cplx.subList" => "sublist : subliste",
"tpls.forms.cplx.list" => "list : liste",
"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 @@
$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>" : "";
$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>" : "";
//var_dump( PHDB::findOne( Form::COLLECTION,["id"=>"arrayDynFormPixel"] ) );
$properties = $dynForm["inputs"] ;
$properties = ( isset($dynForm["inputs"]) ) ? $dynForm["inputs"] : [];
?>
<?php
......@@ -43,7 +48,7 @@ if($mode != "r" && $mode != "pdf"){
#dynformUl li{ padding: 3px; }
.miniTxt{font-size: 0.7em}
</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>
<ul id="dynformUl">
<?php
......@@ -68,9 +73,8 @@ $(document).ready(function() {
sectionDyf.<?php echo $kunik ?> = {
jsonSchema : {
title : "<?php echo $dynForm["name"] ?>",
icon : "<?php echo $dynForm["icon"] ?>",
text : "<?php echo $dynForm["text"] ?>",
title : "<?php echo $input["label"]?>",
icon : "fa-lists",
properties : <?php echo json_encode( $properties ); ?>,
save : function (formData) {
mylog.log('save tplCtx formData', formData)
......@@ -121,12 +125,6 @@ $(document).ready(function() {
delete formData.collection ;
delete formData.id ;
delete tplCtx.key ;
delete tplCtx.form ;
delete tplCtx.costumId ;
delete tplCtx.costumType ;
delete tplCtx.costumSlug ;
delete tplCtx.form ;
tplCtx.value = formData;
mylog.log("save tplCtx",tplCtx);
......@@ -164,7 +162,7 @@ $(document).ready(function() {
$(".edit<?php echo $dynForm["id"]?>Dynform").off().click(function() {
tplCtx.id = $(this).data("id");
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() {
tplCtx.path = "inputs.q<?php echo "_".time()."_".count( $properties ); ?>";
mylog.log("addInput tplCtx",tplCtx);
......
......@@ -92,27 +92,27 @@ if( isset( $form["inputs"] ) ){ ?>
// var_dump($answerPath);
// var_dump($answers);
$p = [
"el" => $el,
"parentForm"=> $parentForm,
"form" => $form,
"key" => $key,
"kunik" => $kunik,
"input" => $input,
"type" => $input["type"],
"answerPath" => $answerPath,
"answerPath"=> $answerPath,
"answer" => $answer,
"answers" => $answers ,//sub answers for this input
"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"] : "" ,
"placeholder" => isset($input["placeholder"]) ? $input["placeholder"] : "" ,
"parentForm" => $parentForm,
"form" => $form,
"key" => $key,
"kunik" => $kunik,
"mode" => $mode,
"canEdit" => $canEdit,
"canEditForm" => @$canEditForm,
"canAnswer" => $canAnswer,
"editQuestionBtn" => @$editQuestionBtn,
"saveOneByOne" => $saveOneByOne,
"wizard" => (isset($wizard) && $wizard == true) ,
"el" => $el ];
"wizard" => (isset($wizard) && $wizard == true) ];
if(isset($tplT[2]) && $tplT[2] == "select" && isset($input["options"]))
$p["options"] = $input["options"];
......@@ -447,22 +447,43 @@ jQuery(document).ready(function() {
//alert("inputs."+tplCtx.form+inputCt);
tplCtx.path = "inputs."+tplCtx.form+inputCt;
tplCtx.inputId = tplCtx.form+inputCt;
tplCtx.value = {
label : $("#label").val(),
placeholder : $("#placeholder").val(),
info : $("#info").val(),
type : $("#type").val()
};
if( $("#placeholder").val() != "" )
tplCtx.value.placeholder = $("#placeholder").val();
if( $("#info").val() != "" )
tplCtx.value.info = $("#info").val();
delete tplCtx.form;
mylog.log("activeForm save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
if(tplCtx.value.type == "tpls.forms.cplx.openDynform" ){
delete tplCtx.path;
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');
//location.href = location.origin+location.pathname+"/form/<?php echo $formId ?>";
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