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

Suppression : de l'option "repeat"

parent 90a0ba72
......@@ -473,8 +473,6 @@ class FormulairesController extends AppController {
$success = true;
$this->Formulaire->begin();
// debug($this->request->data);die;
$data = $this->request->data;
unset($data['Fiche']);
......@@ -822,7 +820,7 @@ class FormulairesController extends AppController {
'type' => 'input',
'ligne' => 1,
'colonne' => 1,
'details' => '{"name":"nom_responsable_conjoint","placeholder":"Nom et prénom","label":"Nom et prénom du responsable conjoint","default":"","obligatoire":true,"repeat":true}'
'details' => '{"name":"nom_responsable_conjoint","placeholder":"Nom et prénom","label":"Nom et prénom du responsable conjoint","default":"","obligatoire":true}'
]
],
[
......@@ -830,7 +828,7 @@ class FormulairesController extends AppController {
'type' => 'input',
'ligne' => 3,
'colonne' => 1,
'details' => '{"name":"structure_responsable_conjointe","placeholder":"Raison sociale","label":"Raison sociale de la structure conjointe","default":"","obligatoire":true,"repeat":false}'
'details' => '{"name":"structure_responsable_conjointe","placeholder":"Raison sociale","label":"Raison sociale de la structure conjointe","default":"","obligatoire":true}'
]
],
[
......@@ -838,7 +836,7 @@ class FormulairesController extends AppController {
'type' => 'input',
'ligne' => 1,
'colonne' => 2,
'details' => '{"name":"email_responsable_conjoint","placeholder":"Adresse e-mail","label":"Adresse mail du responsable conjoint","default":"","obligatoire":true,"repeat":false}'
'details' => '{"name":"email_responsable_conjoint","placeholder":"Adresse e-mail","label":"Adresse mail du responsable conjoint","default":"","obligatoire":true}'
]
],
[
......@@ -846,7 +844,7 @@ class FormulairesController extends AppController {
'type' => 'textarea',
'ligne' => 3,
'colonne' => 2,
'details' => '{"name":"adresse_structure_responsable_conjointe","placeholder":"Adresse postale","label":"Adresse de la structure conjointe","default":"","obligatoire":false,"repeat":false}'
'details' => '{"name":"adresse_structure_responsable_conjointe","placeholder":"Adresse postale","label":"Adresse de la structure conjointe","default":"","obligatoire":false}'
]
]
];
......
......@@ -250,6 +250,9 @@ msgstr "Avez-vous réalisé l'analyse d'impact (AIPD) ?"
msgid "formulaire.champDepotPia"
msgstr "Avez-vous déposer dans l'onglet annexe l'analyse d'impact (AIPD) ?"
msgid "formulaire.infoActifTabCoresponsable"
msgstr "Cet onglet sera actif uniquement lorsque le déclaration du traitement aura indiqué 'Oui' sur le champ 'Co-responsable ?' dans l'onget 'Information générale'"
###############################################################################
msgid "formulaire.champIfTheField"
......
......@@ -24,13 +24,6 @@ foreach ($champs as $key => $value) {
$champObligatoire = "fieldNotRequired";
}
$fieldRepeat = "false";
if (isset($details['repeat'])) {
if ($details['repeat'] == true) {
$fieldRepeat = "true";
}
}
if (!isset($details['conditions'])) {
$details['conditions'] = '';
}
......@@ -39,7 +32,7 @@ foreach ($champs as $key => $value) {
// Petit champ texte
case 'input':
echo '<div class="draggable form-group col-md-6 small-text" style="top: '.$line.'px; '.$colonne.'" '
.'data-virtual-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label for="'.$details['name'].'">'
......@@ -56,7 +49,7 @@ foreach ($champs as $key => $value) {
// Grand champ texte
case 'textarea':
echo '<div class="draggable form-group col-md-6 long-text" style="top:' . $line . 'px; ' . $colonne . '" '
.'data-virtual-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label for="'.$details['name'].'">'
......@@ -73,7 +66,7 @@ foreach ($champs as $key => $value) {
// Champ date
case 'date':
echo '<div class="draggable form-group col-md-6 date" style="top:' . $line . 'px; ' . $colonne . '" '
.'data-virtual-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label for="'.$details['name'].'">'
......@@ -148,7 +141,7 @@ foreach ($champs as $key => $value) {
// Choix unique
case 'radios':
echo '<div class="draggable form-group col-md-6 radios" style="top:' . $line . 'px; ' . $colonne . '" '
.'data-virtual-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label for="'.$details['name'].'">'
......@@ -178,7 +171,7 @@ foreach ($champs as $key => $value) {
// Menu déroulant
case 'deroulant':
echo '<div class="draggable form-group col-md-6 deroulant" style="top:' . $line . 'px; ' . $colonne . '" '
.'data-virtual-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label for="'.$details['name'].'">'
......
......@@ -3,7 +3,7 @@
<div class="alert alert-danger" role="alert">
<?php
echo "Cet onglet sera actif uniquement lorsque le déclaration du traitement aura indiqué 'Oui' sur le champ 'Co-responsable ?' dans l'onget 'Information générale'";
echo __d('formulaire', 'formulaire.infoActifTabCoresponsable');
?>
</div>
......@@ -26,6 +26,13 @@
}
?>
</div>
<div class="row">
<div class="col-md-12">
<a class="btn btn-info">Ajouter un autre co-responsable</a>
<br><br>
</div>
</div>
</div>
<script type="text/javascript">
......
......@@ -390,7 +390,6 @@ let createForm = function(typeCreateForm) {
check = null,
readonly = '',
findType = '',
fieldRepeat = '',
displayConditions = '',
conditions = '';
......@@ -429,22 +428,6 @@ let createForm = function(typeCreateForm) {
if (conditions) {
displayConditions = writeConditionsInOption(conditions);
}
// Checkbox "repeat"
if (!jQuery.inArray(typeCreateForm, ['coresponsable', 'soustraitant'])) {
let fieldRepeatChecked = '';
if ($(object).attr('virtual-data-repeat') === 'true') {
fieldRepeatChecked = 'checked="true"';
}
fieldRepeat = '<div class="checkbox">' +
'<label>' +
'<input type="checkbox" id="checkboxFieldRepeat" class="fieldRepeat" '+fieldRepeatChecked+'>' +
'Répétition du champ X fois' +
'</label>' +
'</div>';
}
}
if ($(object).is('.small-text, .long-text, .date')) {
......@@ -520,7 +503,6 @@ let createForm = function(typeCreateForm) {
'</div>' +
'<div class="col-md-3">' +
check +
fieldRepeat +
'</div>' +
'</div>' +
displayConditions +
......@@ -973,24 +955,6 @@ let createForm = function(typeCreateForm) {
}
}
/**
* Attribut au champ crée si il est répétable ou non
*
* @param repeat : boolean
*
* @created 17/04/2020
* @version V1.2.0
* @author Théo GUILLON <theo.guillon@libriciel.coop>
*/
function giveToFieldIfRepeat(repeat)
{
if (repeat === true) {
$(idContainer).find('.ui-selected').attr('virtual-data-repeat', true);
} else {
$(idContainer).find('.ui-selected').attr('virtual-data-repeat', false);
}
}
/**
* Ecrit textuellement les différentes conditions du champs pour les afficher
*
......@@ -1133,13 +1097,6 @@ let createForm = function(typeCreateForm) {
}
}
// On récupère le "Répétition"
if ($(this).hasClass('fieldRepeat')) {
if ($(this).prop('checked')) {
newRepeteField = true;
}
}
// si erreur on sort de la boucle (de .each)
if (success === false) {
return success;
......@@ -1164,9 +1121,6 @@ let createForm = function(typeCreateForm) {
// give to field if required
giveToFieldIfRequired(newRequiredField);
// give to field if repeat
giveToFieldIfRepeat(newRepeteField);
}
// Attribution les valeurs aux champs "Petit champ texte" et "Champ date"
......
$(document).ready(function () {
$('#container').on('submit', function() {
var success = true,
let success = true,
dynamicFields = [];
$('.ui-droppable').each(function(idxDroppable, droppable) {
var droppableId = $(droppable).attr('id'),
let droppableId = $(droppable).attr('id'),
idTab = '#'+$(droppable).parent().attr('id');
$('.active').removeClass('active');
$(idTab).addClass('active');
$(droppable).find('.draggable').each(function (idxDraggable, draggable) {
var objFieldDetails = {};
var objFieldValues = {};
let objFieldDetails = {};
let objFieldValues = {};
var fieldLine = null,
let fieldLine = null,
fieldColumn = null,
fieldType = null,
fieldName = null;
var options = [];
let options = [];
fieldLine = Math.round($(draggable).position().top / 35 + 1);
......@@ -40,10 +40,11 @@ $(document).ready(function () {
fieldType = 'input';
objFieldDetails['name'] = $(draggable).find('input').attr('name');
objFieldDetails['placeholder'] = $(draggable).find('input').attr('placeholder');
let filedDraggable = $(draggable).find('input');
objFieldDetails['name'] = $(filedDraggable).attr('name');
objFieldDetails['placeholder'] = $(filedDraggable).attr('placeholder');
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['default'] = $(draggable).find('input').val();
objFieldDetails['default'] = $(filedDraggable).val();
} else if ($(draggable).hasClass('long-text')) {
if (typeof $(draggable).find('textarea').attr('name') === '' || typeof $(draggable).find('textarea').attr('name') === 'undefined') {
......@@ -94,7 +95,7 @@ $(document).ready(function () {
fieldType = 'checkboxes';
var fieldNameCheckboxes = $(draggable).find('input').attr('name');
let fieldNameCheckboxes = $(draggable).find('input').attr('name');
objFieldDetails['name'] = fieldNameCheckboxes;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
......@@ -104,9 +105,9 @@ $(document).ready(function () {
});
objFieldDetails['options'] = options;
var valuesCheckboxesDefault = [];
$('input[name="'+fieldNameCheckboxes+'"]:checked').each(function(key, value) {
valuesCheckboxesDefault.push(this.value);
let valuesCheckboxesDefault = [];
$('input[name="'+fieldNameCheckboxes+'"]:checked').each(function() {
valuesCheckboxesDefault.push($(this).value);
});
objFieldDetails['default'] = valuesCheckboxesDefault;
......@@ -119,7 +120,7 @@ $(document).ready(function () {
fieldType = 'radios';
var fieldNameRadios = $(draggable).find('input').attr('name');
let fieldNameRadios = $(draggable).find('input').attr('name');
objFieldDetails['name'] = fieldNameRadios;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['default'] = $(draggable).find('input[name="'+fieldName+'"]:checked').val();
......@@ -130,9 +131,9 @@ $(document).ready(function () {
});
objFieldDetails['options'] = options;
var valuesRadiosDefault = '';
let valuesRadiosDefault = '';
$('input[name="'+fieldNameRadios+'"]:checked').each(function() {
if (this.value != '') {
if ($(this).value !== '') {
valuesRadiosDefault = this.value;
}
});
......@@ -147,7 +148,7 @@ $(document).ready(function () {
fieldType = 'deroulant';
var fieldNameDeroulant = $(draggable).find('option').attr('name');
let fieldNameDeroulant = $(draggable).find('option').attr('name');
objFieldDetails['name'] = fieldNameDeroulant;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
......@@ -159,9 +160,9 @@ $(document).ready(function () {
});
objFieldDetails['options'] = options;
var valuesDeroulantDefault = '';
let valuesDeroulantDefault = '';
$('option[name="'+fieldNameDeroulant+'"]:checked').each(function() {
if (this.value != '') {
if ($(this).value !== '') {
valuesDeroulantDefault = this.value;
}
});
......@@ -176,7 +177,7 @@ $(document).ready(function () {
fieldType = 'multi-select';
var fieldNameMultiSelect = $(draggable).find('option').attr('name');
let fieldNameMultiSelect = $(draggable).find('option').attr('name');
objFieldDetails['name'] = fieldNameMultiSelect;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
......@@ -188,7 +189,7 @@ $(document).ready(function () {
});
objFieldDetails['options'] = options;
var valuesMultiSelectDefault = [];
let valuesMultiSelectDefault = [];
$('option[name="'+fieldNameMultiSelect+'"]:checked').each(function() {
valuesMultiSelectDefault.push(this.index);
});
......@@ -201,13 +202,7 @@ $(document).ready(function () {
objFieldDetails['obligatoire'] = false;
}
if ($(draggable).attr('data-virtual-repeat') === 'fieldRepeat') {
objFieldDetails['repeat'] = true;
} else {
objFieldDetails['repeat'] = false;
}
var dataVirtualConditions = $(draggable).attr('data-virtual-conditions');
let dataVirtualConditions = $(draggable).attr('data-virtual-conditions');
if (dataVirtualConditions) {
objFieldDetails['conditions'] = dataVirtualConditions
} else {
......@@ -222,7 +217,7 @@ $(document).ready(function () {
};
$.each(objFieldValues, function(fieldName, value) {
var hidden = $('<input type="hidden" name="data[Formulaire]['+droppableId+']['+idxDraggable+'][Champ]['+fieldName+']" value="" />');
let hidden = $('<input type="hidden" name="data[Formulaire]['+droppableId+']['+idxDraggable+'][Champ]['+fieldName+']" value="" />');
hidden.attr('value', value);
dynamicFields.push(hidden);
});
......
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