Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libriciel
web-DPO
Commits
d9aacb34
Commit
d9aacb34
authored
Aug 06, 2020
by
Théo GUILLON
Browse files
Correction : factorisation
Correction : condition sur le name lorsqu'il est vide
parent
5ecbb07b
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/webroot/js/FormulaireGenerator/saveFieldsFormulaire.js
View file @
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
(
'
n
ame
'
)
;
objFieldDetails
[
'
placeholder
'
]
=
$
(
draggable
).
find
(
'
textarea
'
).
attr
(
'
placeholder
'
);
objFieldDetails
[
'
label
'
]
=
$
(
draggable
).
find
(
'
.labeler
'
).
html
();
objFieldDetails
[
'
default
'
]
=
$
(
draggable
).
find
(
'
textarea
'
).
val
();
objFieldDetails
[
'
name
'
]
=
fieldTextareaN
ame
;
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
(
'
n
ame
'
)
;
objFieldDetails
[
'
placeholder
'
]
=
$
(
draggable
).
find
(
'
input
'
).
attr
(
'
placeholder
'
);
objFieldDetails
[
'
label
'
]
=
$
(
draggable
).
find
(
'
.labeler
'
).
html
();
objFieldDetails
[
'
default
'
]
=
$
(
draggable
).
find
(
'
input
'
).
val
();
objFieldDetails
[
'
name
'
]
=
fieldDateN
ame
;
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="
'
+
field
Name
Radio
s
+
'
"]:checked
'
).
each
(
function
()
{
$
(
'
input[name="
'
+
fieldRadio
Name
+
'
"]: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="
'
+
field
Name
Deroulant
+
'
"]:checked
'
).
each
(
function
()
{
$
(
'
option[name="
'
+
fieldDeroulant
Name
+
'
"]: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="
'
+
field
Name
MultiSelect
+
'
"]:checked
'
).
each
(
function
()
{
$
(
'
option[name="
'
+
fieldMultiSelect
Name
+
'
"]:checked
'
).
each
(
function
()
{
valuesMultiSelectDefault
.
push
(
this
.
index
);
});
objFieldDetails
[
'
default
'
]
=
valuesMultiSelectDefault
;
...
...
LIBRICIEL SCOP
@libricielscop
mentioned in commit
0cac5f6e
·
Aug 07, 2020
mentioned in commit
0cac5f6e
mentioned in commit 0cac5f6ec588a4f1c4ced9c50eb14cfb36cb3e23
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment