Commit dfd8ef3b authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

add delete steps process

parent cd7310f7
......@@ -91,8 +91,8 @@ var oformParams = {
checked : true },
},
save : function (formData) {
mylog.log('oformParams save tplCtx formData', formData)
tplCtx.collection = "forms";
mylog.log('oformParams save tplCtx formData', formData)
tplCtx.collection = "forms";
tplCtx.path = "allToRoot";
tplCtx.value = {};
$.each( oformParams.jsonSchema.properties , function(k,val) {
......@@ -127,57 +127,43 @@ var addStepParams = {
description : "Un formulaire peut contenir une ou plusieurs étape, chacun peut etre considérée comme un sous formulaire",
icon : "fa-wpforms",
properties : {
subForms : {
inputType : "array",
label : "Nommé chaque étape de votre questionnaire",
//subLabel : "Vous remplirez les question de chaques étapes par la suite",
value : []
name : {
label : "Nommé cette étape de votre questionnaire",
}
},
save : function (formData) {
mylog.log('addStepParams save tplCtx formData', formData)
mylog.log('addStepParams save formData', formData)
tplCtx.collection = "forms";
tplCtx.path = "subForms";
tplCtx.value = [];
var now = new Date();
var cx = ""+now.getDate() + (now.getMonth()+1) + now.getFullYear()+"_"+now.getHours()+now.getMinutes();
$.each( formData.subForms, function(ix,fName) {
mylog.log("addStepParams check sub Form",fName, "<?php echo $el["slug"] ?>"+cx);
if($.inArray(fName, subForms) < 0 ){
var newFormId = "<?php echo $el["slug"] ?>"+cx;
tplCtx.value.push(newFormId);
var newForm = {
collection : "forms",
value : {
id : newFormId,
name : fName,
type : "openForm",
inputs : {}
}
};
dataHelper.path2Value( newForm, function() {
mylog.log("addStepParams created new sub Form",newFormId);
} );
} else
tplCtx.value.push(newFormId);
})
mylog.log("addStepParams save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
urlCtrl.loadByHash(location.hash);
} );
}
tplCtx.value = subForms;
var now = new Date();
var cx = ""+now.getDate() + (now.getMonth()+1) + now.getFullYear()+"_"+now.getHours()+now.getMinutes();
var newFormId = "<?php echo $el["slug"] ?>"+cx+"_"+tplCtx.value.length;
tplCtx.value.push(newFormId);
var newForm = {
collection : "forms",
value : {
id : newFormId,
name : formData.name,
type : "openForm",
inputs : {}
}
};
mylog.log("addStepParams new sub Form",newForm);
dataHelper.path2Value( newForm, function() {
mylog.log("addStepParams created new sub Form",newFormId);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
mylog.log("addStepParams save tplCtx",tplCtx);
dataHelper.path2Value( tplCtx, function(params) {
urlCtrl.loadByHash(location.hash);
} );
}
} );
}
}
};
......
......@@ -116,13 +116,11 @@ if( isset($form["subForms"]) && count($form["subForms"]) > 1 ) {
if( !empty($forms[$v]) )
{
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$forms[$v]["name"].'</h1>';
echo "<div class='text-center'>";
if(isset($this->costum["cms"][$forms[$v]["id"]."desc"]))
echo htmlentities($this->costum["cms"][$forms[$v]["id"]."desc"]);
else
echo "<span style='color:#aaa'>* section description</span>";
if(@$canEditForm)
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='".@$forms[$v]["id"]."desc' data-type='textarea' data-markdown='1' data-path='costum.cms.".@$forms[$v]["id"]."desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>";
echo "<div class='text-center col-xs-12'>";
echo '<a href="javascript:;" class="editFormBtn" data-id="'.$forms[$v]["_id"].'" data-formid="'.$v.'" ><i class="fa fa-pencil text-dark"></i></a> ';
echo '<a href="javascript:;" class="deleteFormBtn" data-id="'.$forms[$v]["_id"].'" data-formid="'.$v.'" ><i class="fa fa-trash text-red"></i></a> ' ;
echo "</div>";
//echo "<div class='markdown'>";
......@@ -154,15 +152,12 @@ if( isset($form["subForms"]) && count($form["subForms"]) > 1 ) {
</div>
<?php } else if( isset($form["subForms"]) && count($form["subForms"]) == 1 ) {
echo "<div class='col-xs-12'>";
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$forms[$v]["name"].'</h1>';
echo "<div class='text-center'>";
if(isset($this->costum["cms"][$forms[$v]["id"]."desc"]))
echo htmlentities($this->costum["cms"][$forms[$v]["id"]."desc"]);
else
echo "<span style='color:#aaa'>* section description</span>";
if(@$canEditForm)
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='".@$forms[$v]["id"]."desc' data-type='textarea' data-markdown='1' data-path='costum.cms.".@$forms[$v]["id"]."desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>";
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$forms[$form["subForms"][0]]["name"].'</h1>';
echo "<div class='text-center col-xs-12'>";
echo '<a href="javascript:;" class="editFormBtn" data-id="'.$forms[$form["subForms"][0]]["_id"].'" data-formid="'.$form["subForms"][0].'"><i class="fa fa-pencil text-dark"></i></a> ';
echo '<a href="javascript:;" class="deleteFormBtn" data-id="'.$forms[$form["subForms"][0]]["_id"].'" data-formid="'.$form["subForms"][0].'"><i class="fa fa-trash text-red"></i></a> ';
echo "</div>";
//echo "<div class='markdown'>";
echo "<div class=''>";
......@@ -185,4 +180,74 @@ if( isset($form["subForms"]) && count($form["subForms"]) > 1 ) {
echo "<br/><br/><i class='fa fa-5x fa-wpforms'></i>";
echo "</div>";
} ?>
</div>
\ No newline at end of file
</div>
<script type="text/javascript">
var formsData = <?php echo (!empty($forms)) ? json_encode( $forms ) : "null"; ?>;
jQuery(document).ready(function() {
mylog.log("render","modules/survey/views/tpls/forms/wizard.php");
$('.editFormBtn').off().click( function(){
tplCtx.id = $(this).data("id");
tplCtx.collection = "forms";
dyFObj.openForm( subformDF , null, formsData[$(this).data("formid")] )
});
$('.deleteFormBtn').off().click( function(){
tplCtx.id = $(this).data("id");
bootbox.dialog({
title: "Confirmez la suppression",
message: "<span class='text-red bold'><i class='fa fa-warning'></i> Cette action sera irréversible</span>",
buttons: [
{
label: "Ok",
className: "btn btn-primary pull-left",
callback: function() {
getAjax("",baseUrl+"/survey/form/delete/id/"+tplCtx.id,function(res){
if(res.result)
toastr.success("Le form été supprimée avec succès");
else
toastr.error(res.msg);
//urlCtrl.loadByHash(location.hash);
},"html");
}
},
{
label: "Annuler",
className: "btn btn-default pull-left",
callback: function() {}
}
]
});
});
});
var subformDF = {
jsonSchema : {
title : "Configurer cette section",
description : "Tout est possible, faut juste poser les bonnes questions",
icon : "fa-question",
properties : {
name : { label : "Nom du formulaire"}
},
save : function (formData) {
mylog.log('save tplCtx formData', formData)
delete formData.collection ;
tplCtx.path = "name";
tplCtx.value = formData.name;
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
urlCtrl.loadByHash(location.hash);
} );
}
}
}
};
</script>
\ No newline at end of file
Supports Markdown
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