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
62d510c0
Commit
62d510c0
authored
Apr 07, 2020
by
Théo GUILLON
Browse files
Modification : mise en place des conditions sur touts les types de champ
parent
995f6d7d
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/View/Elements/Fiches/tabs/formulaire.ctp
View file @
62d510c0
...
...
@@ -146,7 +146,7 @@ $line = 1;
],
'options'
=>
$options
[
'options'
],
'required'
=>
$options
[
'obligatoire'
],
'class'
=>
'
usersDeroulant
transformSelect form-control'
,
'class'
=>
'transformSelect form-control'
,
'empty'
=>
true
,
'placeholder'
=>
false
,
'data-placeholder'
=>
' '
...
...
@@ -275,37 +275,42 @@ $line = 1;
// Mise en place des conditions
var
conditions
=
<?php
echo
json_encode
(
$conditions
);
?>
;
console
.
log
(
conditions
);
$
.
each
(
conditions
,
function
(
key
,
value
)
{
// On cache le champ par défault
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
if
(
jQuery
.
inArray
(
value
[
'
ifTheField
'
],
[
'
transfertHorsUe
'
,
'
donneesSensible
'
])
!==
-
1
)
{
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
val
()
==
value
[
'
hasValue
'
])
{
// Si le champ a comme balise "select" (deroulant)
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
is
(
'
select
'
))
{
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
val
()
==
value
[
'
hasValue
'
])
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
// Quand le champ deroulant change de valeur
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
change
(
function
()
{
if
(
$
(
this
).
val
()
==
value
[
'
hasValue
'
])
{
if
(
jQuery
.
inArray
(
$
(
this
).
val
()
,
value
[
'
hasValue
'
])
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
}
else
{
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
attr
(
'
type
'
)
==
'
radio
'
)
{
}
console
.
log
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
parent
());
// Si le champ a comme balise "input"
if
(
$
(
'
#
'
+
value
[
'
ifTheField
'
]).
is
(
'
input
'
))
{
}
else
{
// Si le champ est de type "checkbox"
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
attr
(
'
type
'
)
==
"
checkbox
"
)
{
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
prop
(
"
checked
"
)
==
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
$
(
'
#
'
+
value
[
'
hasValue
'
]).
on
(
'
change
'
,
function
()
{
// Quand la valeur de la condition change
$
(
'
#
'
+
value
[
'
hasValue
'
]).
on
(
'
change
'
,
function
()
{
if
(
$
(
this
).
prop
(
"
checked
"
)
==
true
)
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
...
...
@@ -313,6 +318,18 @@ $line = 1;
}
});
}
// Si le champ est de type "radio"
if
(
$
(
'
#
'
+
value
[
'
hasValue
'
]).
attr
(
'
type
'
)
==
"
radio
"
)
{
// Quand le champ radio change de valeur
$
(
'
input[type=radio]
'
).
on
(
'
change
'
,
function
()
{
if
(
$
(
this
).
val
()
==
$
(
'
#
'
+
value
[
'
hasValue
'
]).
attr
(
'
value
'
))
{
shownHideField
(
value
[
'
mustBe
'
],
value
[
'
thenTheField
'
])
}
else
{
shownHideField
(
value
[
'
ifNot
'
],
value
[
'
thenTheField
'
]);
}
});
}
}
});
...
...
app/View/Elements/Formulaires/champDuFormulaire.ctp
View file @
62d510c0
...
...
@@ -192,7 +192,7 @@ foreach ($champs as $key => $value) {
}
}
echo
'<option id="'
.
$details
[
'name'
]
.
$key
.
'" class="champNomVariableReadonly" type="deroulant" '
.
$selected
.
' name ="'
.
$details
[
'name'
]
.
'" value="'
.
$
val
.
'">'
.
$val
.
'</option></div>'
;
echo
'<option id="'
.
$details
[
'name'
]
.
$key
.
'" class="champNomVariableReadonly" type="deroulant" '
.
$selected
.
' name ="'
.
$details
[
'name'
]
.
'" value="'
.
$
key
.
'">'
.
$val
.
'</option></div>'
;
}
echo
'</select>'
.
'</div>'
...
...
@@ -211,7 +211,7 @@ foreach ($champs as $key => $value) {
.
'</div>'
.
'<div class="col-md-8">'
.
'<input id="'
.
$details
[
'name'
]
.
'_" type="hidden" name="'
.
$details
[
'name'
]
.
'" value=""/>'
.
'<select name="'
.
$details
[
'name'
]
.
'" class="form-control multiSelect contentMultiSelect" multiple="multiple">'
;
.
'<select
id="'
.
$details
[
'name'
]
.
'"
name="'
.
$details
[
'name'
]
.
'" class="form-control multiSelect contentMultiSelect" multiple="multiple">'
;
foreach
(
$details
[
'options'
]
as
$key
=>
$val
)
{
$selected
=
""
;
if
(
isset
(
$details
[
'default'
]))
{
...
...
@@ -220,7 +220,7 @@ foreach ($champs as $key => $value) {
}
}
echo
'<option id="'
.
$details
[
'name'
]
.
$key
.
'" class="champNomVariableReadonly" '
.
$selected
.
' name="'
.
$details
[
'name'
]
.
'" value="'
.
$
val
.
'"> '
.
$val
.
'</option>'
;
echo
'<option id="'
.
$details
[
'name'
]
.
$key
.
'" class="champNomVariableReadonly" '
.
$selected
.
' name="'
.
$details
[
'name'
]
.
'" value="'
.
$
key
.
'"> '
.
$val
.
'</option>'
;
}
echo
'</select>'
.
'</div>'
...
...
app/View/Elements/Formulaires/modal/modalAddCondition.ctp
View file @
62d510c0
...
...
@@ -179,14 +179,25 @@
});
} else {
// On recupere les "options" du champ "selected" sur lequel nous allons faire la condition
$(idContainer).find('input[name ="'+idFieldConditionCreated+'"], option[name ="'+idFieldConditionCreated+'"]').each(function () {
var option = $(this).attr('value');
var id = $(this).attr('id');
if (option && id) {
$('#hasValue').append('<option value="' + id + '">' + option + '</option>');
}
});
if ($('#'+idFieldConditionCreated).is("select")) {
$(idContainer).find('input[name ="'+idFieldConditionCreated+'"],option[name ="'+idFieldConditionCreated+'"]').each(function () {
var value = $(this).attr('value');
var labelValue = $(this).text();
if (value && labelValue) {
$('#hasValue').append('<option value="' + value + '">' + labelValue + '</option>');
}
});
} else {
$(idContainer).find('input[name ="'+idFieldConditionCreated+'"], option[name ="'+idFieldConditionCreated+'"]').each(function () {
var option = $(this).attr('value');
var id = $(this).attr('id');
if (option && id) {
$('#hasValue').append('<option value="' + id + '">' + option + '</option>');
}
});
}
}
$('#hasValue').parent().parent().show();
...
...
app/webroot/js/FormulaireGenerator/createFormulaire.js
View file @
62d510c0
...
...
@@ -1130,7 +1130,7 @@ var createForm = function(typeCreateForm) {
objet
=
objet
+
'
<option name="
'
+
newNameField
+
'
" value=""></option>
'
;
$
.
each
(
newOptionsField
,
function
(
index
,
value
)
{
objet
=
objet
+
'
<option id="
'
+
newNameField
+
index
+
'
" name="
'
+
newNameField
+
'
" value="
'
+
value
+
'
">
'
+
objet
=
objet
+
'
<option id="
'
+
newNameField
+
index
+
'
" name="
'
+
newNameField
+
'
" value="
'
+
index
+
'
">
'
+
value
+
'
</option>
'
;
});
...
...
@@ -1145,13 +1145,13 @@ var createForm = function(typeCreateForm) {
// Attribution les valeurs au champ "Menu multi-sélect"
if
(
$
(
this
).
hasClass
(
'
multi-select
'
))
{
$
.
each
(
newOptionsField
,
function
(
index
,
value
)
{
objet
=
objet
+
'
<option id="
'
+
newNameField
+
index
+
'
" name="
'
+
newNameField
+
'
" value="
'
+
value
+
'
">
'
+
objet
=
objet
+
'
<option id="
'
+
newNameField
+
index
+
'
" name="
'
+
newNameField
+
'
" value="
'
+
index
+
'
">
'
+
value
+
'
</option>
'
;
});
// add attribute "id"
$
(
idContainer
).
find
(
'
.ui-selected
'
).
find
(
'
input[type="hidden"]
'
).
attr
(
'
id
'
,
newNameField
);
$
(
idContainer
).
find
(
'
.ui-selected
'
).
find
(
'
input[type="hidden"]
'
).
attr
(
'
id
'
,
newNameField
+
'
_
'
);
$
(
idContainer
).
find
(
'
.ui-selected
'
).
find
(
'
input[type="hidden"]
'
).
attr
(
'
name
'
,
newNameField
);
$
(
idContainer
).
find
(
'
.ui-selected
'
).
find
(
'
select
'
).
attr
(
'
name
'
,
newNameField
);
...
...
app/webroot/js/FormulaireGenerator/saveFieldsFormulaire.js
View file @
62d510c0
...
...
@@ -153,8 +153,8 @@ $(document).ready(function () {
options
=
[];
$
(
draggable
).
find
(
'
option
'
).
each
(
function
()
{
if
(
this
.
value
!=
''
)
{
options
.
push
(
this
.
value
);
if
(
$
(
this
).
text
()
)
{
options
.
push
(
$
(
this
).
text
()
);
}
});
objFieldDetails
[
'
options
'
]
=
options
;
...
...
@@ -182,7 +182,9 @@ $(document).ready(function () {
options
=
[];
$
(
draggable
).
find
(
'
option
'
).
each
(
function
()
{
options
.
push
(
$
(
this
).
attr
(
'
value
'
));
if
(
$
(
this
).
text
())
{
options
.
push
(
$
(
this
).
text
());
}
});
objFieldDetails
[
'
options
'
]
=
options
;
...
...
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