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

Correction : enregistrement des conditions sur tout les champs

Ajout : dans la balise label de "for" au la génération JS et à l'édition
Correction : enregistrement options type de champ "radio"
Ajout : enregistrement en BDD des conditions
Ajout restitution des conditions à l'affichage
parent 27a4ef91
......@@ -37,47 +37,51 @@ foreach ($champs as $key => $value) {
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-conditions="'.$details['conditions'].'">'
.'data-virtual-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label>'
. '<label for="'.$details['name'].'">'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '</div>'
. '<div class="col-md-8">'
. '<input type="text" value="'.$details['default'].'" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '" class="form-control champNomVariableReadonly"/>'
. '<input type="text" value="'.$details['default'].'" name="'.$details['name'].'" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '" class="form-control champNomVariableReadonly"/>'
. '</div>'
. '</div>';
break;
// 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.'">'
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-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label>'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '<label for="'.$details['name'].'">'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '</div>'
. '<div class="col-md-8">'
. '<textarea type="textarea" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '"class="form-control champNomVariableReadonly" cols="30" rows="6">'.$details['default'].'</textarea>'
. '<textarea type="textarea" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '"class="form-control champNomVariableReadonly" cols="30" rows="6">'.$details['default'].'</textarea>'
. '</div>'
. '</div>';
. '</div>';
break;
// 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.'">'
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-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label>'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '<label for="'.$details['name'].'">'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '</div>'
. '<div class="col-md-8">'
. '<input class="form-control champNomVariableReadonly" id="'.$details['name'].'" value="'.$details['default'].'" name="'.$details['name'].'" required="'.$details['obligatoire'].'" placeholder="'.$details['placeholder'].'"/>'
. '<input class="form-control champNomVariableReadonly" id="'.$details['name'].'" value="'.$details['default'].'" name="'.$details['name'].'" required="'.$details['obligatoire'].'" placeholder="'.$details['placeholder'].'"/>'
. '</div>'
. '</div>';
. '</div>';
$calendrier[] = $details['name'];
break;
......@@ -93,17 +97,21 @@ foreach ($champs as $key => $value) {
case 'help':
echo '<div class="draggable form-group col-md-6 help text-center" style="top:' . $line . 'px; ' . $colonne . '">'
. '<div class="col-md-12 alert alert-info">'
. '<div class="col-md-12">'
. '<i class="fa fa-fw fa-info-circle fa-2x"><!----></i>'
. '</div>'
. '<div class="col-md-12 messager">' . $details['content'] . '</div>'
. '<div class="col-md-12">'
. '<i class="fa fa-fw fa-info-circle fa-2x"><!----></i>'
. '</div>'
. '<div class="col-md-12 messager">'
. $details['content']
. '</div>'
. '</div>'
. '</div>';
. '</div>';
break;
// Cases à cocher
case 'checkboxes':
echo '<div class="draggable form-group col-md-6 checkboxes" style="top: '.$line.'px; '.$colonne.'" data-virtual-required="'.$champObligatoire.'">'
echo '<div class="draggable form-group col-md-6 checkboxes" style="top: '.$line.'px; '.$colonne.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
.'<div class="input select">'
.'<label for="'.$details['name'].'" class="col-md-4">'
.'<span class="labeler">'.$details['label'].'</span>'
......@@ -134,79 +142,89 @@ 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.'">'
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-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label>'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '<label for="'.$details['name'].'">'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '</div>'
. '<div class="col-md-8 contentRadio">';
foreach ($details['options'] as $key => $val) {
$checked = "";
if (isset($details['default'])) {
if ($details['default'] === $details['name'].$key) {
$checked = "checked";
. '<div class="col-md-8 contentRadio">'
.'<input id="'.$details['name'].'" type="hidden" name="'.$details['name'].'" value="">';
foreach ($details['options'] as $key => $val) {
$checked = "";
if (isset($details['default'])) {
if ($details['default'] === $details['name'].$key) {
$checked = "checked";
}
}
}
echo '<div class="radio">'
. '<input id="'.$details['name'].$key.'" class="champNomVariableReadonly" type="radio" '.$checked.' name="'.$details['name'].'" value="'.$val.'">'.$val.'</div>';
}
echo '</div></div>';
echo '<div class="radio">'
. '<input id="'.$details['name'].$key.'" class="champNomVariableReadonly" type="radio" '.$checked.' name="'.$details['name'].'" value="'.$val.'">'
. $val
.'</div>';
}
echo '</div>'
.'</div>';
break;
// 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.'">'
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-conditions='.$details['conditions'].'>'
. '<div class="col-md-4">'
. '<label>'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '<label for="'.$details['name'].'">'
. '<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '</div>'
. '<div class="col-md-8">'
. '<select id="'.$details['name'].'" class="transformSelect form-control contentDeroulant" name="data[Fiche]['.$details['name'].']" data-placeholder=" ">'
. '<option name="'.$details['name'].'" value=""></option>';
foreach ($details['options'] as $key => $val) {
$selected = "";
if (isset($details['default'])) {
if ($details['default'] === $details['name'].$key) {
$selected = "selected";
}
}
. '<select id="'.$details['name'].'" class="transformSelect form-control contentDeroulant" name="data[Fiche]['.$details['name'].']" data-placeholder=" ">'
. '<option name="'.$details['name'].'" value=""></option>';
foreach ($details['options'] as $key => $val) {
$selected = "";
if (isset($details['default'])) {
if ($details['default'] === $details['name'].$key) {
$selected = "selected";
}
}
echo '<option id="'.$details['name'].$key.'" class="champNomVariableReadonly" type="deroulant" '.$selected.' name ="'.$details['name'].'" value="'.$val.'">'.$val.'</option></div>';
}
echo '</select>'
echo '<option id="'.$details['name'].$key.'" class="champNomVariableReadonly" type="deroulant" '.$selected.' name ="'.$details['name'].'" value="'.$val.'">'.$val.'</option></div>';
}
echo '</select>'
. '</div>'
. '</div>';
. '</div>';
break;
case 'multi-select' :
echo '<div class="draggable col-md-6 form-group multi-select" style="top:'.$line.'px; '.$colonne.'" data-virtual-required="'.$champObligatoire.'">'
echo '<div class="draggable col-md-6 form-group multi-select" style="top:'.$line.'px; '.$colonne.'" '
.'data-virtual-required="'.$champObligatoire.'" '
.'data-virtual-conditions='.$details['conditions'].'>'
.'<div class="col-md-4">'
.'<label>'
.'<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
.'</label>'
.'<label for="'.$details['name'].'">'
.'<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
.'</label>'
.'</div>'
.'<div class="col-md-8">'
.'<input type="hidden" name="multi-select" value="" id="multi-select_"/>'
.'<select id="'.$details['name'].'" name="multi-select" class="form-control multiSelect contentMultiSelect" multiple="multiple">';
foreach ($details['options'] as $key => $val) {
$selected = "";
if (isset($details['default'])) {
if (in_array($details['name'].$key, $details['default'])) {
$selected = 'selected';
}
}
.'<input type="hidden" name="multi-select" value="" id="multi-select_"/>'
.'<select id="'.$details['name'].'" name="multi-select" class="form-control multiSelect contentMultiSelect" multiple="multiple">';
foreach ($details['options'] as $key => $val) {
$selected = "";
if (isset($details['default'])) {
if (in_array($details['name'].$key, $details['default'])) {
$selected = 'selected';
}
}
echo '<option id="'.$details['name'].$key.'" class="champNomVariableReadonly" '.$selected.' name="'.$details['name'].'" value="'.$val.'"> '.$val.'</option>';
}
echo '</select>'
echo '<option id="'.$details['name'].$key.'" class="champNomVariableReadonly" '.$selected.' name="'.$details['name'].'" value="'.$val.'"> '.$val.'</option>';
}
echo '</select>'
.'</div>'
.'</div>';
.'</div>';
break;
// Label
......
......@@ -207,11 +207,13 @@
}
$.each(fieldsContainer, function (key, field) {
var name = $(field).find('input, option').attr('name');
var name = $(field).find('input, textarea, option').attr('name');
var label = $(field).find('.labeler').html();
if (name != idFieldConditionCreated) {
$('#thenTheField').append('<option value="'+name+'">'+label+'</option>');
if (name && label) {
if (name != idFieldConditionCreated) {
$('#thenTheField').append('<option value="' + name + '">' + label + '</option>');
}
}
});
......@@ -306,7 +308,7 @@
var fieldChoose = null;
if (jQuery.inArray(idFieldConditionCreated, ['transfertHorsUe', 'donneesSensible']) !== -1){
fieldChoose = $(idContainer).find('input[name ="' + thenTheField + '"], option[name ="' + thenTheField + '"]').closest('.draggable');
fieldChoose = $(idContainer).find('input[name ="' + thenTheField + '"], textarea[name ="' + thenTheField + '"], option[name ="' + thenTheField + '"]').closest('.draggable');
} else {
fieldChoose = $(idContainer).find('input[name ="' + idFieldConditionCreated + '"], option[name ="' + idFieldConditionCreated + '"]').closest('.draggable');
}
......
......@@ -443,7 +443,6 @@ var createForm = function(typeCreateForm) {
if (object.is('.small-text, .long-text, .date, .checkboxes, .radios, .deroulant, .multi-select')) {
// Ecriture des conditions dans les options du champs
conditions = $(idContainer).find('.ui-selected').attr('data-virtual-conditions');
console.log(conditions);
if (conditions) {
displayConditions = writeConditionsInOption(conditions);
}
......@@ -919,7 +918,7 @@ var createForm = function(typeCreateForm) {
'<strong>'+
' "'+thenTheField+'" '+
'</strong>' +
'doit être' +
'sera' +
'<strong>'+
' "'+mustBe+'" '+
'</strong>' +
......@@ -1075,6 +1074,7 @@ var createForm = function(typeCreateForm) {
// Attribution les valeurs au champ "Choix unique"
if ($(this).hasClass('radios')) {
objet = objet + '<input id="'+newNameField+'" type="hidden" name="'+newNameField+'" value="">'
$.each(newOptionsField, function (index, value) {
objet = objet + '<div class="radio">' +
'<input id="'+index+'" type="radio" name="'+newNameField+'" value="'+value+'">' +
......
......@@ -125,7 +125,7 @@ $(document).ready(function () {
objFieldDetails['default'] = $(draggable).find('input[name="'+fieldName+'"]:checked').val();
options = [];
$(draggable).find('input').each(function () {
$(draggable).find('input[type="radio"]').each(function () {
options.push($(this).attr('value'));
});
objFieldDetails['options'] = options;
......
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