fix(rc): armer modal projet avec tarifRC/tarif fallback
This commit is contained in:
parent
bb695a820e
commit
b35d64a241
|
|
@ -39,10 +39,10 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
client = contrat?.["@expand"]?.client || null;
|
client = contrat?.["@expand"]?.client || null;
|
||||||
intermediaire = contrat?.["@expand"]?.intermediaire || null;
|
intermediaire = contrat?.["@expand"]?.intermediaire || null;
|
||||||
|
|
||||||
// Récupérer les données RC depuis la nouvelle structure (EXACTEMENT comme TPPC)
|
// Récupérer les données RC depuis la structure actuelle.
|
||||||
rc = contrat?.["@expand"]?.enCours || null; // RC principal
|
rc = contrat?.["@expand"]?.enCours || null; // RC principal
|
||||||
projet = rc?.["@expand"]?.projet || null; // Données projet (normalized by contratService)
|
projet = rc?.["@expand"]?.projetRC || rc?.["@expand"]?.projet || rc?.projetRC || rc?.projet || null;
|
||||||
tarif = rc?.["@expand"]?.tarif || null; // Données tarif (normalized by contratService)
|
tarif = rc?.["@expand"]?.tarifRC || rc?.["@expand"]?.tarif || rc?.tarifRC || rc?.tarif || null;
|
||||||
|
|
||||||
// Exposer ces variables globalement pour que rc-orchestrator puisse y accéder
|
// Exposer ces variables globalement pour que rc-orchestrator puisse y accéder
|
||||||
window.rc = rc;
|
window.rc = rc;
|
||||||
|
|
@ -65,6 +65,17 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
|
|
||||||
let tarifOriginalData = null;
|
let tarifOriginalData = null;
|
||||||
|
|
||||||
|
function getLinkedTarifId() {
|
||||||
|
if (tarif && typeof tarif === 'object' && tarif.id) return tarif.id;
|
||||||
|
if (typeof rc?.tarifRC === 'string' && rc.tarifRC.trim()) return rc.tarifRC;
|
||||||
|
if (typeof rc?.tarif === 'string' && rc.tarif.trim()) return rc.tarif;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasTarifReference() {
|
||||||
|
return Boolean(getLinkedTarifId());
|
||||||
|
}
|
||||||
|
|
||||||
async function loadModulateurs() {
|
async function loadModulateurs() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/rc/modulo/activiteRCC');
|
const response = await fetch('/rc/modulo/activiteRCC');
|
||||||
|
|
@ -98,7 +109,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveOriginalTarifData() {
|
function saveOriginalTarifData() {
|
||||||
if (!tarif || !tarif.id) return;
|
if (!hasTarifReference()) return;
|
||||||
|
|
||||||
const garantieRCCSelector = document.getElementById('garantieRCC-selector');
|
const garantieRCCSelector = document.getElementById('garantieRCC-selector');
|
||||||
let garantiesRCC = [];
|
let garantiesRCC = [];
|
||||||
|
|
@ -799,7 +810,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
function promptTarifImpactIfNeeded(context = {}) {
|
function promptTarifImpactIfNeeded(context = {}) {
|
||||||
if (isRestoringValue || isTarifImpactModalOpen || !tarif || !tarif.id || !tarifOriginalData) return false;
|
if (isRestoringValue || isTarifImpactModalOpen || !hasTarifReference() || !tarifOriginalData) return false;
|
||||||
|
|
||||||
const isImpacting = typeof context.isImpacting === 'function'
|
const isImpacting = typeof context.isImpacting === 'function'
|
||||||
? Boolean(context.isImpacting())
|
? Boolean(context.isImpacting())
|
||||||
|
|
@ -831,7 +842,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupTarifImpactListeners() {
|
function setupTarifImpactListeners() {
|
||||||
if (!tarif || !tarif.id) return;
|
if (!hasTarifReference()) return;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
saveOriginalTarifData();
|
saveOriginalTarifData();
|
||||||
|
|
@ -869,7 +880,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
const originalSelection = [...lastActivitySelection];
|
const originalSelection = [...lastActivitySelection];
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkActivityImpact(getCurrentActivityData()),
|
isImpacting: () => checkActivityImpact(getCurrentActivityData()),
|
||||||
|
|
@ -903,7 +914,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
const originalSelection = lastMarchandiseSelection;
|
const originalSelection = lastMarchandiseSelection;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkMarchandiseImpact(getCurrentMarchandiseData()),
|
isImpacting: () => checkMarchandiseImpact(getCurrentMarchandiseData()),
|
||||||
restore: () => restoreChangedFieldValue(this, originalSelection),
|
restore: () => restoreChangedFieldValue(this, originalSelection),
|
||||||
|
|
@ -941,7 +952,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkZoneImpact(getCurrentZoneData()),
|
isImpacting: () => checkZoneImpact(getCurrentZoneData()),
|
||||||
restore: () => restoreZoneState(previousZones)
|
restore: () => restoreZoneState(previousZones)
|
||||||
|
|
@ -967,7 +978,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
if (isRestoringValue) return;
|
if (isRestoringValue) return;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
const originalSelection = [...lastGarantieRCCSelection];
|
const originalSelection = [...lastGarantieRCCSelection];
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkGarantieRCCImpact(getCurrentGarantieRCCData()),
|
isImpacting: () => checkGarantieRCCImpact(getCurrentGarantieRCCData()),
|
||||||
|
|
@ -1006,7 +1017,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
const originalChecked = this.dataset.tarifPrevChecked === 'true';
|
const originalChecked = this.dataset.tarifPrevChecked === 'true';
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkActiviteComplImpact(getCurrentActiviteComplData()),
|
isImpacting: () => checkActiviteComplImpact(getCurrentActiviteComplData()),
|
||||||
restore: () => restoreChangedFieldValue(this, originalChecked)
|
restore: () => restoreChangedFieldValue(this, originalChecked)
|
||||||
|
|
@ -1031,7 +1042,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
if (isRestoringValue) return;
|
if (isRestoringValue) return;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
const stateToRestore = previousCotisationState;
|
const stateToRestore = previousCotisationState;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkCotisationImpact(),
|
isImpacting: () => checkCotisationImpact(),
|
||||||
|
|
@ -1066,7 +1077,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
if (isRestoringValue) return;
|
if (isRestoringValue) return;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkCapitalImpactByField(this.id, this.value),
|
isImpacting: () => checkCapitalImpactByField(this.id, this.value),
|
||||||
restore: () => restoreChangedFieldValue(this, originalValue),
|
restore: () => restoreChangedFieldValue(this, originalValue),
|
||||||
|
|
@ -1118,7 +1129,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkPJImpact(),
|
isImpacting: () => checkPJImpact(),
|
||||||
restore: () => restorePJState(stateToRestore),
|
restore: () => restorePJState(stateToRestore),
|
||||||
|
|
@ -1150,7 +1161,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkRCEImpact(),
|
isImpacting: () => checkRCEImpact(),
|
||||||
restore: () => restoreRCEState(stateToRestore),
|
restore: () => restoreRCEState(stateToRestore),
|
||||||
|
|
@ -1177,7 +1188,7 @@ window.initSubmenuForm = initSubmenuForm;// Module IIFE pour éviter la pollutio
|
||||||
if (isRestoringValue) return;
|
if (isRestoringValue) return;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tarif || !tarif.id || !tarifOriginalData || isRestoringValue) return;
|
if (!hasTarifReference() || !tarifOriginalData || isRestoringValue) return;
|
||||||
const previousType = this.dataset.tarifPrevType || '';
|
const previousType = this.dataset.tarifPrevType || '';
|
||||||
if (promptTarifImpactIfNeeded({
|
if (promptTarifImpactIfNeeded({
|
||||||
isImpacting: () => checkTypeExtConfiesImpact(),
|
isImpacting: () => checkTypeExtConfiesImpact(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue