forked from FroSteel/Planification
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 763e63d9c6 | |||
| bea236ca88 |
+35
-38
@@ -644,33 +644,18 @@ async function submitDouchette(origin, phpsessid, opts) {
|
|||||||
async function deletePlanningItem(origin, phpsessid, actionId, kind) {
|
async function deletePlanningItem(origin, phpsessid, actionId, kind) {
|
||||||
if (!actionId) throw new Error("actionId manquant");
|
if (!actionId) throw new Error("actionId manquant");
|
||||||
|
|
||||||
// v5.0.1 : plusieurs function_name à tester dans l'ordre (du plus probable
|
// v5.0.14 : confirmé par capture Network réelle — EasyVista utilise
|
||||||
// au moins probable). Le premier qui renvoie 200 ET non-login est considéré OK.
|
// "Planning_delete_absence" pour TOUS les types d'entrée planning (absences,
|
||||||
const fnNames = kind === "reservation"
|
// réservations, événements, etc.). Réponse XML : <Planning_delete_absence>true</...>
|
||||||
? [
|
// On met donc ce nom en PREMIER pour tout, et on garde les autres en fallback.
|
||||||
|
const fnNames = [
|
||||||
|
"Planning_delete_absence", // ← le seul qui marche vraiment côté EV
|
||||||
|
// Fallbacks historiques (au cas où EV change un jour) :
|
||||||
"Planning_delete_reservation",
|
"Planning_delete_reservation",
|
||||||
"delete_reservation",
|
|
||||||
"fc_delete_reservation",
|
|
||||||
"delete_act_reservation",
|
|
||||||
"delete_planning_reservation",
|
|
||||||
"remove_reservation",
|
|
||||||
// v5.0.2 : réservations sont parfois traitées comme absences côté API
|
|
||||||
"Planning_delete_absence",
|
|
||||||
"delete_absence",
|
"delete_absence",
|
||||||
"fc_delete_absence"
|
"delete_reservation",
|
||||||
]
|
"fc_delete_absence",
|
||||||
: [
|
"fc_delete_reservation"
|
||||||
// v5.0.2 : élargir la liste, on a essayé 3 sans succès. Les variantes
|
|
||||||
// plausibles vues dans les API EasyVista :
|
|
||||||
"Planning_delete_absence", // le plus "officiel"
|
|
||||||
"delete_absence", // le nom JS dans le onclick
|
|
||||||
"fc_delete_absence", // pattern fc_*
|
|
||||||
"delete_act_absence", // parfois "act_" dans les noms
|
|
||||||
"Planning_delete_holiday", // en anglais
|
|
||||||
"delete_holiday",
|
|
||||||
"fc_delete_holiday",
|
|
||||||
"delete_planning_absence", // variation complète
|
|
||||||
"remove_absence"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let lastErr = null;
|
let lastErr = null;
|
||||||
@@ -703,22 +688,34 @@ async function deletePlanningItem(origin, phpsessid, actionId, kind) {
|
|||||||
throw new Error("session_expired");
|
throw new Error("session_expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
// v5.0.1 : heuristique pour détecter si la suppression a marché.
|
// v5.0.14 : détection explicite du succès XML observé dans les captures
|
||||||
// v5.0.13 : élargie pour détecter aussi le script de redirection CSRF
|
// réseau : <Planning_delete_absence>true</Planning_delete_absence>
|
||||||
// (si evFetch n'a pas suffi) et les réponses vides.
|
const trimmed = (body || "").trim();
|
||||||
const trimmed = (body || "").trim().toLowerCase();
|
const lower = trimmed.toLowerCase();
|
||||||
const looksLikeError = trimmed.includes("error")
|
|
||||||
|| trimmed.includes("erreur")
|
// Succès explicite : réponse XML du type <X>true</X>
|
||||||
|| trimmed.includes("unknown function")
|
if (/^<\w+>true<\/\w+>\s*$/i.test(trimmed)) {
|
||||||
|| trimmed.includes("fonction inconnue")
|
console.log(`[bg] → SUCCÈS confirmé par XML <...>true</...> avec function_name=${fn}`);
|
||||||
|| trimmed.includes("<html")
|
return { status: r.status, functionName: fn, body: trimmed };
|
||||||
|| trimmed.includes("window.location.href"); // CSRF
|
|
||||||
if (!looksLikeError) {
|
|
||||||
console.log(`[bg] → suppression OK avec function_name=${fn}`);
|
|
||||||
return { status: r.status, functionName: fn, body: body.substring(0, 200) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Détection d'échec : <X>false</X>, erreurs, html, redirect, etc.
|
||||||
|
const looksLikeError = /^<\w+>false<\/\w+>\s*$/i.test(trimmed)
|
||||||
|
|| lower.includes("error")
|
||||||
|
|| lower.includes("erreur")
|
||||||
|
|| lower.includes("unknown function")
|
||||||
|
|| lower.includes("fonction inconnue")
|
||||||
|
|| lower.includes("<html")
|
||||||
|
|| lower.includes("window.location.href");
|
||||||
|
if (looksLikeError) {
|
||||||
console.log(`[bg] → réponse ressemble à une erreur, on tente le prochain nom`);
|
console.log(`[bg] → réponse ressemble à une erreur, on tente le prochain nom`);
|
||||||
lastBody = body;
|
lastBody = body;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Pas d'erreur évidente mais pas de succès explicite non plus
|
||||||
|
// (ex: réponse vide ou "1" ou "ok"). On considère comme succès.
|
||||||
|
console.log(`[bg] → suppression probablement OK (body neutre) avec function_name=${fn}`);
|
||||||
|
return { status: r.status, functionName: fn, body: trimmed.substring(0, 200) };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.message === "session_expired") throw err;
|
if (err.message === "session_expired") throw err;
|
||||||
console.warn(`[bg] erreur avec ${fn}:`, err);
|
console.warn(`[bg] erreur avec ${fn}:`, err);
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Planification",
|
"name": "Planification",
|
||||||
"version": "5.0.13",
|
"version": "5.0.15",
|
||||||
"description": "Vue claire et rapide du planning des techniciens EasyVista. Regroupe interventions et réservations par tech, affiche horaires, contact, lieu, catégorie et statut en un coup d'œil.",
|
"description": "Vue claire et rapide du planning des techniciens EasyVista. Regroupe interventions et réservations par tech, affiche horaires, contact, lieu, catégorie et statut en un coup d'œil.",
|
||||||
"permissions": ["activeTab", "scripting", "storage", "tabs", "alarms"],
|
"permissions": ["activeTab", "scripting", "storage", "tabs", "alarms"],
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
|
|||||||
+23
-6
@@ -689,12 +689,9 @@ html, body {
|
|||||||
.timeline-slot.status-resolved { background: var(--c-resolved); }
|
.timeline-slot.status-resolved { background: var(--c-resolved); }
|
||||||
|
|
||||||
.timeline-slot.kind-absence {
|
.timeline-slot.kind-absence {
|
||||||
background: repeating-linear-gradient(
|
/* v5.0.15 : uni gris-noir au lieu de rayé, plus lisible */
|
||||||
45deg,
|
background: #2a2f36;
|
||||||
var(--text-faint) 0 6px,
|
border-right: 1px solid var(--bg-elevated);
|
||||||
var(--bg-muted) 6px 12px
|
|
||||||
);
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-slot:hover,
|
.timeline-slot:hover,
|
||||||
@@ -1117,6 +1114,26 @@ html, body {
|
|||||||
color: var(--c-reservation);
|
color: var(--c-reservation);
|
||||||
font-family: var(--font);
|
font-family: var(--font);
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
|
/* v5.0.15 : étendre le titre sur toute la largeur de la carte pour le
|
||||||
|
vrai centrage (sinon il n'est centré que dans sa colonne grid) */
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
text-align: center;
|
||||||
|
padding-left: 62px; /* compense la colonne time (58px + gap) */
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* v5.0.15 : absence partielle (demi-journée) affichée comme une row */
|
||||||
|
.iv-ref-header.is-absence-title {
|
||||||
|
color: var(--c-absence, #a0a8b2);
|
||||||
|
font-family: var(--font);
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
text-align: center;
|
||||||
|
padding-left: 62px;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
.intervention-v2.color-absence .intervention-dot {
|
||||||
|
background: var(--c-absence, #2a2f36);
|
||||||
}
|
}
|
||||||
.iv-reservation-par {
|
.iv-reservation-par {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ function deriveShortTitle(iv) {
|
|||||||
|
|
||||||
function deriveColorKey(iv) {
|
function deriveColorKey(iv) {
|
||||||
if (iv.type === "AL-Reservation") return "reservation";
|
if (iv.type === "AL-Reservation") return "reservation";
|
||||||
|
if (iv.type === "AL-Absence") return "absence"; // v5.0.15 : couleur noire/gris foncé
|
||||||
if (iv.ref && /^I\d/.test(iv.ref)) return "incident";
|
if (iv.ref && /^I\d/.test(iv.ref)) return "incident";
|
||||||
if (isRollOut(iv)) return "rollout";
|
if (isRollOut(iv)) return "rollout";
|
||||||
if (isRecupAction(iv)) return "recup";
|
if (isRecupAction(iv)) return "recup";
|
||||||
@@ -4348,7 +4349,21 @@ function buildCard(tech, isoDate) {
|
|||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realInterventions.length === 0 && !isPompier) {
|
// v5.0.14 : si le tech n'a aucune intervention mais a des absences
|
||||||
|
// partielles (demi-journée) ou pompier, on veut quand même afficher la
|
||||||
|
// timeline avec les blocs absence visibles. Sans ça, une absence 08-12
|
||||||
|
// seule n'apparaissait jamais sur la carte (affichait juste "Pas
|
||||||
|
// d'intervention planifiée").
|
||||||
|
const hasPartialAbsences = absenceBlocks.some(ab => {
|
||||||
|
if (ab.isPompier) return false;
|
||||||
|
const s = timeToMinutes(ab.startTime);
|
||||||
|
const e = timeToMinutes(ab.endTime);
|
||||||
|
if (s === null || e === null) return false;
|
||||||
|
// Absence qui couvre PAS toute la journée → c'est partiel
|
||||||
|
return !(s <= DAY_START && e >= DAY_END);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (realInterventions.length === 0 && !isPompier && !hasPartialAbsences) {
|
||||||
if (isPillonelFriday) {
|
if (isPillonelFriday) {
|
||||||
const note = document.createElement("div");
|
const note = document.createElement("div");
|
||||||
note.className = "tech-absence-recurring";
|
note.className = "tech-absence-recurring";
|
||||||
@@ -4398,6 +4413,25 @@ function buildCard(tech, isoDate) {
|
|||||||
body.appendChild(buildInterventionRow(iv, card));
|
body.appendChild(buildInterventionRow(iv, card));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v5.0.15 : afficher aussi les absences partielles (demi-journée) comme
|
||||||
|
// des rows, avec le même style que les réservations mais en gris foncé.
|
||||||
|
// Les absences qui couvrent toute la journée sont déjà traitées plus haut
|
||||||
|
// (carte "Absent toute la journée") et ne doivent pas être dupliquées ici.
|
||||||
|
if (!isAbsent) {
|
||||||
|
const partialAbsences = absenceBlocks.filter(ab => {
|
||||||
|
if (ab.isPompier) return false;
|
||||||
|
const s = timeToMinutes(ab.startTime);
|
||||||
|
const e = timeToMinutes(ab.endTime);
|
||||||
|
if (s === null || e === null) return false;
|
||||||
|
return !(s <= DAY_START && e >= DAY_END);
|
||||||
|
});
|
||||||
|
// Trier par heure de début
|
||||||
|
partialAbsences.sort((a, b) => (a.startTime || "").localeCompare(b.startTime || ""));
|
||||||
|
for (const ab of partialAbsences) {
|
||||||
|
body.appendChild(buildInterventionRow(ab, card));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
card.appendChild(body);
|
card.appendChild(body);
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
@@ -4759,7 +4793,7 @@ function buildInterventionRow(iv, cardEl) {
|
|||||||
cardEl._rowIdxCounter = ivIdx + 1;
|
cardEl._rowIdxCounter = ivIdx + 1;
|
||||||
row.dataset.ivIdx = ivIdx;
|
row.dataset.ivIdx = ivIdx;
|
||||||
|
|
||||||
if (iv.formLink && !iv.ghost) {
|
if (iv.formLink && !iv.ghost && iv.type !== "AL-Absence") {
|
||||||
row.classList.add("clickable");
|
row.classList.add("clickable");
|
||||||
// v4.1.8 : plus de title au survol (info déjà dans le tooltip en bas)
|
// v4.1.8 : plus de title au survol (info déjà dans le tooltip en bas)
|
||||||
|
|
||||||
@@ -4797,6 +4831,10 @@ function buildInterventionRow(iv, cardEl) {
|
|||||||
if (iv.type === "AL-Reservation") {
|
if (iv.type === "AL-Reservation") {
|
||||||
refHeader.textContent = "Réservation";
|
refHeader.textContent = "Réservation";
|
||||||
refHeader.classList.add("is-reservation-title");
|
refHeader.classList.add("is-reservation-title");
|
||||||
|
} else if (iv.type === "AL-Absence") {
|
||||||
|
// v5.0.15 : absence partielle (demi-journée) affichée comme une row
|
||||||
|
refHeader.textContent = "Absence";
|
||||||
|
refHeader.classList.add("is-absence-title");
|
||||||
} else if (iv.ref) {
|
} else if (iv.ref) {
|
||||||
refHeader.textContent = iv.ref;
|
refHeader.textContent = iv.ref;
|
||||||
} else {
|
} else {
|
||||||
@@ -4805,8 +4843,8 @@ function buildInterventionRow(iv, cardEl) {
|
|||||||
}
|
}
|
||||||
row.appendChild(refHeader);
|
row.appendChild(refHeader);
|
||||||
|
|
||||||
// Check ✓ + bouton copier à droite de la ref (pas pour réservation)
|
// Check ✓ + bouton copier à droite de la ref (pas pour réservation / absence)
|
||||||
if (statusClass && iv.type !== "AL-Reservation") {
|
if (statusClass && iv.type !== "AL-Reservation" && iv.type !== "AL-Absence") {
|
||||||
const statusEl = document.createElement("div");
|
const statusEl = document.createElement("div");
|
||||||
statusEl.className = "iv-status-check";
|
statusEl.className = "iv-status-check";
|
||||||
// v4.2.5 : ✓✓ double pour clôturé/résolu (statut officiel EasyVista)
|
// v4.2.5 : ✓✓ double pour clôturé/résolu (statut officiel EasyVista)
|
||||||
@@ -4819,7 +4857,7 @@ function buildInterventionRow(iv, cardEl) {
|
|||||||
}
|
}
|
||||||
row.appendChild(statusEl);
|
row.appendChild(statusEl);
|
||||||
}
|
}
|
||||||
if (iv.ref && iv.type !== "AL-Reservation") {
|
if (iv.ref && iv.type !== "AL-Reservation" && iv.type !== "AL-Absence") {
|
||||||
const copyBtn = document.createElement("button");
|
const copyBtn = document.createElement("button");
|
||||||
copyBtn.className = "intervention-copy";
|
copyBtn.className = "intervention-copy";
|
||||||
copyBtn.type = "button";
|
copyBtn.type = "button";
|
||||||
@@ -4899,6 +4937,40 @@ function buildInterventionRow(iv, cardEl) {
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v5.0.15 : absence partielle (demi-journée) affichée comme une row au
|
||||||
|
// même style que les réservations mais en gris foncé, avec le type d'absence
|
||||||
|
// (Congés, Maladie, Pompier) comme sujet.
|
||||||
|
if (iv.type === "AL-Absence") {
|
||||||
|
// Bloc "Par Nom, Prénom" si on a un créateur
|
||||||
|
if (iv.reservationCreator) {
|
||||||
|
const parEl = document.createElement("div");
|
||||||
|
parEl.className = "iv-reservation-par";
|
||||||
|
parEl.textContent = "Par " + iv.reservationCreator;
|
||||||
|
rightCol.appendChild(parEl);
|
||||||
|
}
|
||||||
|
// Type d'absence (Congés, Maladie, Pompier) si dispo dans label
|
||||||
|
const absenceTypeMatch = (iv.label || "").match(/^([^/]+?)\s*(?:\/|$)/);
|
||||||
|
const absenceType = absenceTypeMatch ? absenceTypeMatch[1].trim() : null;
|
||||||
|
if (absenceType) {
|
||||||
|
const sujetEl = document.createElement("div");
|
||||||
|
sujetEl.className = "iv-reservation-sujet";
|
||||||
|
sujetEl.textContent = "Type : " + absenceType;
|
||||||
|
rightCol.appendChild(sujetEl);
|
||||||
|
}
|
||||||
|
row.appendChild(rightCol);
|
||||||
|
|
||||||
|
// Tooltip au hover (avec bouton supprimer)
|
||||||
|
row.addEventListener("mouseenter", (e) => {
|
||||||
|
showTooltip(e, iv, row);
|
||||||
|
highlightIntervention(cardEl, ivIdx, true);
|
||||||
|
});
|
||||||
|
row.addEventListener("mouseleave", () => {
|
||||||
|
hideTooltip();
|
||||||
|
highlightIntervention(cardEl, ivIdx, false);
|
||||||
|
});
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
// v4.1.2 : priorité à iv.infobulle (venant du xhr2 = données réelles vérifiées
|
// v4.1.2 : priorité à iv.infobulle (venant du xhr2 = données réelles vérifiées
|
||||||
// par le tech sur place) puis fallback sur iv.bulleContact/iv.bulleLieu
|
// par le tech sur place) puis fallback sur iv.bulleContact/iv.bulleLieu
|
||||||
// (venant de attr1/attr2 = planification initiale, parfois incorrecte).
|
// (venant de attr1/attr2 = planification initiale, parfois incorrecte).
|
||||||
|
|||||||
Reference in New Issue
Block a user