Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pixel Humain
survey
Commits
9d80a875
Commit
9d80a875
authored
Apr 10, 2020
by
Raph El
Browse files
Form : hotfix parentSlug + add fct getFirstParentForm
parent
e0ff5392
Changes
4
Hide whitespace changes
Inline
Side-by-side
controllers/answer/DirectoryAction.php
View file @
9d80a875
...
...
@@ -25,8 +25,9 @@ class DirectoryAction extends CAction
$res
[
"count"
]
=
$answers
[
"count"
];
$res
[
"results"
]
=
$answerList
;
$res
[
"what"
]
=
(
isset
(
$params
[
"form"
][
"what"
]))
?
$params
[
"form"
][
"what"
]
:
"réponses"
;
$el
=
Slug
::
getElementBySlug
(
$res
[
"form"
][
"parentSlug"
]
);
$res
[
'el'
]
=
$el
[
"el"
];
//$el = Slug::getElementBySlug( $res["form"]["parentSlug"] );
//$el=Form::getFirstParentForm($res["form"]);
$res
[
'el'
]
=
Form
::
getFirstParentForm
(
$res
[
"form"
]);
//ce code ne marchera pas pour deux formulaire identaique , d'un meme slug
//TODO utiliser le parntForm Id en plus
$res
[
'canEdit'
]
=
(
isset
(
Yii
::
app
()
->
session
[
"userId"
])
&&
isset
(
$el
[
"type"
])
&&
isset
(
$el
[
"id"
])
)
?
...
...
controllers/form/GetAction.php
View file @
9d80a875
...
...
@@ -40,35 +40,8 @@ class GetAction extends CTKAction
}
}
}
// IS IT IMPORTANT TO OPEN A FORM WITHOUT AN ANSWER
// else if(!empty($form))
// {
// $controller->layout = "//layouts/mainSearch";
// $canEdit = false;
// if( isset(Yii::app()->session["userId"]) && isset($controller->costum["contextType"]) && isset($controller->costum["contextId"]) )
// $canEdit = Authorisation::canEditItem(Yii::app()->session["userId"],@$controller->costum["contextType"], @$controller->costum["contextId"]);
// //TODO if no canEdit et test exist then
// //redirect unTpl
// $params = ["canEdit" => $canEdit];
// if( isset($test) ){
// $params["tpl"]=$id;
// $params["test"]=$test;
// }
// if(isset($_GET["form"]))
// $params = Form::getDataForAnswer($params);
// $params['el'] = Slug::getElementBySlug( $params["parentForm"]["parentSlug"] )["el"];
// $tpl=(!empty($params["parentForm"]["tpl"])) ? $params["parentForm"]["tpl"] : "survey.views.tpls.forms.formWizard";
// }
//var_dump($params);exit;
}
if
(
Yii
::
app
()
->
request
->
isAjaxRequest
)
echo
$controller
->
renderPartial
(
$tpl
,
$params
,
true
);
else
...
...
models/Form.php
View file @
9d80a875
...
...
@@ -784,14 +784,15 @@ class Form {
else
$params
[
"formId"
]
=
(
isset
(
$form
[
"id"
]))
?
$form
[
"id"
]
:
Form
::
generateOpenForm
(
$el
[
"slug"
]
);
}
if
(
!
isset
(
$params
[
"el"
])
&&
!
empty
(
$answer
)
&&
isset
(
$answer
[
"parentSlug"
]))
$params
[
"el"
]
=
Slug
::
getElementBySlug
(
$answer
[
"parentSlug"
])[
"el"
];
//
if(!isset($params["el"]) && !empty($answer) && isset($answer["parentSlug"]))
//
$params["el"]=Slug::getElementBySlug($answer["parentSlug"])["el"];
if
(
!
isset
(
$params
[
"el"
])
&&
!
empty
(
$answer
)
&&
isset
(
$answer
[
"parent"
])
){
foreach
(
$answer
[
"parent"
]
as
$keyP
=>
$valP
)
{
$params
[
"el"
]
=
Element
::
getElementById
(
$keyP
,
$valP
[
"type"
],
null
,
array
()
);
}
if
(
!
isset
(
$params
[
"el"
])
&&
!
empty
(
$form
)
&&
isset
(
$form
[
"parent"
])
){
$params
[
"el"
]
=
self
::
getFirstParentForm
(
$form
);
// foreach ($form["parent"] as $keyP => $valP) {
// $params["el"]=Element::getElementById($keyP, $valP["type"], null, array() );
// }
}
$showForm
=
true
;
...
...
@@ -838,5 +839,18 @@ class Form {
return
$params
;
}
public
static
function
getFirstParentForm
(
$form
){
$parent
=
null
;
if
(
!
empty
(
$form
)
&&
isset
(
$form
[
"parent"
])
){
foreach
(
$form
[
"parent"
]
as
$keyP
=>
$valP
)
{
$parent
=
Element
::
getElementById
(
$keyP
,
$valP
[
"type"
],
null
,
array
()
);
if
(
!
empty
(
$parent
))
return
$parent
;
}
}
return
$parent
;
}
}
?>
\ No newline at end of file
views/tpls/forms/oforms.php
View file @
9d80a875
...
...
@@ -51,11 +51,11 @@ foreach ($forms as $fix => $f) {
</
a
>
-->
<?
php
if
(
isset
(
$f
[
'active'
]
)
&&
$f
[
'active'
]
==
true
)
{
?>
<a target='_blank' href='
costum/co/index/slug/
<?php
echo
$el
[
"slug"
]
?>
#answer.index.id.new.form.
<?php
echo
$fix
?>
' class="btn btn-xs btn-primary col-md-4 col-sm-12 bold">
<a target='_blank' href='#answer.index.id.new.form.
<?php
echo
$fix
?>
' class="btn btn-xs btn-primary col-md-4 col-sm-12 bold">
<i class='fa fa-file-text-o'></i> RÉPONDRE
</a>
<?php
}
else
{
?>
<a target='_blank' href='
costum/co/index/slug/
<?php
echo
$el
[
"slug"
]
?>
#form.edit.id.
<?php
echo
$fix
?>
' class="btn btn-xs btn-primary col-md-4 col-sm-12 bold">
<a target='_blank' href='#form.edit.id.
<?php
echo
$fix
?>
' class="btn btn-xs btn-primary col-md-4 col-sm-12 bold">
<i class='fa fa-pencil'></i> CONSTRUIRE
</a>
<?php
}
?>
...
...
@@ -87,11 +87,6 @@ jQuery(document).ready(function() {
},"html");
});
// $('.configBtn').off().on("click",function() {
// tplCtx.id = $(this).data("id");
// mylog.log( "configBtn", tplCtx.id );
// dyFObj.openForm( oformParams, null, formsData[$(this).data("id")] )
// });
$('.editFormBtn').off().click( function(){
tplCtx.id = $(this).data("id");
dyFObj.openForm( oform , null, formsData[$(this).data("id")] )
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment