Commit 4b31c39f authored by Anatole Rakotoson's avatar Anatole Rakotoson
Browse files

sommom

parent 552d1eb1
<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;}
</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" => [ ]
];
$optionsSup = [];
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 $key => $value) {
$optionsSup += array($value => $value );
}
}
}
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["tofill"]) ) {
$paramsData["tofill"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["tofill"];
foreach ($paramsData["tofill"] as $k => $v) {
if(isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholders"][$v]) ){
$paramsData["placeholdersradio"] += array($v => Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholders"][$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="form-check">
<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) {
$value = "";
if(!empty($answer) && isset($answer["answers"][$form["id"]][$kunik.$ix]) && $answer["answers"][$form["id"]][$kunik.$ix] )
$value = "checked";
else if(!empty($answer) && isset($answer["answers"][$kunik]) && $answer["answers"][$kunik] )
$value = "checked";
?>
<tr><th>
<input data-id="<?php echo $kunik ?>" class=" radioCo " id="<?php echo $kunik.$ix ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value?> type="radio" name="<?php echo $kunik ?>"
data-type="<?php if(count($paramsData["tofill"]) != 0){
$tr = true;
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $value){
echo "cplx";
$tr = false;
}
}
if($tr){
echo "simple";
}
} else {
echo "simple";
}
?>"
value="<?php echo $lbl ?>" />
<label for="<?php echo $kunik.$ix ?>"><span></span><span><?php echo $lbl ?>
<?php if(count($paramsData["tofill"]) != 0){
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $value){
?>
<input class="effect-1" type="text" placeholder="<?php echo $paramsData['placeholdersradio'][$value]; ?>" style="display: inline-block !important;">
<?php
}
}
}
?>
</span></label>
</th></tr>
<?php } ?>
</table>
<?php //var_dump($paramsData["tofill"]); ?>
</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 ?>optSup = <?php echo json_encode($optionsSup); ?> ;
sectionDyf.<?php echo $kunik ?>ParamsPlace = {
labels : <?php echo json_encode( $paramsData["tofill"] ); ?>,
placeholders : <?php echo json_encode( $paramsData["placeholdersradio"] ); ?>
};
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 = $(this).val();
dataHelper.path2Value(answer , function(params) {
} );
} else if ($(this).data("type") == "cplx"){
}
});
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
},
tofill : {
inputType : "selectMultiple",
label : "Bouton radio avec champ de saisie",
options : sectionDyf.<?php echo $kunik ?>optSup,
values : sectionDyf.<?php echo $kunik ?>ParamsData.tofill
},
placeholdersradio : {
inputType : "properties",
labelKey : "Bouton radio",
labelValue : "Texte dans le champs",
label : "Modifier les textes à l'interieur du champs de saisie",
values : sectionDyf.<?php echo $kunik ?>ParamsPlace.placeholders
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value[k] = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = 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();
} );
}
}
}
};
$(".edit<?php echo $kunik ?>Params").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
//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
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
<?php <?php
if( count($answers)>0 ){ ?> if( count($answers)>0 ){ ?>
<tr> <tr style="font-size: 14px;">
</th> </th>
<?php <?php
......
...@@ -147,7 +147,7 @@ $actualNbr1 = 0; ...@@ -147,7 +147,7 @@ $actualNbr1 = 0;
<?php <?php
if( count($answers)>0 ){ ?> if( count($answers)>0 ){ ?>
<tr> <tr style="font-size: 14px;">
</th> </th>
<?php <?php
......
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