Commit 8f82da1e authored by Anatole Rakotoson's avatar Anatole Rakotoson

reloadinput

parent b25796a0
<?php
class ReloadinputAction extends CAction
{
public function run($answerId=null, $key=null, $formId=null, $kunik=null, $wizard=null, $titleColor=null, $mode=null, $canEdit=null, $canEditForm = null, $canAdminAnswer=null, $canAnswer=null, $editQuestionBtn=null, $saveOneByOne=null, $tpl=null)
public function run($answerId=null, $key=null, $formId=null, $wizard=null, $titleColor=null, $mode=null, $canEdit=null, $canEditForm = null, $canAdminAnswer=null, $canAnswer=null, $editQuestionBtn=null, $saveOneByOne=null)
{
$controller = $this->getController();
......@@ -20,6 +20,10 @@ class ReloadinputAction extends CAction
$input = $form["inputs"][$key];
$answerPath = "answers.".$key.".";
$kunikT = explode( ".", $input["type"]);
$keyTpl = ( count($kunikT)>1 ) ? $kunikT[ count($kunikT)-1 ] : $input["type"];
$kunik = $keyTpl.$key;
if(isset($wizard))
{
if($wizard){
......@@ -32,7 +36,17 @@ class ReloadinputAction extends CAction
$answers = $answer["answers"][$key];
}
}
$tpl = $input["type"];
if(in_array($tpl, ["textarea","markdown","wysiwyg"])){
$tpl = "tpls.forms.textarea";
}
else if(empty($tpl) || in_array($tpl, ["text","button","color","date","datetime-local","email","image","month","number","radio","range","tel","time","url","week","tags"])){
$tpl = "tpls.forms.text";
}
else if(in_array($tpl, ["sectionTitle"])){
$tpl = "tpls.forms.".$tpl;
}
$p = [
"el" => $el,
......
......@@ -469,7 +469,7 @@ costumInputs.elementproject = {
$("#ajax-modal").modal('hide');
//coInterface.showLoader("#central-container")
urlCtrl.loadByHash( location.hash );
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
}
};
......@@ -503,7 +503,7 @@ $(document).ready(function() {
else {
$("#ajax-modal").modal('hide');
//coInterface.showLoader("#central-container")
urlCtrl.loadByHash( location.hash );
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
}
},
// connectToAnswer : function (data) {
......@@ -575,7 +575,7 @@ $(document).ready(function() {
$("#ajax-modal").modal('hide');
//urlCtrl.loadByHash(location.hash);
//coInterface.showLoader("#central-container")
urlCtrl.loadByHash( location.hash );
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
} );
}
......
......@@ -291,13 +291,7 @@
else {
dataHelper.path2Value( tplCtx, function(params) {
dyFObj.closeForm();
ajaxPost(
"#question<?php echo $key ?>",
baseUrl+"/survey/answer/reloadinput/tpl/<?php echo $tpl ?>/answerId/<?php echo (string)$answer["_id"] ?>/key/<?php echo $key ?>/formId/<?php echo (string)$form["_id"] ?>/kunik/<?php echo $kunik ?>/wizard/<?php echo $wizard ?>/mode/<?php echo $mode ?>/canEdit/<?php echo $canEdit ?>/canEditForm/<?php echo $canEditForm ?>/canAdminAnswer/<?php echo $canAdminAnswer ?>/canAnswer/<?php echo $canAnswer ?>/saveOneByOne/<?php echo $saveOneByOne ?>",
null,
function(){
},"html");
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
} );
}
......@@ -330,7 +324,7 @@
else {
dataHelper.path2Value( tplCtx, function(params) {
dyFObj.closeForm();
urlCtrl.loadByHash(location.hash);
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
} );
}
......
......@@ -546,6 +546,16 @@ function saveLinks(id,linkType,uid,callB){
} else if(typeof callB == "function" )
callB();
}
function reloadInput(key, formId){
ajaxPost(
"#question"+key,
baseUrl+"/survey/answer/reloadinput/answerId/<?php echo (string)$answer["_id"] ?>/key/"+key+"/formId/"+formId+"/wizard/<?php echo $wizard ?>/mode/<?php echo $mode ?>/canEdit/<?php echo $canEdit ?>/canEditForm/<?php echo $canEditForm ?>/canAdminAnswer/<?php echo $canAdminAnswer ?>/canAnswer/<?php echo $canAnswer ?>/saveOneByOne/<?php echo $saveOneByOne ?>",
null,
function(){
},"html");
}
</script>
<?php } ?>
\ No newline at end of file
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