Correction des erreurs dans l'édition des booléens

This commit is contained in:
leosw
2026-01-20 20:15:50 +01:00
parent 04ecae8211
commit 5f07c557f5
3 changed files with 43 additions and 32 deletions

View File

@@ -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>