Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
web-DPO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libriciel
web-DPO
Commits
a5a3f3a2
Commit
a5a3f3a2
authored
Sep 14, 2020
by
Théo GUILLON
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correction : condition sur les champs avec plusieurs valeurs
parent
ab1e45ec
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
275 additions
and
174 deletions
+275
-174
app/Config/Schema/CreationBase/data-dev/1.2.0.sql
app/Config/Schema/CreationBase/data-dev/1.2.0.sql
+22
-22
app/View/Elements/Fiches/tabs/formulaire.ctp
app/View/Elements/Fiches/tabs/formulaire.ctp
+153
-107
app/View/Elements/Formulaires/champDuFormulaire.ctp
app/View/Elements/Formulaires/champDuFormulaire.ctp
+1
-1
app/View/Elements/Formulaires/modal/modalAddCondition.ctp
app/View/Elements/Formulaires/modal/modalAddCondition.ctp
+65
-27
app/View/Fiches/add.ctp
app/View/Fiches/add.ctp
+5
-2
app/webroot/js/FormulaireGenerator/createFormulaire.js
app/webroot/js/FormulaireGenerator/createFormulaire.js
+29
-15
No files found.
app/Config/Schema/CreationBase/data-dev/1.2.0.sql
View file @
a5a3f3a2
This diff is collapsed.
Click to expand it.
app/View/Elements/Fiches/tabs/formulaire.ctp
View file @
a5a3f3a2
...
...
@@ -134,6 +134,7 @@ $line = 1;
case
'checkboxes'
:
echo
$this
->
WebcilForm
->
input
(
'WebdpoFiche.'
.
$options
[
'name'
],
[
'id'
=>
$options
[
'name'
],
'name'
=>
$options
[
'name'
],
'label'
=>
[
'text'
=>
$options
[
'label'
],
'class'
=>
'col-md-4'
,
...
...
@@ -290,149 +291,194 @@ $line = 1;
// Mise en place des conditions
let
conditions
=
<?php
echo
json_encode
(
$conditions
);
?>
;
$
.
each
(
conditions
,
function
(
key
,
value
)
{
// On cache le champ par défault
// shownHideField(value['ifNot'], value['thenTheField']);
let
valueIfTheField
=
$
(
'
#
'
+
value
[
'
ifTheField
'
]);
// Si le champ a comme balise "select" (deroulant et multi-select)
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
is
(
'
select
'
))
{
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
hasClass
(
'
multiSelect
'
)
==
true
)
{
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
on
(
'
show
'
,
function
()
{
if
(
jQuery
.
inArray
(
value
[
'
hasValue
'
],
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
val
())
!==
-
1
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
if
(
$
(
valueIfTheField
).
is
(
'
select
'
))
{
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
// if (jQuery.inArray(value['hasValue'], $('#'+value['ifTheField']).val()) !== -1) {
// shownHideField(value['mustBe'], value['thenTheField'])
// } else {
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
// }
});
if
(
$
(
valueIfTheField
).
hasClass
(
'
multiSelect
'
)
===
true
)
{
// Champ multi-select
if
(
jQuery
.
inArray
(
value
[
'
hasValue
'
],
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
val
())
!==
-
1
&&
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
css
(
'
display
'
)
!=
'
none
'
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
else
{
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
on
(
'
show
'
,
function
()
{
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
val
()
==
value
[
'
hasValue
'
])
{
// Si le champ multi-select est visible
$
(
valueIfTheField
).
parent
().
parent
().
on
(
'
show
'
,
function
()
{
let
showCondition
=
false
;
if
(
$
(
valueIfTheField
).
val
())
{
$
.
each
(
$
(
valueIfTheField
).
val
(),
function
(
k
,
v
)
{
if
(
jQuery
.
inArray
(
v
,
value
[
'
hasValue
'
])
!==
-
1
)
{
showCondition
=
true
;
}
});
}
if
(
showCondition
===
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
// if ($('#'+value['ifTheField']).val() == value['hasValue']) {
// shownHideField(value['mustBe'], value['thenTheField'])
// } else {
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
// }
});
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
val
()
==
value
[
'
hasValue
'
]
&&
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
css
(
'
display
'
)
!=
'
none
'
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
// Si le champ multi-select n'est pas visible
$
(
valueIfTheField
).
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
});
// Quand le champ deroulant ou multi-select change de valeur
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
change
(
function
()
{
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
hasClass
(
'
multiSelect
'
)
==
true
)
{
if
(
jQuery
.
inArray
(
value
[
'
hasValue
'
],
$
(
this
).
val
())
!==
-
1
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
else
{
if
(
$
(
this
).
val
()
==
value
[
'
hasValue
'
])
{
$
.
each
(
$
(
valueIfTheField
).
val
(),
function
(
k
,
v
)
{
if
(
jQuery
.
inArray
(
v
,
value
[
'
hasValue
'
])
!==
-
1
&&
$
(
valueIfTheField
).
parent
().
parent
().
css
(
'
display
'
)
!==
'
none
'
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
});
}
});
// Si le champ a comme balise "input"
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
is
(
'
input
'
))
{
}
else
{
// Champ deroulant
// Si le champ est de type "checkbox"
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
attr
(
'
type
'
)
==
"
checkbox
"
)
{
$
(
'
#
'
+
value
[
'
hasValue
'
]).
parent
().
parent
().
parent
().
on
(
'
show
'
,
function
()
{
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
prop
(
"
checked
"
)
==
true
)
{
// Si le champ déroulant est visible
$
(
valueIfTheField
).
parent
().
parent
().
on
(
'
show
'
,
function
()
{
if
(
$
(
valueIfTheField
).
val
()
===
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
$
(
'
#
'
+
value
[
'
hasValue
'
]).
parent
().
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
// Si le champ déroulant n'est pas visible
$
(
valueIfTheField
).
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
});
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
prop
(
"
checked
"
)
===
true
&&
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
css
(
'
display
'
)
!=
'
none
'
)
{
if
(
$
(
valueIfTheField
).
val
()
===
value
[
'
hasValue
'
]
&&
$
(
valueIfTheField
).
parent
().
parent
().
css
(
'
display
'
)
!==
'
none
'
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
// Quand le champ deroulant ou multi-select change de valeur
$
(
valueIfTheField
).
change
(
function
()
{
if
(
$
(
valueIfTheField
).
hasClass
(
'
multiSelect
'
)
===
true
)
{
if
(
Array
.
isArray
(
value
[
'
hasValue
'
])
===
true
)
{
let
showCondition
=
false
;
if
(
$
(
this
).
val
())
{
$
.
each
(
$
(
this
).
val
(),
function
(
k
,
v
)
{
if
(
jQuery
.
inArray
(
v
,
value
[
'
hasValue
'
])
!==
-
1
)
{
showCondition
=
true
;
}
});
}
// Quand la valeur de la condition change
$
(
'
#
'
+
value
[
'
hasValue
'
]).
on
(
'
change
'
,
function
()
{
if
(
$
(
this
).
prop
(
"
checked
"
)
==
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
}
// Si le champ est de type "radio"
// if ($('#'+value['hasValue']).attr('type') == "radio") {
if
(
$
(
'
input[type="radio"][value="
'
+
value
[
'
hasValue
'
]
+
'
"]
'
).
length
==
1
)
{
// Quand le changer est affiché
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
on
(
'
show
'
,
function
()
{
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
find
(
'
input[type=radio]:checked
'
).
each
(
function
()
{
if
(
$
(
this
).
val
()
==
value
[
'
hasValue
'
])
{
if
(
showCondition
===
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
});
// Quand le champ est caché
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
});
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
parent
().
css
(
'
display
'
)
!=
'
none
'
)
{
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
find
(
'
input[type=radio]:checked
'
).
val
()
==
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
// Quand le champ radio change de valeur
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
parent
().
find
(
'
input[type=radio]
'
).
on
(
'
change
'
,
function
()
{
if
(
$
(
this
).
val
()
==
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
}
}
}
}
else
{
if
(
$
(
this
).
val
()
===
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
});
}
// Si le champ a comme balise "input"
if
(
$
(
valueIfTheField
).
is
(
'
input
'
))
{
// Si le champ est de type "checkbox"
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
attr
(
'
type
'
)
===
"
checkbox
"
)
{
$
(
'
#
'
+
value
[
'
hasValue
'
]).
parent
().
parent
().
parent
().
on
(
'
show
'
,
function
()
{
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
prop
(
"
checked
"
)
==
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
$
(
'
#
'
+
value
[
'
hasValue
'
]).
parent
().
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
});
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
prop
(
"
checked
"
)
===
true
&&
$
(
valueIfTheField
).
parent
().
parent
().
css
(
'
display
'
)
!=
'
none
'
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
$
(
'
input[name ="
'
+
value
[
'
ifTheField
'
]
+
'
[]"]
'
).
change
(
function
()
{
let
valueSelected
=
[];
$
.
each
(
$
(
'
input[name ="
'
+
value
[
'
ifTheField
'
]
+
'
[]"]:checked
'
),
function
(){
valueSelected
.
push
(
$
(
this
).
attr
(
'
id
'
));
});
if
(
Array
.
isArray
(
valueSelected
)
===
true
)
{
let
showCondition
=
false
;
if
(
valueSelected
)
{
$
.
each
(
valueSelected
,
function
(
k
,
v
)
{
if
(
jQuery
.
inArray
(
v
,
value
[
'
hasValue
'
])
!==
-
1
)
{
showCondition
=
true
;
}
});
}
if
(
showCondition
===
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
});
}
// Si le champ est de type "radio"
// if ($('#'+value['hasValue']).attr('type') == "radio") {
if
(
$
(
'
input[type="radio"][value="
'
+
value
[
'
hasValue
'
]
+
'
"]
'
).
length
===
1
)
{
// Quand le changer est affiché
$
(
valueIfTheField
).
parent
().
parent
().
on
(
'
show
'
,
function
()
{
$
(
valueIfTheField
).
parent
().
find
(
'
input[type=radio]:checked
'
).
each
(
function
()
{
if
(
$
(
this
).
val
()
===
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
});
// Quand le champ est caché
$
(
valueIfTheField
).
parent
().
parent
().
on
(
'
hide
'
,
function
()
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
});
if
(
$
(
valueIfTheField
).
parent
().
parent
().
css
(
'
display
'
)
!==
'
none
'
)
{
if
(
$
(
valueIfTheField
).
parent
().
find
(
'
input[type=radio]:checked
'
).
val
()
===
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
// Quand le champ radio change de valeur
$
(
valueIfTheField
).
parent
().
find
(
'
input[type=radio]
'
).
on
(
'
change
'
,
function
()
{
if
(
$
(
this
).
val
()
===
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
}
}
});
function
shownHideField
(
condition
,
thenTheField
)
...
...
app/View/Elements/Formulaires/champDuFormulaire.ctp
View file @
a5a3f3a2
...
...
@@ -257,7 +257,7 @@ foreach ($champs as $key => $value) {
width
:
'
100%
'
});
var
champsDate
=
<?php
echo
json_encode
(
$calendrier
)
?>
;
let
champsDate
=
<?php
echo
json_encode
(
$calendrier
)
?>
;
jQuery
.
each
(
champsDate
,
function
(
key
,
val
){
$
(
'
#
'
+
val
).
datetimepicker
({
viewMode
:
'
year
'
,
...
...
app/View/Elements/Formulaires/modal/modalAddCondition.ctp
View file @
a5a3f3a2
...
...
@@ -54,6 +54,19 @@
'text' => __d('formulaire', 'formulaire.champHasValue')
],
]);
echo $this->WebcilForm->input('Fiche.hasValueMulti', [
'id' => 'hasValueMulti',
'options' => [],
'empty' => true,
'class' => 'form-control usersDeroulant',
'placeholder' => false,
'required' => true,
'data-placeholder' => ' ',
'label' => [
'text' => __d('formulaire', 'formulaire.champHasValue')
],
'multiple' => true,
]);
?>
</div>
...
...
@@ -142,15 +155,13 @@
<script type="text/javascript">
$(document).ready(function () {
let idContainer = null
;
let
idFieldConditionCreated = null;
let idContainer = null
,
idFieldConditionCreated = null;
// $('#btn-condition').click(function () {
$('#btn-condition-formulaire, #btn-condition-coresponsable, #btn-condition-soustraitant').click(function () {
hideAllFields();
$('#ifTheField option').slice(3).remove();
// idContainer = '#' + $('.form-container').attr('id');
idContainer = '#' + $(this).parent().parent().nextAll('.form-container').attr('id');
if (!idContainer) {
return false;
...
...
@@ -165,8 +176,8 @@
}
$(idContainer).find('.draggable').filter('.checkboxes, .radios, .deroulant, .multi-select').each(function (key, field) {
let name = $(field).find('input, option').attr('name')
;
let
label = $(field).find('.labeler').html();
let name = $(field).find('input, option').attr('name')
,
label = $(field).find('.labeler').html();
if (name && label) {
$('#ifTheField').append('<option value="' + name + '">' + label + '</option>');
...
...
@@ -179,14 +190,16 @@
idFieldConditionCreated = $(this).val();
let showHasValueMulti = false;
if (!idFieldConditionCreated) {
hideAllFields();
} else {
if (jQuery.inArray(idFieldConditionCreated, ['transfert_hors_ue', 'donnees_sensibles']) !== -1){
if (jQuery.inArray(idFieldConditionCreated, ['transfert_hors_ue', 'donnees_sensibles']) !== -1)
{
// On recupere les "options" du champ "selected" sur lequel nous allons faire la condition
$('#'+idFieldConditionCreated).find('option').each(function () {
let option = $(this).attr('value')
;
let
label = $(this).text();
let option = $(this).attr('value')
,
label = $(this).text();
if (option && label) {
$('#hasValue').append('<option value="' + option + '">' + label + '</option>');
...
...
@@ -195,20 +208,28 @@
} else {
// On recupere les "options" du champ "selected" sur lequel nous allons faire la condition
if ($('#'+idFieldConditionCreated).is("select")) {
// Champs "Menu multi-select" ou "Menu déroulant"
$(idContainer).find('input[name ="'+idFieldConditionCreated+'"],option[name ="'+idFieldConditionCreated+'"]').each(function () {
let value = $(this).attr('value')
;
let
labelValue = $(this).text();
let value = $(this).attr('value')
,
labelValue = $(this).text();
if (value && labelValue) {
$('#hasValue').append('<option value="' + value + '">' + labelValue + '</option>');
if ($(this).attr('type')) {
$('#hasValue').append('<option value="' + value + '">' + labelValue + '</option>');
} else {
let newOption = new Option(labelValue, value, false, false);
$('#hasValueMulti').append(newOption).trigger('change');
}
}
});
} else {
// Champs "Case à cocher" ou "Choix unique"
$(idContainer).find('input[name ="'+idFieldConditionCreated+'"], option[name ="'+idFieldConditionCreated+'"]').each(function () {
let option = null
;
let
id = null;
let option = null
,
id = null;
if ($(this).attr('type') == 'checkbox') {
showHasValueMulti = true;
option = $(this).next('label').text();
} else {
option = $(this).attr('value');
...
...
@@ -221,17 +242,29 @@
}
if (option && id) {
$('#hasValue').append('<option value="' + id + '">' + option + '</option>');
if (showHasValueMulti === true) {
let newOption = new Option(option, id, false, false);
$('#hasValueMulti').append(newOption).trigger('change');
} else {
$('#hasValue').append('<option value="' + id + '">' + option + '</option>');
}
}
});
}
}
$('#hasValue').parent().parent().show();
if ($('#'+idFieldConditionCreated).hasClass('multiSelect') === true ||
showHasValueMulti === true
) {
$('#hasValueMulti').parent().parent().show();
} else {
$('#hasValue').parent().parent().show();
}
}
});
$('#hasValue').change(function () {
$('#hasValue
, #hasValueMulti
').change(function () {
let valueSelected = $(this).val();
$('#thenTheField').parent().parent().hide();
...
...
@@ -250,8 +283,8 @@
}
$.each(fieldsContainer, function (key, field) {
let name = $(field).find('input, textarea, option').attr('name')
;
let
label = $(field).find('.labeler').html();
let name = $(field).find('input, textarea, option').attr('name')
,
label = $(field).find('.labeler').html();
if (name && label) {
if (name != idFieldConditionCreated) {
...
...
@@ -300,12 +333,12 @@
$('#saveCondition').click(function () {
$('div.error-message').remove();
let ifTheField = $('#ifTheField').val()
;
let hasValue = $('#hasValue').val();
let thenTheField = $('#thenTheField').val();
let mustBe = $('#mustBe').val();
let ifNot = $('#ifNot').val();
let
success = true;
let ifTheField = $('#ifTheField').val()
,
hasValue = $('#hasValue').val(),
thenTheField = $('#thenTheField').val(),
mustBe = $('#mustBe').val(),
ifNot = $('#ifNot').val(),
success = true;
if (!ifTheField) {
$('#ifTheField').parent().parent().append('<div class="error-message">Champ obligatoire</div>');
...
...
@@ -313,8 +346,11 @@
}
if (!hasValue) {
$('#hasValue').parent().parent().append('<div class="error-message">Champ obligatoire</div>');
success = false;
hasValue = $('#hasValueMulti').val();
if (!hasValue) {
$('#hasValue').parent().parent().append('<div class="error-message">Champ obligatoire</div>');
success = false;
}
}
if (!thenTheField) {
...
...
@@ -374,6 +410,7 @@
function hideAllFields()
{
$('#hasValue').parent().parent().hide();
$('#hasValueMulti').parent().parent().hide();
$('#thenTheField').parent().parent().hide();
$('#mustBe').parent().parent().hide();
$('#ifNot').parent().parent().hide();
...
...
@@ -384,6 +421,7 @@
function removeValuesAllFields()
{
$('#hasValue option').not(':first').remove();
$('#hasValueMulti option').not(':first').remove();
$('#thenTheField option').not(':first').remove();
$('#mustBe').val('');
$('#ifNot').val('');
...
...
app/View/Fiches/add.ctp
View file @
a5a3f3a2
...
...
@@ -6,6 +6,8 @@ echo $this->Html->script([
]);
echo
$this
->
Html
->
css
(
'/js/smalot-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min'
);
$validationErrorsFichier
=
null
;
if
(
isset
(
$this
->
validationErrors
[
'WebdpoFiche'
])
&&
!
empty
(
$this
->
validationErrors
[
'WebdpoFiche'
])
||
isset
(
$this
->
validationErrors
[
'Fiche'
])
&&
!
empty
(
$this
->
validationErrors
[
'Fiche'
])
||
isset
(
$this
->
validationErrors
[
'Fichier'
])
&&
!
empty
(
$this
->
validationErrors
[
'Fichier'
])
||
...
...
@@ -66,6 +68,7 @@ if (isset($this->validationErrors['WebdpoFiche']) && !empty($this->validationErr
}
if
(
isset
(
$this
->
validationErrors
[
'Fichier'
])
&&
!
empty
(
$this
->
validationErrors
[
'Fichier'
]))
{
$validationErrorsFichier
=
$this
->
validationErrors
[
'Fichier'
];
$champ
=
null
;
foreach
(
$this
->
validationErrors
[
'Fichier'
]
as
$key
=>
$errorChamps
)
{
foreach
(
$errorChamps
as
$error
)
{
...
...
@@ -388,8 +391,8 @@ echo $this->WebcilForm->end();
$
(
a
).
append
(
"
<span class='fa fa-exclamation-circle fa-danger' aria-hidden='true'><
\
/span>
"
);
});
let
errorAnnexe
=
<?php
echo
json_encode
(
$
this
->
validationErrors
[
'Fichier'
]
);
?>
;
if
(
errorAnnexe
.
length
!==
0
)
{
let
errorAnnexe
=
<?php
echo
json_encode
(
$
validationErrorsFichier
);
?>
;
if
(
errorAnnexe
&&
errorAnnexe
.
length
!==
0
)
{
let
aAnnexe
=
$
(
'
a[href="#annexe"]
'
);
$
(
aAnnexe
).
parent
().
addClass
(
"
form-error
"
);
$
(
aAnnexe
).
append
(
"
<span class='fa fa-exclamation-circle fa-danger' aria-hidden='true'><
\
/span>
"
);
...
...
app/webroot/js/FormulaireGenerator/createFormulaire.js
View file @
a5a3f3a2
...
...
@@ -980,16 +980,17 @@ let createForm = function(typeCreateForm) {
* @author Théo GUILLON <theo.guillon@libriciel.coop>
*/
function
writeConditionsInOption
(
conditions
,
noTrash
=
true
)
{
let
writeConditions
=
''
;
let
success
=
true
;
let
writeConditions
=
''
,
success
=
true
;
$
.
each
(
JSON
.
parse
(
conditions
),
function
(
key
,
value
)
{
let
field
=
$
(
'
#
'
+
value
[
'
ifTheField
'
]);
let
ifTheField
=
$
(
field
).
labels
().
text
();
let
hasValue
=
$
(
field
).
find
(
'
option[value="
'
+
value
[
'
hasValue
'
]
+
'
"]
'
).
text
();
let
thenTheField
=
$
(
'
label[for="
'
+
value
[
'
thenTheField
'
]
+
'
"]
'
).
text
();
let
mustBe
=
''
;
let
ifNot
=
''
;
let
field
=
$
(
'
#
'
+
value
[
'
ifTheField
'
]),
ifTheField
=
$
(
field
).
labels
().
text
(),
hasValue
=
$
(
field
).
find
(
'
option[value="
'
+
value
[
'
hasValue
'
]
+
'
"]
'
).
text
(),
thenTheField
=
$
(
'
label[for="
'
+
value
[
'
thenTheField
'
]
+
'
"]
'
).
text
(),
mustBe
=
''
,
ifNot
=
''
,
textHasValue
=
''
;
if
(
!
ifTheField
)
{
alert
(
"
Une condition est en erreur !
"
);
...
...
@@ -998,12 +999,27 @@ let createForm = function(typeCreateForm) {
}
if
(
!
hasValue
)
{
// Radios
hasValue
=
$
(
'
input[type="radio"][name="
'
+
value
[
'
ifTheField
'
]
+
'
"][value="
'
+
value
[
'
hasValue
'
]
+
'
"]
'
).
val
();
if
(
Array
.
isArray
(
value
[
'
hasValue
'
])
===
true
||
jQuery
.
isPlainObject
(
value
[
'
hasValue
'
])
===
true
)
{
let
arrayHasValue
=
value
.
hasValue
$
.
each
(
arrayHasValue
,
function
(
k
,
v
)
{
if
(
$
(
field
).
is
(
"
select
"
))
{
hasValue
=
$
(
field
).
find
(
'
option[value="
'
+
v
+
'
"]
'
).
text
();
}
else
{
hasValue
=
$
(
'
input[id="
'
+
v
+
'
"]
'
).
next
(
'
label
'
).
text
();
}
if
(
!
hasValue
)
{
hasValue
=
$
(
'
#
'
+
value
[
'
hasValue
'
]).
labels
().
text
();
textHasValue
=
textHasValue
+
'
<strong>
'
+
'
"
'
+
$
.
trim
(
hasValue
)
+
'
",
'
+
'
</strong>
'
;
});
}
else
{
// Radios
hasValue
=
$
(
'
input[type="radio"][name="
'
+
value
[
'
ifTheField
'
]
+
'
"][value="
'
+
value
[
'
hasValue
'
]
+
'
"]
'
).
val
();
textHasValue
=
'
<strong>
'
+
'
"
'
+
hasValue
+
'
"
'
+
'
</strong>
'
;
}
}
else
{
textHasValue
=
'
<strong>
'
+
'
"
'
+
hasValue
+
'
"
'
+
'
</strong>
'
;
}
if
(
value
[
'
mustBe
'
]
===
'
shown
'
)
{
...
...
@@ -1031,9 +1047,7 @@ let createForm = function(typeCreateForm) {
'
"
'
+
ifTheField
+
'
"
'
+
'
</strong>
'
+
'
a comme valeur
'
+