fix: locked_year cleared on edit — populate edit dialog field

The openEditDialog JS function didn't populate the locked_year input
in the edit dialog, and the PHP template didn't pass locked_year as an
argument. Any edit to a link (even just changing the name) would clear
the locked academic year to NULL.

- Pass $linkLockedYear as 5th argument to openEditDialog in the template
- Accept and populate edit-locked-year input in the JS handler
This commit is contained in:
Pontoporeia
2026-07-10 11:56:27 +02:00
parent 1025d99601
commit 08a9b7309f
3 changed files with 4 additions and 2 deletions
+1
View File
@@ -45,3 +45,4 @@
- [x] Close TOC (licence/charte/apropos) and Filtres (search.php) <details> by default on mobile - [x] Close TOC (licence/charte/apropos) and Filtres (search.php) <details> by default on mobile
- [x] Wider heading scale (h1/h2/h3) for apropos/licence/charte pages: step-5 / step-3 / step-1 - [x] Wider heading scale (h1/h2/h3) for apropos/licence/charte pages: step-5 / step-3 / step-1
- [x] Masquer le bloc "Durée" sur la page TFE quand aucune durée n'est encodée (ni pages ni minutes) - [x] Masquer le bloc "Durée" sur la page TFE quand aucune durée n'est encodée (ni pages ni minutes)
- [x] Fix: locked_year cleared on edit — edit dialog didn't populate the field, so any edit cleared the locked academic year
+2 -1
View File
@@ -74,10 +74,11 @@ function _copyTextToClipboard(text) {
.catch(() => {}); .catch(() => {});
} }
window.openEditDialog = (id, name, _hasPassword, expiresVal) => { window.openEditDialog = (id, name, _hasPassword, expiresVal, lockedYear) => {
document.getElementById("edit-link-id").value = id; document.getElementById("edit-link-id").value = id;
document.getElementById("edit-name").value = name || ""; document.getElementById("edit-name").value = name || "";
document.getElementById("edit-expires").value = expiresVal || ""; document.getElementById("edit-expires").value = expiresVal || "";
document.getElementById("edit-locked-year").value = lockedYear || "";
document.getElementById("edit-dialog").showModal(); document.getElementById("edit-dialog").showModal();
}; };
+1 -1
View File
@@ -94,7 +94,7 @@
</button> </button>
<?php endif; ?> <?php endif; ?>
<button type="button" class="admin-icon-btn admin-icon-btn--edit" title="Éditer" <button type="button" class="admin-icon-btn admin-icon-btn--edit" title="Éditer"
onclick="event.stopPropagation(); openEditDialog(<?= $link['id'] ?>, <?= htmlspecialchars(json_encode($linkName), ENT_QUOTES) ?>, <?= $hasLinkPassword ? 'true' : 'false' ?>, <?= htmlspecialchars(json_encode($linkExpiresVal), ENT_QUOTES) ?>)"> onclick="event.stopPropagation(); openEditDialog(<?= $link['id'] ?>, <?= htmlspecialchars(json_encode($linkName), ENT_QUOTES) ?>, <?= $hasLinkPassword ? 'true' : 'false' ?>, <?= htmlspecialchars(json_encode($linkExpiresVal), ENT_QUOTES) ?>, <?= htmlspecialchars(json_encode($linkLockedYear), ENT_QUOTES) ?>)">
<?= icon('pencil-note') ?> <?= icon('pencil-note') ?>
</button> </button>
<form method="post" action="actions/acces-etudiante.php" class="publish-form" onclick="event.stopPropagation()"> <form method="post" action="actions/acces-etudiante.php" class="publish-form" onclick="event.stopPropagation()">