Commit a54c4905 authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Modification du retour pour coller à l'envoie du serveur

parent ce5267e3
......@@ -470,6 +470,8 @@ class FormulairesController extends AppController {
$this->redirect($this->Referers->get());
}
debug($this->request->data);die;
$success = true;
$this->Formulaire->begin();
......@@ -583,9 +585,7 @@ class FormulairesController extends AppController {
}
}
// if ($this->request->params['action'] === 'edit') {
$this->getFields($id);
// }
$this->getFields($id);
$this->view = 'edit';
}
......@@ -740,7 +740,9 @@ class FormulairesController extends AppController {
// ];
// }
$this->set(compact('fields'));
$this->request->data['Formulaire']['form-container-formulaire'] = $fields['formulaire'];
$this->request->data['Formulaire']['form-container-coresponsable'] = $fields['coresponsable'];
$this->request->data['Formulaire']['form-container-soustraitant'] = $fields['soustraitant'];
}
......
......@@ -18,10 +18,9 @@
<!-- Corps du formulaire -->
<div id="form-container-coresponsable" class="form-container col-md-12">
<?php
// if ($this->request->params['action'] == 'edit' && !empty($fields['coresponsable'])) {
if (!empty($fields['coresponsable'])) {
if (!empty($this->request->data['Formulaire']['formulaire'])) {
echo $this->element('Formulaires/champDuFormulaire', [
'champs' => $fields['coresponsable']
'champs' => $this->request->data['Formulaire']['coresponsable']
]);
}
?>
......
......@@ -17,9 +17,9 @@
<!-- Corps du formulaire -->
<div id="form-container-formulaire" class="form-container col-md-12">
<?php
if ($this->request->params['action'] == 'edit' && !empty($fields['formulaire'])) {
if (!empty($this->request->data['Formulaire']['formulaire'])) {
echo $this->element('Formulaires/champDuFormulaire', [
'champs' => $fields['formulaire']
'champs' => $this->request->data['Formulaire']['formulaire']
]);
}
?>
......
......@@ -19,9 +19,9 @@
<!-- Corps du formulaire -->
<div id="form-container-soustraitant" class="form-container col-md-12">
<?php
if ($this->request->params['action'] == 'edit' && !empty($fields['soustraitant'])) {
if (!empty($this->request->data['Formulaire']['formulaire'])) {
echo $this->element('Formulaires/champDuFormulaire', [
'champs' => $fields['soustraitant']
'champs' => $this->request->data['Formulaire']['soustraitant']
]);
}
?>
......
......@@ -2,7 +2,9 @@ $(document).ready(function () {
$('#container').on('submit', function() {
var success = true,
retour = [];
retour = [],
testRETOUR = {};
loulou = {};
$('.ui-droppable').each(function(idxDroppable, droppable) {
var droppableId = $(droppable).attr('id'),
......@@ -14,14 +16,37 @@ $(document).ready(function () {
$(droppable).find('.draggable').each(function (idxDraggable, draggable) {
var contenu = {};
contenu['onglet'] = droppableId;
contenu['ligne'] = Math.round($(draggable).position().top / 35 + 1);
var fieldLine = null,
fieldColumn = null,
fieldType = null,
fieldName = null,
fieldPlaceholder = null,
fieldLabel = null,
fieldDefault = null;
// console.log(contenu);
//
// contenu['ligne'] = 10;
//
// console.log(contenu);
//
//
// total.push({droppableId: contenu});
//
// console.log(total);
// contenu['onglet'] = droppableId;
// contenu['ligne'] = Math.round($(draggable).position().top / 35 + 1);
fieldLine = Math.round($(draggable).position().top / 35 + 1);
// @TODO
if ($(this).position().left < 10) {
contenu['colonne'] = 1;
// contenu['colonne'] = 1;
fieldColumn = 1;
} else {
contenu['colonne'] = 2;
// contenu['colonne'] = 2;
fieldColumn = 2;
}
if ($(draggable).hasClass('small-text')) {
......@@ -30,11 +55,19 @@ $(document).ready(function () {
success = false;
return;
}
contenu['type'] = 'input';
contenu['name'] = $(draggable).find('input').attr('name');
contenu['placeholder'] = $(draggable).find('input').attr('placeholder');
contenu['label'] = $(draggable).find('.labeler').html();
contenu['default'] = $(draggable).find('input').val();
// contenu['type'] = 'input';
// contenu['name'] = $(draggable).find('input').attr('name');
// contenu['placeholder'] = $(draggable).find('input').attr('placeholder');
// contenu['label'] = $(draggable).find('.labeler').html();
// contenu['default'] = $(draggable).find('input').val();
fieldType = 'input';
fieldName = $(draggable).find('input').attr('name');
fieldPlaceholder = $(draggable).find('input').attr('placeholder');
fieldLabel = $(draggable).find('.labeler').html();
fieldDefault = $(draggable).find('input').val();
} else if ($(draggable).hasClass('long-text')) {
if (typeof $(draggable).find('textarea').attr('name') === '' || typeof $(draggable).find('textarea').attr('name') === 'undefined') {
alert('Le nom de variable du grand champ texte est incorrect');
......@@ -166,15 +199,35 @@ $(document).ready(function () {
contenu['repeat'] = false;
}
retour.push(contenu);
var fieldDetails = {
'name': fieldName,
'placeholder': fieldPlaceholder,
'label': fieldLabel,
'default': fieldDefault
};
var fieldValues = {
'ligne' : fieldLine,
'colonne' : fieldColumn,
'type' : fieldType,
'details' : JSON.stringify(fieldDetails)
};
// console.log(fieldValues);
testRETOUR[idxDraggable] = fieldValues;
loulou[droppableId] = testRETOUR;
// retour.push(contenu);
});
});
$('.active').removeClass('active');
$('#info_complementaire').addClass('active');
$('#onglet_info_complementaire').addClass('active');
var ret = JSON.stringify(retour, null, '\t');
// var ret = JSON.stringify(retour, null, '\t');
var ret = JSON.stringify(loulou, null, '\t');
if (success) {
$('#hiddenForm').attr('value', ret);
......
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