Commit cde32a53 authored by THEO GUILLON's avatar THEO GUILLON
Browse files

Merge branch '404-formulaires-enregistrement' into '2.0.0'

Resolve "Formulaires: enregistrement"

See merge request libriciel/pole-citoyens/web-DPO/web-DPO!394
parents 5ecbb07b d9aacb34
......@@ -32,7 +32,10 @@ $(document).ready(function () {
}
if ($(draggable).hasClass('small-text')) {
if (typeof $(draggable).find('input').attr('name') === '' || typeof $(draggable).find('input').attr('name') === 'undefined') {
let fieldDraggable = $(this).find('input');
let fieldInputName = $(fieldDraggable).attr('name');
if ($.trim(fieldInputName).length === 0) {
alert('Le nom de variable du petit champ texte est incorrect');
success = false;
return;
......@@ -40,14 +43,16 @@ $(document).ready(function () {
fieldType = 'input';
let filedDraggable = $(draggable).find('input');
objFieldDetails['name'] = $(filedDraggable).attr('name');
objFieldDetails['placeholder'] = $(filedDraggable).attr('placeholder');
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['default'] = $(filedDraggable).val();
objFieldDetails['name'] = fieldInputName;
objFieldDetails['placeholder'] = $(fieldDraggable).attr('placeholder');
objFieldDetails['label'] = $(this).find('.labeler').html();
objFieldDetails['default'] = $(fieldDraggable).val();
} else if ($(draggable).hasClass('long-text')) {
if (typeof $(draggable).find('textarea').attr('name') === '' || typeof $(draggable).find('textarea').attr('name') === 'undefined') {
let fieldTextareaDraggable = $(this).find('textarea');
let fieldTextareaName = $(fieldTextareaDraggable).attr('name');
if ($.trim(fieldTextareaName).length === 0) {
alert('Le nom de variable du grand champ texte est incorrect');
success = false;
return;
......@@ -55,13 +60,16 @@ $(document).ready(function () {
fieldType = 'textarea';
objFieldDetails['name'] = $(draggable).find('textarea').attr('name');
objFieldDetails['placeholder'] = $(draggable).find('textarea').attr('placeholder');
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['default'] = $(draggable).find('textarea').val();
objFieldDetails['name'] = fieldTextareaName;
objFieldDetails['placeholder'] = $(fieldTextareaDraggable).attr('placeholder');
objFieldDetails['label'] = $(this).find('.labeler').html();
objFieldDetails['default'] = $(fieldTextareaDraggable).val();
} else if ($(draggable).hasClass('date')) {
if (typeof $(draggable).find('input').attr('name') === '' || typeof $(draggable).find('input').attr('name') === 'undefined') {
let fieldDateDraggable = $(this).find('input');
let fieldDateName = $(fieldDateDraggable).attr('name');
if ($.trim(fieldDateName).length === 0) {
alert('Le nom de variable du champ date est incorrect');
success = false;
return;
......@@ -69,25 +77,28 @@ $(document).ready(function () {
fieldType = 'date';
objFieldDetails['name'] = $(draggable).find('input').attr('name');
objFieldDetails['placeholder'] = $(draggable).find('input').attr('placeholder');
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['default'] = $(draggable).find('input').val();
objFieldDetails['name'] = fieldDateName;
objFieldDetails['placeholder'] = $(fieldDateDraggable).attr('placeholder');
objFieldDetails['label'] = $(this).find('.labeler').html();
objFieldDetails['default'] = $(fieldDateDraggable).val();
} else if ($(draggable).hasClass('title')) {
fieldType = 'title';
objFieldDetails['content'] = $(draggable).find('h1').html();
objFieldDetails['content'] = $(this).find('h1').html();
} else if ($(draggable).hasClass('texte')) {
fieldType = 'texte';
objFieldDetails['content'] = $(draggable).find('h5').html();
objFieldDetails['content'] = $(this).find('h5').html();
} else if ($(draggable).hasClass('help')) {
fieldType = 'help';
objFieldDetails['content'] = $(draggable).find('.messager').html();
objFieldDetails['content'] = $(this).find('.messager').html();
} else if ($(draggable).hasClass('checkboxes')) {
if (typeof $(draggable).find('input').attr('name') === '' || typeof $(draggable).find('input').attr('name') === 'undefined') {
let fieldCheckboxeDraggable = $(this).find('input');
let fieldCheckboxeName = $(fieldCheckboxeDraggable).attr('name');
if ($.trim(fieldCheckboxeName).length === 0) {
alert('Le nom de variable des cases à cocher est incorrect');
success = false;
return;
......@@ -95,12 +106,11 @@ $(document).ready(function () {
fieldType = 'checkboxes';
let fieldNameCheckboxes = $(draggable).find('input').attr('name');
objFieldDetails['name'] = fieldNameCheckboxes;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['name'] = fieldCheckboxeName;
objFieldDetails['label'] = $(this).find('.labeler').html();
options = [];
$(draggable).find('input[type="checkbox"]').each(function () {
$(this).find('input[type="checkbox"]').each(function () {
options.push($(this).next('label').text());
});
objFieldDetails['options'] = options;
......@@ -113,7 +123,10 @@ $(document).ready(function () {
objFieldDetails['default'] = valuesCheckboxesDefault;
} else if ($(draggable).hasClass('radios')) {
if (typeof $(draggable).find('input').attr('name') === '' || typeof $(draggable).find('input').attr('name') === 'undefined') {
let fieldRadioDraggable = $(this).find('input');
let fieldRadioName = $(fieldRadioDraggable).attr('name');
if ($.trim(fieldRadioName).length === 0) {
alert('Le nom de variable du choix unique est incorrect');
success = false;
return;
......@@ -121,19 +134,18 @@ $(document).ready(function () {
fieldType = 'radios';
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();
objFieldDetails['name'] = fieldRadioName;
objFieldDetails['label'] = $(this).find('.labeler').html();
objFieldDetails['default'] = $(this).find('input[name="'+fieldName+'"]:checked').val();
options = [];
$(draggable).find('input[type="radio"]').each(function () {
$(this).find('input[type="radio"]').each(function () {
options.push($(this).attr('value'));
});
objFieldDetails['options'] = options;
let valuesRadiosDefault = '';
$('input[name="'+fieldNameRadios+'"]:checked').each(function() {
$('input[name="'+fieldRadioName+'"]:checked').each(function() {
if ($(this).value !== '') {
valuesRadiosDefault = this.value;
}
......@@ -141,7 +153,10 @@ $(document).ready(function () {
objFieldDetails['default'] = valuesRadiosDefault;
} else if ($(draggable).hasClass('deroulant')) {
if (typeof $(draggable).find('option').attr('name') === '' || typeof $(draggable).find('option').attr('name') === 'undefined') {
let fieldDeroulantDraggable = $(this).find('option');
let fieldDeroulantName = $(fieldDeroulantDraggable).attr('name');
if ($.trim(fieldDeroulantName).length === 0) {
alert('Le nom de variable du menu déroulant est incorrect');
success = false;
return;
......@@ -149,12 +164,11 @@ $(document).ready(function () {
fieldType = 'deroulant';
let fieldNameDeroulant = $(draggable).find('option').attr('name');
objFieldDetails['name'] = fieldNameDeroulant;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['name'] = fieldDeroulantName;
objFieldDetails['label'] = $(this).find('.labeler').html();
options = [];
$(draggable).find('option').each(function () {
$(this).find('option').each(function () {
if ($(this).text()) {
options.push($(this).text());
}
......@@ -162,7 +176,7 @@ $(document).ready(function () {
objFieldDetails['options'] = options;
let valuesDeroulantDefault = '';
$('option[name="'+fieldNameDeroulant+'"]:checked').each(function() {
$('option[name="'+fieldDeroulantName+'"]:checked').each(function() {
if ($(this).value !== '') {
valuesDeroulantDefault = this.value;
}
......@@ -170,7 +184,10 @@ $(document).ready(function () {
objFieldDetails['default'] = valuesDeroulantDefault;
} else if ($(draggable).hasClass('multi-select')) {
if (typeof $(draggable).find('option').attr('name') === '' || typeof $(draggable).find('option').attr('name') === 'undefined') {
let fieldMultiDraggable = $(this).find('option');
let fieldMultiSelectName = $(fieldMultiDraggable).attr('name');
if ($.trim(fieldMultiSelectName).length === 0) {
alert('Le nom de variable du menu multi-select est incorrect');
success = false;
return;
......@@ -178,12 +195,11 @@ $(document).ready(function () {
fieldType = 'multi-select';
let fieldNameMultiSelect = $(draggable).find('option').attr('name');
objFieldDetails['name'] = fieldNameMultiSelect;
objFieldDetails['label'] = $(draggable).find('.labeler').html();
objFieldDetails['name'] = fieldMultiSelectName;
objFieldDetails['label'] = $(this).find('.labeler').html();
options = [];
$(draggable).find('option').each(function () {
$(this).find('option').each(function () {
if ($(this).text()) {
options.push($(this).text());
}
......@@ -191,7 +207,7 @@ $(document).ready(function () {
objFieldDetails['options'] = options;
let valuesMultiSelectDefault = [];
$('option[name="'+fieldNameMultiSelect+'"]:checked').each(function() {
$('option[name="'+fieldMultiSelectName+'"]:checked').each(function() {
valuesMultiSelectDefault.push(this.index);
});
objFieldDetails['default'] = valuesMultiSelectDefault;
......
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