Commit 911cd1f6 authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

links.answers added to elements

parent 4c0b89e1
......@@ -69,7 +69,7 @@ class AnswerAction extends CAction
}
echo $ctrl->render( "answerList" ,$params);
}
else if( @$answer["formId"] && @$answer["answers"] )
else if( @$answer["formId"] )
{
if( !$view ){
$ctrl->layout = "//layouts/empty";
......
......@@ -20,13 +20,13 @@
"afterSave" : {
"path" : "/costum/co/index/id/ctenat#@",
"where" : "project"
},
},
"costum" : {
"editForm" : "survey.views.co.dossierEdit2"
"editForm" : "survey.views.custom.ctenat.dossierEdit"
},
"scenario" : {
"organization" : {
"title" : "Ajouter une structure porteuse",
"title" : "Structure porteuse",
"description" : "Présenter l'organisation porteuse du projet.",
"where" : "parentModuleUrl",
"path" : "/js/dynForm/organization2.js",
......@@ -38,8 +38,24 @@
},
"costum" : {
"dynFormCostum" : {
"beforeBuild" : {
"properties" : {
"category" : {
"inputType" : "hidden",
"value" : "ficheAction"
},
"links[answers]" : {
"inputType" : "hidden"
}
}
},
"onload" : {
"actions" : {
"presetValue" : {
"links[answers]" : {
"eval" : "answerId"
}
},
"hide" : {
"urltext" : 1,
"parentfinder" : 1
......@@ -50,7 +66,7 @@
}
},
"project" : {
"title" : "Ajouter votre action",
"title" : "L'action ou le projet",
"description" : "Décrivez votre Action, sa localité, ses référents",
"where" : "parentModuleUrl",
"path" : "/js/dynForm/project2.js",
......@@ -69,17 +85,17 @@
"inputType" : "hidden",
"value" : "ficheAction"
},
"links[answers]" : {
"inputType" : "hidden"
},
"parent[id]" : {
"inputType" : "hidden",
"eval" : "contextData.id"
"inputType" : "hidden"
},
"parent[type]" : {
"inputType" : "hidden",
"eval" : "contextData.type"
"inputType" : "hidden"
},
"parent[slug]" : {
"inputType" : "hidden",
"eval" : "contextData.slug"
"inputType" : "hidden"
}
}
},
......@@ -89,7 +105,19 @@
"i:section2 c:nametext > label" : "Titre de votre Action"
},
"presetValue" : {
"public" : false
"public" : false,
"links[answers]" : {
"eval" : "answerId"
},
"parent[id]" : {
"eval" : "contextData.id"
},
"parent[type]" : {
"eval" : "contextData.type"
},
"parent[slug]" : {
"eval" : "contextData.slug"
}
},
"hide" : {
"urltext" : 1,
......
......@@ -333,6 +333,7 @@ class Form {
$res = false;
if( Yii::app()->session["userId"] == $form["author"] ||
Yii::app()->session["userId"] == $form["author"] ||
( !empty($form["links"]["members"][Yii::app()->session["userId"]]) &&
!empty($form["links"]["members"][Yii::app()->session["userId"]]["isAdmin"]) &&
$form["links"]["members"][Yii::app()->session["userId"]]["isAdmin"] == true /*&&
......
......@@ -62,7 +62,6 @@ $showStyle = ( $canAdmin ) ? "display:none; " : "";
$pageParams = array(
"adminAnswers"=>$answer,
"adminForm"=>$adminForm,
"answers" => $answer['answers'][$answer["formId"]]['answers'],
"form" => $form,
"user" => $user,
"prioKey" => @$adminForm['key'],
......@@ -70,6 +69,8 @@ $pageParams = array(
"canSuperAdmin" => $canSuperAdmin,
"session"=>$session
);
if(isset($answer['answers']))
$pageParams["answers"] = $answer['answers'][$answer["formId"]]['answers'];
$ct = 0;
$showHide = "";
......
......@@ -50,14 +50,14 @@ HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->theme->baseUrl);
}else { ?>
<div class="container col-xs-12 padding-20" >
<div id="surveyContent" class="formChart col-xs-offset-1 col-xs-10 padding-bottom-20" >
<div id="surveyContent" class="formChart padding-bottom-20" >
<div id="surveyDesc" class="col-xs-offset-1 col-xs-10">
<div id="surveyDesc" class="">
<p class="text-center"><?php echo $form["description"] ?></p>
</div>
<?php } ?>
<div id="surveyBtn" class="margin-top-15 col-xs-offset-1 col-xs-10"></div>
<div id="surveyBtn" class="margin-top-15 "></div>
<form id="ajaxFormModal"></form>
</div>
......
......@@ -45,11 +45,11 @@ HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->theme->baseUrl);
?>
<style type="text/css">
.img-circle{border:2px solid #666;margin-left: 20px;}
.formStep{}
</style>
<div class="col-xs-12 text-center margin-bottom-20" >
<div class="col-xs-3 text-center">
<div class="col-xs-3 formStep text-center">
<?php
echo "<h4>AUTEUR</h4>";
echo "<a target='_blank' href='".Yii::app()->createUrl("costum/co/index/id/ctenat#@".@$user["username"])."'>";
......@@ -58,7 +58,7 @@ HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->theme->baseUrl);
?>
</div>
<div class="col-xs-3 text-center">
<div class="col-xs-3 formStep text-center">
<?php
if( isset($answers["organization"]) ){
$orga = Element::getByTypeAndId( $answers["organization"]["type"] , $answers["organization"]["id"] );
......@@ -67,11 +67,15 @@ HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->theme->baseUrl);
if(isset($orga["profilThumbImageUrl"]))
echo "<img src='".Yii::app()->createUrl($orga["profilThumbImageUrl"])."' class='img-circle'/>";
echo "<h4>".$orga["name"]."</h4></a>";
} else {
echo "<h4>ORGANISATION<br/></h4>";
echo "<i class='fa fa-4x fa-question-circle-o'></i>";
}
?>
</div>
<div class="col-xs-3 text-center">
<div class="col-xs-3 formStep text-center">
<?php
if(isset($answers["project"])){
$project = Element::getByTypeAndId( $answers["project"]["type"] , $answers["project"]["id"] );
......@@ -80,23 +84,33 @@ HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->theme->baseUrl);
if(isset($project["profilThumbImageUrl"]))
echo "<img src='".Yii::app()->createUrl($project["profilThumbImageUrl"])."' class='img-circle'/>";
echo "<h4>".$project["name"]."</h4></a>";
}else {
echo "<h4>PROJET<br/></h4>";
echo "<i class='fa fa-4x fa-question-circle-o'></i>";
}
?>
</div>
<div class="col-xs-3 text-center">
<div class="col-xs-3 formStep text-center">
<?php
$tags = array();
if(isset($answers["caracter"])){
$tags = array_merge($tags,$answers["caracter"]["actionPrincipal"],
$answers["caracter"]["actionSecondaire"],
$answers["caracter"]["cibleDDPrincipal"],
$answers["caracter"]["cibleDDSecondaire"]);
if(isset($answers["caracter"]) ){
if(is_array($answers["caracter"]["actionPrincipal"]))
$tags = array_merge($tags,$answers["caracter"]["actionPrincipal"]);
if(is_array($answers["caracter"]["actionSecondaire"]))
$tags = array_merge($tags,@$answers["caracter"]["actionSecondaire"]);
if(is_array($answers["caracter"]["cibleDDPrincipal"]))
$tags = array_merge($tags,@$answers["caracter"]["cibleDDPrincipal"]);
if(is_array($answers["caracter"]["cibleDDSecondaire"]))
$tags = array_merge($tags,@$answers["caracter"]["cibleDDSecondaire"]);
echo "<br/>";
foreach ($tags as $i => $t) {
echo "<span class='badge bg-red' style='margin-bottom:3px;' >#".$t."</span><br/>";
}
}else {
echo "<h4>CARACTERISATION<br/></h4>";
echo "<i class='fa fa-4x fa-question-circle-o'></i>";
}
?>
</div>
......@@ -135,13 +149,23 @@ foreach ( $form[ "scenario" ] as $step => $dynF ) {
if(@$answers[$step]){
$editBtn = "";
if( isset($dynF["saveElement"]) )
$editBtn = "<a href='javascript:' data-form='".$step."' data-step='".$step."' data-type='".$answers[$step]["type"]."' data-id='".$answers[$step]["id"]."' class='editStep btn btn-default'><i class='fa fa-pencil'></i></a>";
else if(!isset($dynF["arrayForm"]))
{
if( isset($answers[$step]["type"] ) )
{
$editBtn = "<a href='javascript:' data-form='".$step."' data-step='".$step."' data-type='".$answers[$step]["type"]."' data-id='".$answers[$step]["id"]."' class='editStep btn btn-default'><i class='fa fa-pencil'></i></a>";
}
else
$editBtn = "<a href='javascript:' data-form='".$step."' data-step='".$step."' class='createStep btn btn-default'><i class='fa fa-pencil'></i></a>";
}
else if(!isset($dynF["arrayForm"]))
{
$editBtn = ( !empty($user) && (string)$user["_id"] == Yii::app()->session["userId"] )
? "<a href='javascript:' data-form='".$step."' data-step='".$step."' class='editStep btn btn-default'><i class='fa fa-pencil'></i></a>"
: "";
}
$titleIcon = ( isset($dynF['icon']) )? "<i class='fa ".@$dynF['icon']." ".@$dynF['titleClass']."'></i>" : "";
......@@ -261,74 +285,77 @@ foreach ( $form[ "scenario" ] as $step => $dynF ) {
//the scene is dynform.js : ex: project, organization
else if ( isset($dynF["saveElement"]) )
{
$el = Element::getByTypeAndId( $answers[$step]["type"] , $answers[$step]["id"] );
echo '<tr>';
echo "<td> ".Yii::t("common","Name")."</td>";
echo "<td> <a target='_blank' class='btn btn-default' href='".Yii::app()->createUrl("#@".@$el["slug"]).".view.detail'>".$el["name"]."</a></td>";
echo '</tr>';
if( isset($answers[$step]["type"])) {
$el = Element::getByTypeAndId( $answers[$step]["type"] , $answers[$step]["id"] );
if(isset($el["type"])){
echo '<tr>';
echo "<td>".Yii::t("common","Type")."</td>";
echo "<td>".$el["type"]."</td>";
echo "<td> ".Yii::t("common","Name")."</td>";
echo "<td> <a target='_blank' class='btn btn-default' href='".Yii::app()->createUrl("#@".@$el["slug"]).".view.detail'>".$el["name"]."</a></td>";
echo '</tr>';
}
if(isset($el["description"])){
echo '<tr>';
echo "<td>".Yii::t("common", "Description")."</td>";
echo "<td>".$el["description"]."</td>";
echo '</tr>';
}
if(isset($el["type"])){
echo '<tr>';
echo "<td>".Yii::t("common","Type")."</td>";
echo "<td>".$el["type"]."</td>";
echo '</tr>';
}
if(isset($el["tags"])){
echo '<tr>';
echo "<td>".Yii::t("common","Tags")."</td>";
echo "<td>";
$it=0;
foreach($el["tags"] as $tags){
if($it>0)
echo ", ";
echo "<span class='text-red'>#".$tags."</span>";
$it++;
}
echo "</td>";
echo '</tr>';
}
if(isset($el["description"])){
echo '<tr>';
echo "<td>".Yii::t("common", "Description")."</td>";
echo "<td>".$el["description"]."</td>";
echo '</tr>';
}
if(isset($el["shortDescription"])){
echo '<tr>';
echo "<td>".Yii::t("common","Short description")."</td>";
echo "<td>".$el["shortDescription"]."</td>";
echo '</tr>';
}
if(isset($el["tags"])){
echo '<tr>';
echo "<td>".Yii::t("common","Tags")."</td>";
echo "<td>";
$it=0;
foreach($el["tags"] as $tags){
if($it>0)
echo ", ";
echo "<span class='text-red'>#".$tags."</span>";
$it++;
}
echo "</td>";
echo '</tr>';
}
if(isset($el["email"])){
echo '<tr>';
echo "<td>".Yii::t("common","Email")."</td>";
echo "<td>".$el["email"]."</td>";
echo '</tr>';
}
if(!empty($el["profilThumbImageUrl"])){
echo '<tr>';
echo "<td>".Yii::t("common","Profil image")." </td>";
echo "<td><img src='".Yii::app()->createUrl($el["profilThumbImageUrl"])."' class='img-responsive'/></td>";
echo '</tr>';
}
if(isset($el["shortDescription"])){
echo '<tr>';
echo "<td>".Yii::t("common","Short description")."</td>";
echo "<td>".$el["shortDescription"]."</td>";
echo '</tr>';
}
if(isset($el["email"])){
echo '<tr>';
echo "<td>".Yii::t("common","Email")."</td>";
echo "<td>".$el["email"]."</td>";
echo '</tr>';
}
if(!empty($el["profilThumbImageUrl"])){
echo '<tr>';
echo "<td>".Yii::t("common","Profil image")." </td>";
echo "<td><img src='".Yii::app()->createUrl($el["profilThumbImageUrl"])."' class='img-responsive'/></td>";
echo '</tr>';
}
if(isset($el["url"])){
echo '<tr>';
echo "<td>".Yii::t("common","Website URL")."</td>";
echo "<td><a href='".$el["url"]."'>".$el["url"]."</a></td>";
echo '</tr>';
}
if(isset($el["url"])){
echo '<tr>';
echo "<td>".Yii::t("common","Website URL")."</td>";
echo "<td><a href='".$el["url"]."'>".$el["url"]."</a></td>";
echo "<td>".Yii::t("common","Edit")."</td>";
echo "<td>".$editBtn."</td>";
echo '</tr>';
}
echo '<tr>';
echo "<td>".Yii::t("common","Edit")."</td>";
echo "<td>".$editBtn."</td>";
echo '</tr>';
}
echo "</tbody></table></div>";
......@@ -382,6 +409,13 @@ $(document).ready(function() {
$(this).html( dataHelper.markdownToHtml( $(this).html() ) );
});
$('.createStep').off().click(function() {
mylog.log('.createStep ',$(this).data("form"));
var dfCostum = ( form[scenarioKey][ $(this).data("form") ]['costum']) ? form[scenarioKey][ $(this).data("form") ]['costum']['dynFormCostum'] : null;
dyFObj.openForm( $(this).data("form"), null, true, null,dfCostum );
});
$('.editStep').off().click(function() {
//alert('.editStep : '+$(this).data("form"));
//editing typed elements like projects, organizations
......
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