Commit 7526d2ea authored by Anatole Rakotoson's avatar Anatole Rakotoson
Browse files

sommom multiradio multitext

parent c56310ea
<?php
$value = (!empty($answers)) ? " value='".$answers."' " : "";
$inpClass = "form-control";
if($type == "tags")
$inpClass = "select2TagsInput";
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="form-group">
<label for="<?php echo $key ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<br/><input type="<?php echo (!empty($type)) ? $type : 'text' ?>" class="<?php echo $inpClass ?>" 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 } ?>
</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
......@@ -59,39 +59,69 @@
.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;
}
</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" => [ ]
"placeholdersradio" => [ ],
"type" => [
"simple" => "Sans champ de saisie",
"cplx" => "Avec champ de saisie"
]
];
$optionsSup = [];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["list"]) ){
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 );
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]["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]);
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 => ""];
}
......@@ -99,6 +129,15 @@ if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
}
}
if(count($paramsData["list"]) != 0){
foreach ($paramsData["list"] as $key => $value) {
// if($lbl == $key){
if($paramsData["tofill"][$value] == "cplx"){
var_dump($paramsData["placeholdersradio"][$value]);
}}}
if($mode == "r"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
......@@ -108,8 +147,10 @@ if($mode == "r"){ ?>
<?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>
<label class="form-check-label" for="<?php echo $key ?>"><h4 style="color: #043743;"><?php echo $label.$editQuestionBtn.$editParamsBtn ?></h4></label>
<?php
if( !isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['list']) ) {
......@@ -126,24 +167,21 @@ if($mode == "r"){ ?>
if(isset($answer["answers"][$form["id"]][$kunik]["value"]) && $answer["answers"][$form["id"]][$kunik]["value"] == $lbl)
$ckd = "checked";
?>
<tr><th>
<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){
$tr = true;
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $value){
echo "cplx";
$tr = false;
if($lbl == $key){
if($value == "cplx"){
echo "cplx";
}else {
echo "simple";
}
}
}
if($tr){
echo "simple";
}
} else {
echo "simple";
}
}
?>"
value="<?php echo $lbl ?>" />
......@@ -151,11 +189,11 @@ if($mode == "r"){ ?>
<?php if(count($paramsData["tofill"]) != 0){
foreach ($paramsData["tofill"] as $key => $value) {
if($lbl == $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 $value; ?>" placeholder="<?php echo $paramsData['placeholdersradio'][$value]; ?>" style="display: inline-block !important;"
<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;"
value="<?php
if(isset($answer["answers"][$form["id"]][$kunik]["textsup"]) && isset($answer["answers"][$form["id"]][$kunik]["value"]) && $answer["answers"][$form["id"]][$kunik]["value"] == $value ){
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"] ;
} ?>"
......@@ -167,6 +205,29 @@ if($mode == "r"){ ?>
}
}
?>
<?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>
......@@ -188,12 +249,11 @@ if($mode == "r"){ ?>
<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"] ); ?>
};
sectionDyf.<?php echo $kunik ?>ParamsPlace = "";
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/multiCheckbox.php");
......@@ -221,18 +281,19 @@ jQuery(document).ready(function() {
$('.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",
......@@ -242,28 +303,15 @@ jQuery(document).ready(function() {
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);
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = getArray('.'+k+val.inputType);
tplCtx.value = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
......@@ -276,20 +324,154 @@ jQuery(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
//location.reload();
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");
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
......@@ -278,6 +278,8 @@
if(dyFObj.closeForm()){
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
}else{
location.reload();
}
// } );
});
......
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