mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 07:11:18 +02:00
- Removed ambiguous aliases: phpstan, cs-check, syntax - Split lint-biome into lint-css and lint-js with correct paths - Added lint meta-recipe and fix recipe (biome --unsafe + php-cs-fixer) - Fixed FormBootstrap dead null check, CSS shorthand override bug - Updated phpstan baseline, suppressed noDescendingSpecificity/noInnerDeclarations - Applied ~74 biome auto-fixes across CSS/JS
131 lines
4.0 KiB
JavaScript
131 lines
4.0 KiB
JavaScript
/**
|
|
* admin-contenus-motscles.js — Mots-clés management on contenus.php.
|
|
* Bulk merge, delete, toggle-all, sticky bar height tracking.
|
|
*
|
|
* Inline-rename functions (motsclesStartRename, motsclesCancelRename) remain
|
|
* in the template because they embed PHP-generated icon SVGs.
|
|
*/
|
|
var _motsclesPendingForm = null;
|
|
|
|
function _motsclesConfirmDelete(btn, name) {
|
|
_motsclesPendingForm = btn.closest("form");
|
|
document.getElementById("motscles-delete-name").textContent = name;
|
|
document.getElementById("motscles-delete-dialog").showModal();
|
|
}
|
|
|
|
function _motsclesSubmitPending() {
|
|
if (_motsclesPendingForm) _motsclesPendingForm.submit();
|
|
}
|
|
|
|
function _motsclesToggleAll(src) {
|
|
document.querySelectorAll('input[name="selected_tags[]"]').forEach((cb) => {
|
|
cb.checked = src.checked;
|
|
});
|
|
motsclesUpdateBulk();
|
|
}
|
|
|
|
function motsclesUpdateBulk() {
|
|
var n = document.querySelectorAll(
|
|
'input[name="selected_tags[]"]:checked',
|
|
).length;
|
|
document.getElementById("motscles-selected-count").textContent = n;
|
|
var bar = document.getElementById("motscles-bulk-actions");
|
|
var wrap = document.getElementById("motscles-table-wrap");
|
|
var visible = n > 1;
|
|
bar.style.display = visible ? "flex" : "none";
|
|
if (visible) {
|
|
requestAnimationFrame(() => {
|
|
wrap.style.setProperty("--sticky-top", `${bar.offsetHeight}px`);
|
|
});
|
|
} else {
|
|
wrap.style.setProperty("--sticky-top", "0px");
|
|
}
|
|
}
|
|
|
|
function _motsclesConfirmBulkMerge() {
|
|
var checked = document.querySelectorAll(
|
|
'input[name="selected_tags[]"]:checked',
|
|
);
|
|
if (checked.length < 2) return;
|
|
document.getElementById("motscles-bulk-merge-count").textContent =
|
|
checked.length;
|
|
var sel = document.getElementById("motscles-bulk-merge-target-select");
|
|
sel.innerHTML = '<option value="">— Choisir la destination —</option>';
|
|
checked.forEach((cb) => {
|
|
var tr = cb.closest("tr");
|
|
sel.innerHTML +=
|
|
'<option value="' +
|
|
cb.value +
|
|
'">' +
|
|
tr.querySelector("td:nth-child(2)").textContent.trim() +
|
|
"</option>";
|
|
});
|
|
document.getElementById("motscles-bulk-merge-dialog").showModal();
|
|
}
|
|
|
|
function _motsclesExecBulkMerge() {
|
|
var targetId = document.getElementById(
|
|
"motscles-bulk-merge-target-select",
|
|
).value;
|
|
if (!targetId) return;
|
|
document.getElementById("motscles-bulk-target").value = targetId;
|
|
var container = document.getElementById("motscles-bulk-checkboxes");
|
|
container.innerHTML = "";
|
|
document
|
|
.querySelectorAll('input[name="selected_tags[]"]:checked')
|
|
.forEach((cb) => {
|
|
var inp = document.createElement("input");
|
|
inp.type = "hidden";
|
|
inp.name = "selected_tags[]";
|
|
inp.value = cb.value;
|
|
container.appendChild(inp);
|
|
});
|
|
document.getElementById("motscles-bulk-merge-dialog").close();
|
|
document.getElementById("motscles-bulk-form").submit();
|
|
}
|
|
|
|
function _motsclesCancelSelection() {
|
|
document.querySelectorAll('input[name="selected_tags[]"]').forEach((cb) => {
|
|
cb.checked = false;
|
|
});
|
|
motsclesUpdateBulk();
|
|
}
|
|
|
|
function _motsclesConfirmBulkDelete() {
|
|
var checked = document.querySelectorAll(
|
|
'input[name="selected_tags[]"]:checked',
|
|
);
|
|
if (checked.length < 1) return;
|
|
document.getElementById("motscles-bulk-delete-count").textContent =
|
|
checked.length;
|
|
document.getElementById("motscles-bulk-delete-dialog").showModal();
|
|
}
|
|
|
|
function _motsclesExecBulkDelete() {
|
|
var container = document.getElementById("motscles-bulk-checkboxes");
|
|
container.innerHTML = "";
|
|
document
|
|
.querySelectorAll('input[name="selected_tags[]"]:checked')
|
|
.forEach((cb) => {
|
|
var inp = document.createElement("input");
|
|
inp.type = "hidden";
|
|
inp.name = "selected_tags[]";
|
|
inp.value = cb.value;
|
|
container.appendChild(inp);
|
|
});
|
|
document
|
|
.getElementById("motscles-bulk-form")
|
|
.querySelector('input[name="action"]').value = "delete_bulk";
|
|
document.getElementById("motscles-bulk-delete-dialog").close();
|
|
document.getElementById("motscles-bulk-form").submit();
|
|
}
|
|
|
|
document.addEventListener("htmx:afterSwap", (evt) => {
|
|
if (evt.target.id === "motscles-table-wrap") {
|
|
document.querySelectorAll('input[name="selected_tags[]"]').forEach((cb) => {
|
|
cb.addEventListener("change", motsclesUpdateBulk);
|
|
});
|
|
motsclesUpdateBulk();
|
|
}
|
|
});
|