Commit 72fe6e6d authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

Merge branch 'qa'

parents 3be782b4 d8c5335a
<style type="text/css">
.rdo-grp {
/*position: absolute;
top: calc(50% - 10px);*/
}
.rdo-grp label {
cursor: pointer;
-webkit-tap-highlight-color: transparent;
padding: 6px 8px;
border-radius: 20px;
float: left;
transition: all 0.2s ease;
}
.rdo-grp label:hover {
background: rgba(125,100,247,0.06);
}
.rdo-grp label:not(:last-child) {
margin-right: 16px;
}
.rdo-grp label span {
vertical-align: middle;
}
.rdo-grp label span:first-child {
position: relative;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
background: #e8eaed;
border-radius: 50%;
transition: all 0.2s ease;
margin-right: 8px;
}
.rdo-grp label span:first-child:after {
content: '';
position: absolute;
width: 16px;
height: 16px;
margin: 2px;
background: #fff;
border-radius: 50%;
transition: all 0.2s ease;
}
.rdo-grp label:hover span:first-child {
background: #7d64f7;
}
.rdo-grp input {
display: none;
}
.rdo-grp input:checked + label span:first-child {
background: #7d64f7;
}
.rdo-grp input:checked + label span:first-child:after {
transform: scale(0.5);
}
.effect-1{border: 0; padding: 7px 0; border-bottom: 1px solid #ccc;}
.effect-1 ~ .focus-border{position: absolute; bottom: 0; left: 0; width: 0; height: 2px; background-color: #3399FF; transition: 0.4s;}
.effect-1:focus ~ .focus-border{width: 100%; transition: 0.4s;}
.paramsonebtn , .paramsonebtnP {
font-size: 17px;
display: none;
padding: 5px;
}
.paramsonebtn:hover {
color: red;
}
.paramsonebtnP:hover {
color: blue;
}
.thradio:hover .paramsonebtn, .thradio:hover .paramsonebtnP {
display: inline-block;
}
.effect-1:focus {
outline: none !important;
}
</style>
<?php
$value = (!empty($answers)) ? " value='".$answers."' " : "";
$inpClass = " saveOneByOne";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"list" => [ ],
"tofill" => [ ],
"placeholdersradio" => [ ],
"type" => [
"simple" => "Sans champ de saisie",
"cplx" => "Avec champ de saisie"
]
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["list"]) ) {
$paramsData["list"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["list"];
foreach ($paramsData["list"] as $k => $v) {
if(isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["tofill"][$v]) ){
$paramsData["tofill"] += array($v => Yii::app()->session["costum"]["form"]["params"][$kunik]["tofill"][$v]);
} else {
$paramsData["tofill"] += [$v => "simple"];
}
}
}
}
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["list"]) ) {
$paramsData["list"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["list"];
foreach ($paramsData["list"] as $k => $v) {
if(isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholdersradio"][$v]) ){
$paramsData["placeholdersradio"] += array($v => Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholdersradio"][$v]);
} else {
$paramsData["placeholdersradio"] += [$v => ""];
}
}
}
}
if($mode == "r"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php echo $answers; ?>
</div>
<?php
}else{
?>
<div class="" style="padding-top: 30px;">
<label class="form-check-label" for="<?php echo $key ?>"><h4 style="color: <?php echo ($titleColor) ? $titleColor : "black"; ?>;"><?php echo $label.$editQuestionBtn.$editParamsBtn ?></h4></label>
<?php
if( !isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['list']) ) {
echo "<br/><span class='text-red text-center'><i class='fa fa-warning fa-2x'></i> THIS FIELD HAS TO BE CONFIGURED FIRST ".$editParamsBtn."</span>";
} else {
?>
<div class="rdo-grp">
<table>
<?php
foreach (Yii::app()->session["costum"]["form"]["params"][$kunik]["list"] as $ix => $lbl) {
$ckd = "";
if(isset($answer["answers"][$form["id"]][$kunik]["value"]) && $answer["answers"][$form["id"]][$kunik]["value"] == $lbl)
$ckd = "checked";
?>
<tr class="thradio"><th >
<input data-id="<?php echo $kunik ?>" class=" radioCo " id="<?php echo $kunik.$ix ?>" data-form='<?php echo $form["id"] ?>' <?php echo $ckd?> type="radio" name="<?php echo $kunik ?>"
data-type="<?php if(count($paramsData["tofill"]) != 0){
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $key){
if($value == "cplx"){
echo "cplx";
}else {
echo "simple";
}
}
}
}
?>"
value="<?php echo $lbl ?>" />
<label for="<?php echo $kunik.$ix ?>"><span></span><span><?php echo $lbl ?>
<div style="position: relative; display: inline-block;">
<?php if(count($paramsData["tofill"]) != 0){
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $key && $value == "cplx"){
?>
<input class="effect-1 inputRadioCo" data-id="<?php echo $kunik ?>" data-form='<?php echo $form["id"] ?>' type="text" data-imp="<?php echo $key; ?>" placeholder="<?php echo $paramsData['placeholdersradio'][$key]; ?>" style="display: inline-block !important; position: relative;"
value="<?php
if(isset($answer["answers"][$form["id"]][$kunik]["textsup"]) && isset($answer["answers"][$form["id"]][$kunik]["value"]) && $answer["answers"][$form["id"]][$kunik]["value"] == $key ){
echo $answer["answers"][$form["id"]][$kunik]["textsup"] ;
} ?>"
>
<span class="focus-border"></span>
</div>
<?php
}
}
}
?>
<?php
if($canEdit){
echo " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl paramsonebtn editone".$kunik."Params".$ix." '><i class='fa fa-cog'></i> </a>";
if(count($paramsData["tofill"]) != 0){
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $key){
if($value == "cplx"){
echo " <a alt='placeholder' href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl paramsonebtnP editonep".$kunik."Params".$ix." '><i class='fa fa-pencil'></i> </a>";
}
}
}
}
}
?>
</span></label>
</th></tr>
<?php } ?>
</table>
</div>
<?php }?>
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
</div>
<script type="text/javascript">
var <?php echo $kunik ?>Data = <?php echo json_encode( (isset($answer["answers"][$kunik])) ? $answer["answers"][$kunik] : null ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsData = <?php echo json_encode( $paramsData ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsPlace = "";
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/multiCheckbox.php");
answer = {};
$('.radioCo').change(function(){
if($(this).data("type") == "simple"){
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = {"value" : $(this).val(), "type" : "simple"};
dataHelper.path2Value(answer , function(params) {
} );
} else if ($(this).data("type") == "cplx"){
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = {"value" : $(this).val(), "type" : "cplx", "textsup" : $('input[data-imp="' + $(this).val() + '"]').val()};
dataHelper.path2Value(answer , function(params) {
} );
}
});
$('.inputRadioCo').keyup(function(){
if($('input[value="' + $(this).data("imp") + '"]').is(':checked')) {
console.log('here');
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = {"value" : $(this).data("imp"), "type" : "cplx", "textsup" : $(this).val()};
dataHelper.path2Value(answer , function(params) {
} );
}
})
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
list : {
inputType : "array",
label : "Liste de bouton radio",
values : sectionDyf.<?php echo $kunik ?>ParamsData.list
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
<?php if(count($paramsData["list"]) != 0){
foreach ($paramsData["list"] as $key => $value) {
// if($lbl == $key){
// if($value == "cplx"){
?>
sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?> = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
tofill : {
inputType : "select",
label : "Bouton radio avec champ de saisie",
options : sectionDyf.<?php echo $kunik ?>ParamsData.type,
values : "<?php echo (isset($paramsData["tofill"][$value])) ? $paramsData["tofill"][$value] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?>.jsonSchema.properties , function(ko,valo) {
$.each(sectionDyf.<?php echo $kunik ?>ParamsData.tofill, function(ke, va) {
if(ke == "<?php echo $value; ?>"){
var azerazer = ke.toString();
sectionDyf.<?php echo $kunik ?>ParamsData.tofill[azerazer] = $("#"+ko).val();
}
})
tplCtx.value = sectionDyf.<?php echo $kunik ?>ParamsData.tofill;
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
$(".editone<?php echo $kunik ?>Params<?php echo $key ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+'.tofill';
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?>,null, sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?>);
});
<?php
}
}
// }
// }
?>
<?php if(count($paramsData["list"]) != 0){
foreach ($paramsData["list"] as $key => $value) {
// if($lbl == $key){
if($paramsData["tofill"][$value] == "cplx"){
?>
sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?> = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
placeholdersradio : {
inputType : "text",
label : "Modifier les textes à l'interieur du champs de saisie",
values : "<?php echo $paramsData["placeholdersradio"][$value]; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?>.jsonSchema.properties , function(kk,vall) {
$.each(sectionDyf.<?php echo $kunik ?>ParamsData.placeholdersradio, function(ke, va) {
if(ke == "<?php echo $value; ?>"){
var azerazer = ke.toString();
sectionDyf.<?php echo $kunik ?>ParamsData.placeholdersradio[azerazer] = $("#"+kk).val();
}
})
tplCtx.value = sectionDyf.<?php echo $kunik ?>ParamsData.placeholdersradio;
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
$(".editonep<?php echo $kunik ?>Params<?php echo $key ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+'.placeholdersradio';
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?>,null, sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?>);
});
<?php
}
}
}
// }
?>
$(".edit<?php echo $kunik ?>Params").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+'.list';
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
});
</script>
<?php } ?>
\ No newline at end of file
<style type="text/css">
.rdo-grp label {
cursor: pointer;
-webkit-tap-highlight-color: transparent;
padding: 6px 8px;
border-radius: 20px;
float: left;
transition: all 0.2s ease;
}
.input-grp label span:first-child {
position: relative;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
background: #e8eaed;
/*background: rgba(125,100,247,0.06);*/
border-radius: 50%;
transition: all 0.2s ease;
margin-right: 8px;
}
.input-grp :hover {
background: rgba(125,100,247,0.06);
}
.effect-2{border: 0; padding: 7px 0; border-bottom: 2px solid #ccc;}
.effect-2 ~ .focus-border{position: absolute; bottom: 0; left: 0; width: 0; height: 2px; background-color: #3399FF; transition: 0.4s;}
.effect-2:focus ~ .focus-border{width: 100%; transition: 0.4s;}
.paramsonebtn , .paramsonebtnP {
font-size: 17px;
display: none;
padding: 5px;
}
.paramsonebtn:hover {
color: red;
}
.paramsonebtnP:hover {
color: blue;
}
.thradio:hover .paramsonebtn, .thradio:hover .paramsonebtnP {
display: inline-block;
}
.effect-2:focus {
outline: none !important;
}
</style>
<?php
$value = (!empty($answers)) ? " value='".$answers."' " : "";
$inpClass = "form-control";
if($saveOneByOne)
$inpClass .= " saveOneByOne";
if($mode == "r"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php echo $answers; ?>
</div>
<?php
}else{
?>
<div class="input-grp" style="position: relative; padding-top: 30px;">
<label for="<?php echo $key ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<br/>
<!-- <input type="" class="<?php echo $inpClass ?> effect-2 " id="<?php echo $key ?>" aria-describedby="<?php echo $key ?>Help" placeholder="<?php echo (isset($placeholder)) ? $placeholder : '' ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value ?> >
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?> -->
<input class="effect-2" type="text" placeholder="Placeholder Text" style="position: relative; width: 100%;">
<span class="focus-border"></span>
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/text.php");
});
</script>
<?php } ?>
\ No newline at end of file
......@@ -88,7 +88,7 @@ if( isset( $form["inputs"] ) ){ ?>
}
}
// var_dump($answerPath);
//var_dump($answerPath);
// var_dump($answers);
$p = [
"input" => $input,
......
......@@ -9,8 +9,11 @@ $paramsData = [ "options" => [ ] ];
if( isset(Yii::app()->session["costum"]["form"]["params"][$key]) )
$paramsData = Yii::app()->session["costum"]["form"]["params"][$key];
if(!isset($options))
$options = Yii::app()->session["costum"]["form"]["params"][$key]['options'];
if(!isset($options)){
if(isset(Yii::app()->session["costum"]["form"]["params"][$key]['options'])){
$options = Yii::app()->session["costum"]["form"]["params"][$key]['options'];