Skip to content

Commit e85ef71

Browse files
committed
Prend en compte l'identification manuelle resolue
1 parent daaf566 commit e85ef71

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

forms/fagerh/index.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8431,10 +8431,20 @@ <h2>Validation finale</h2>
84318431
});
84328432

84338433
function validateIdent() {
8434-
const ok = identInputs.every(i => String(i.value || '').trim() !== '');
8434+
const manualResolved = !!manualResolvedRecord;
8435+
const resolvedRaisonSociale = String(manualResolvedRecord?.record?.raisonSociale || '').trim();
8436+
const resolvedDepartement = String(manualResolvedRecord?.record?.departement || '').trim().toUpperCase();
8437+
const esNomValue = manualResolved ? resolvedRaisonSociale : String(document.getElementById('es_nom')?.value || '').trim();
8438+
const deptValue = manualResolved ? resolvedDepartement : String(deptInput?.value || '').trim();
8439+
const ok = [
8440+
esNomValue,
8441+
String(document.getElementById('v_nom')?.value || '').trim(),
8442+
String(document.getElementById('v_prenom')?.value || '').trim(),
8443+
String(document.getElementById('v_email')?.value || '').trim(),
8444+
deptValue,
8445+
].every((value) => value !== '');
84358446
const email = document.getElementById('v_email').value.trim();
84368447
const emailOk = !email || /^[^\s@]+@(?:[^\s@.]+\.)+[^\s@.]{2,}$/.test(email);
8437-
const deptValue = String(deptInput?.value || '').trim();
84388448
const deptOk = isValidDept(deptValue);
84398449
const noFinessMode = isNoFinessMode();
84408450
const allFiness = collectFinessInputs();
@@ -8514,7 +8524,7 @@ <h2>Validation finale</h2>
85148524
if (state === 'invalid') input.classList.add('field-input-invalid');
85158525
};
85168526

8517-
setFieldState(document.getElementById('es_nom'), document.getElementById('es_nom').value.trim() ? 'valid' : 'pending');
8527+
setFieldState(document.getElementById('es_nom'), esNomValue ? 'valid' : 'pending');
85188528
setFieldState(document.getElementById('v_nom'), document.getElementById('v_nom').value.trim() ? 'valid' : 'pending');
85198529
setFieldState(document.getElementById('v_prenom'), document.getElementById('v_prenom').value.trim() ? 'valid' : 'pending');
85208530
setFieldState(document.getElementById('v_email'), !email ? 'pending' : (emailOk ? 'valid' : 'invalid'));
@@ -8543,11 +8553,11 @@ <h2>Validation finale</h2>
85438553
}
85448554
if (finessMsg) {
85458555
const missingIdentFields = [];
8546-
if (!String(document.getElementById('es_nom')?.value || '').trim()) missingIdentFields.push("raison sociale");
8556+
if (!esNomValue) missingIdentFields.push("raison sociale");
85478557
if (!String(document.getElementById('v_nom')?.value || '').trim()) missingIdentFields.push("nom");
85488558
if (!String(document.getElementById('v_prenom')?.value || '').trim()) missingIdentFields.push("prenom");
85498559
if (!String(document.getElementById('v_email')?.value || '').trim()) missingIdentFields.push("email");
8550-
if (!String(deptInput?.value || '').trim()) missingIdentFields.push("departement");
8560+
if (!deptValue) missingIdentFields.push("departement");
85518561
const mainInput = document.getElementById('finess');
85528562
const mainValue = String(mainInput?.value || '').trim();
85538563
const mainLookupFound = mainInput?.dataset.lookupFound === '1';

0 commit comments

Comments
 (0)