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