Correction des erreurs dans l'édition des booléens
This commit is contained in:
@@ -31,11 +31,13 @@ switch ($controller->splitted_url[1]) {
|
|||||||
if (isset($_POST[$key])) {
|
if (isset($_POST[$key])) {
|
||||||
$value = $_POST[$key];
|
$value = $_POST[$key];
|
||||||
|
|
||||||
if (str_starts_with($key, 'b_')) {
|
if (str_starts_with($key, 'b_')) {
|
||||||
// 3 états : 1 = oui, 0 = non, -1 = non renseigné
|
if ($value === "0" || $value === "1" || $value === "2") {
|
||||||
$params[$key] = ($value === "1" ? 1 :
|
$params[$key] = intval($value);
|
||||||
($value === "0" ? 0 : -1));
|
} else {
|
||||||
}
|
$params[$key] = -1; // non renseigné
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif (str_starts_with($key, 'n_')) {
|
elseif (str_starts_with($key, 'n_')) {
|
||||||
$params[$key] = is_numeric($value) ? (0 + $value) : null;
|
$params[$key] = is_numeric($value) ? (0 + $value) : null;
|
||||||
}
|
}
|
||||||
@@ -158,11 +160,13 @@ switch ($controller->splitted_url[1]) {
|
|||||||
if (isset($_POST[$key])) {
|
if (isset($_POST[$key])) {
|
||||||
$value = $_POST[$key];
|
$value = $_POST[$key];
|
||||||
|
|
||||||
if (str_starts_with($key, 'b_')) {
|
if (str_starts_with($key, 'b_')) {
|
||||||
// 3 états : 1 = oui, 0 = non, -1 = non renseigné
|
if ($value === "0" || $value === "1" || $value === "2") {
|
||||||
$params[$key] = ($value === "1" ? 1 :
|
$params[$key] = intval($value);
|
||||||
($value === "0" ? 0 : -1));
|
} else {
|
||||||
}
|
$params[$key] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif (str_starts_with($key, 'n_')) {
|
elseif (str_starts_with($key, 'n_')) {
|
||||||
$params[$key] = is_numeric($value) ? (0 + $value) : null;
|
$params[$key] = is_numeric($value) ? (0 + $value) : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,19 +62,22 @@ var unsaved = false;
|
|||||||
function update3State(id) {
|
function update3State(id) {
|
||||||
var input = $("input[name="+id+"]");
|
var input = $("input[name="+id+"]");
|
||||||
var label = $("label[for="+id+"]");
|
var label = $("label[for="+id+"]");
|
||||||
switch (+input.val()) {
|
|
||||||
case 0:
|
var v = parseInt(input.val(), 10);
|
||||||
input.val(1);
|
|
||||||
label.toggleClass('uncheck intermediate');
|
// cycle propre : 0 → 1 → 2 → 0
|
||||||
break;
|
if (v === 0) v = 1;
|
||||||
case 1:
|
else if (v === 1) v = 2;
|
||||||
input.val(2);
|
else v = 0;
|
||||||
label.toggleClass('intermediate check');
|
|
||||||
break;
|
input.val(v);
|
||||||
default:
|
|
||||||
input.val(0);
|
label.removeClass("uncheck intermediate check");
|
||||||
label.toggleClass('check uncheck');
|
|
||||||
}
|
if (v === 0) label.addClass("uncheck");
|
||||||
|
if (v === 1) label.addClass("intermediate");
|
||||||
|
if (v === 2) label.addClass("check");
|
||||||
|
|
||||||
unsaved = true;
|
unsaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,12 +98,16 @@ function updateForm(type) {
|
|||||||
case 'b':
|
case 'b':
|
||||||
var cls = 'intermediate';
|
var cls = 'intermediate';
|
||||||
var val = 1;
|
var val = 1;
|
||||||
|
|
||||||
if (existing == 0) {
|
if (existing == 0) {
|
||||||
cls = 'uncheck';
|
cls = 'uncheck';
|
||||||
val = 0;
|
val = 0;
|
||||||
} else if (existing == 2) {
|
} else if (existing == 2) {
|
||||||
cls = 'check';
|
cls = 'check';
|
||||||
val = 2;
|
val = 2;
|
||||||
|
} else if (existing == -1 || existing === null) {
|
||||||
|
cls = 'intermediate';
|
||||||
|
val = 1;
|
||||||
}
|
}
|
||||||
html_form +=
|
html_form +=
|
||||||
'<label class="threecb ' + cls + '" for="' + index + '" onclick="update3State(\'' + index + '\')">' +
|
'<label class="threecb ' + cls + '" for="' + index + '" onclick="update3State(\'' + index + '\')">' +
|
||||||
@@ -160,10 +167,7 @@ $(document).ready(function(){
|
|||||||
if (current_poi_type) {
|
if (current_poi_type) {
|
||||||
updateForm(current_poi_type);
|
updateForm(current_poi_type);
|
||||||
}
|
}
|
||||||
|
unsaved = !is_new;
|
||||||
if (poi_mode === "edit") {
|
|
||||||
unsaved = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#type_selector label').click(function(){
|
$('#type_selector label').click(function(){
|
||||||
|
|
||||||
@@ -219,10 +223,12 @@ $( "#name" ).change(function() {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
<? if($poi->lat != null && $poi->lon != null) { ?>
|
||||||
var poi_lat = <?=$poi->lat?>;
|
var poi_lat = <?=$poi->lat?>;
|
||||||
var poi_lon = <?=$poi->lon?>;
|
var poi_lon = <?=$poi->lon?>;
|
||||||
|
<? } ?>
|
||||||
var poi_type = "<?=$poi->poi_type?>";
|
var poi_type = "<?=$poi->poi_type?>";
|
||||||
var poi_mode = "edit";
|
var is_new = <?= isset($new) && $new == 1 ? "true" : "false" ?>;
|
||||||
var root = "<?=$config['rel_root_folder']?>";
|
var root = "<?=$config['rel_root_folder']?>";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -145,11 +145,12 @@
|
|||||||
<div class="bool-row values">
|
<div class="bool-row values">
|
||||||
<?php foreach ($bool_fields as $key => $label): ?>
|
<?php foreach ($bool_fields as $key => $label): ?>
|
||||||
<?php
|
<?php
|
||||||
$value = $values[$key] ?? -1;
|
$value = $values[$key] ?? 2;
|
||||||
$icon = [
|
$icon = [
|
||||||
-1 => "<span class='boolean-pill boolean-yes'>✔️</span>",
|
0 => "<span class='boolean-pill boolean-no'>❌</span>",
|
||||||
0 => "<span class='boolean-pill boolean-no'>❌</span>",
|
1 => "<span class='boolean-pill boolean-maybe'>❓</span>",
|
||||||
1 => "<span class='boolean-pill boolean-unknown'>❓</span>"
|
2 => "<span class='boolean-pill boolean-yes'>✔️</span>",
|
||||||
|
-1 => "<span class='boolean-pill boolean-unknown'>➖</span>"
|
||||||
][$value];
|
][$value];
|
||||||
?>
|
?>
|
||||||
<div class="bool-cell">
|
<div class="bool-cell">
|
||||||
|
|||||||
Reference in New Issue
Block a user