From ca8d8187c19039fcd81d182adb10f1493bdf121e Mon Sep 17 00:00:00 2001 From: kdeterme Date: Fri, 25 Sep 2026 11:34:04 +0200 Subject: [PATCH] feat: hide standard inspection sections for GIEP-specific inspections --- loko/assets/static/assets/inspection_map.js | 19 ++++- .../components/inspection_form_modal.html | 6 +- .../static/inspections/inspections_index.js | 2 +- .../components/asset_fields/_naturerwiz.html | 78 +++++++++++-------- .../components/edit_inspection_modal.html | 24 ++++++ .../components/inspection_form_modal.html | 6 ++ .../interventions/detail/card_controles.html | 2 +- 7 files changed, 97 insertions(+), 40 deletions(-) diff --git a/loko/assets/static/assets/inspection_map.js b/loko/assets/static/assets/inspection_map.js index 4dbcdc6..e9dfb3a 100644 --- a/loko/assets/static/assets/inspection_map.js +++ b/loko/assets/static/assets/inspection_map.js @@ -1268,7 +1268,7 @@ document.getElementById('map-insp-summary').textContent = insp.details_summary || 'Aucun constat spécifique.'; const notesEl = document.getElementById('map-insp-notes'); if (notesEl) { - if (insp.notes) { + if (insp.notes && !insp.is_giep) { notesEl.textContent = insp.notes; notesEl.classList.remove('d-none'); } else { @@ -1422,6 +1422,23 @@ window.currentGiepLocationId = props.location_id || (props.is_location ? objId : null) || objId; } + const isGiep = (modelName === 'naturerwiz' || isZoneRwiz); + const quickNotesSection = document.getElementById('quickInspNotesSection'); + const quickResultSection = document.getElementById('quickInspResultSection'); + const quickPhotosSection = document.getElementById('quickInspPhotosSection'); + if (quickNotesSection) { + if (isGiep) quickNotesSection.classList.add('d-none'); + else quickNotesSection.classList.remove('d-none'); + } + if (quickResultSection) { + if (isGiep) quickResultSection.classList.add('d-none'); + else quickResultSection.classList.remove('d-none'); + } + if (quickPhotosSection) { + if (isGiep) quickPhotosSection.classList.add('d-none'); + else quickPhotosSection.classList.remove('d-none'); + } + document.getElementById('insp_target_type').textContent = props.element_type || props.asset_type_display || props.model_name || 'Asset'; document.getElementById('insp_target_code').textContent = props.code || props.target_display || (objId ? ('#' + objId) : '-'); document.getElementById('insp_target_name').textContent = props.name || props.name_fr || props.target_display || '-'; diff --git a/loko/assets/templates/assets/components/inspection_form_modal.html b/loko/assets/templates/assets/components/inspection_form_modal.html index 45e92f8..1c4b64f 100644 --- a/loko/assets/templates/assets/components/inspection_form_modal.html +++ b/loko/assets/templates/assets/components/inspection_form_modal.html @@ -37,7 +37,7 @@
-
+
@@ -83,7 +83,7 @@
-
+
{% translate "Photos & Fichiers" %}
@@ -124,7 +124,7 @@
-
+
diff --git a/loko/inspections/static/inspections/inspections_index.js b/loko/inspections/static/inspections/inspections_index.js index 4c6ef3d..05c20e6 100644 --- a/loko/inspections/static/inspections/inspections_index.js +++ b/loko/inspections/static/inspections/inspections_index.js @@ -1006,7 +1006,7 @@ window.openInspectionDetailModal = openInspectionDetailModal; const notesCard = document.getElementById('detail-notes-card'); const notesText = document.getElementById('detail-notes-text'); if (notesCard && notesText) { - if (data.notes) { + if (data.notes && !data.is_giep) { notesText.textContent = data.notes; notesCard.classList.remove('d-none'); } else { diff --git a/loko/inspections/templates/inspections/components/asset_fields/_naturerwiz.html b/loko/inspections/templates/inspections/components/asset_fields/_naturerwiz.html index 855952e..5e2370e 100644 --- a/loko/inspections/templates/inspections/components/asset_fields/_naturerwiz.html +++ b/loko/inspections/templates/inspections/components/asset_fields/_naturerwiz.html @@ -546,25 +546,22 @@ } function toggleParentGlobalSections(isGiep) { - const sectionsToToggle = [ - rootModal.querySelector('#quickInspResultSection'), - rootModal.querySelector('#editInspResultSection'), - rootModal.querySelector('#quickInspPhotosSection'), - rootModal.querySelector('#editInspPhotosSection'), - rootModal.querySelector('#quickInspNotesSection'), - rootModal.querySelector('#editInspNotesSection') + const ids = [ + 'quickInspResultSection', + 'editInspResultSection', + 'quickInspPhotosSection', + 'editInspPhotosSection', + 'quickInspNotesSection', + 'editInspNotesSection', + 'editInspectionExistingDocsContainer' ]; - sectionsToToggle.forEach(sec => { - if (sec) { - if (isGiep) sec.classList.add('d-none'); - else sec.classList.remove('d-none'); + ids.forEach(id => { + const el = document.getElementById(id); + if (el) { + if (isGiep) el.classList.add('d-none'); + else el.classList.remove('d-none'); } }); - - const editExistingDocs = rootModal.querySelector('#editInspectionExistingDocsContainer'); - if (editExistingDocs && isGiep) { - editExistingDocs.classList.add('d-none'); - } } function updateSerializedGiepData() { @@ -1605,35 +1602,48 @@
-
-
- - {% translate "Équipement GIEP associé (Optionnel)" %} +
+
+ + {% translate "Équipement GIEP associé (Optionnel)" %} ${ouv.asset_id ? `` : ''}
${ouv.asset_id ? ` -
-
- +
+
+
+ +
- ${ouv.asset_code} - ${ouv.asset_name || ''} +
+ ${ouv.asset_code} + {% translate "Lié" %} +
+
${ouv.asset_name || ''}
- {% translate "Lié" %} +
` : ` -
-
- - - +
+
+
+ + + + +
+
-
+
`}
diff --git a/loko/inspections/templates/inspections/components/edit_inspection_modal.html b/loko/inspections/templates/inspections/components/edit_inspection_modal.html index 1062a69..e2e738b 100644 --- a/loko/inspections/templates/inspections/components/edit_inspection_modal.html +++ b/loko/inspections/templates/inspections/components/edit_inspection_modal.html @@ -764,8 +764,18 @@ document.addEventListener('DOMContentLoaded', function() { // Affichage et préremplissage des champs spécifiques GIEP (GiepInspection) const giepFieldsContainer = document.getElementById('editGiepSpecificFieldsContainer'); + const editNotesSection = document.getElementById('editInspNotesSection'); + const editResultSection = document.getElementById('editInspResultSection'); + const editPhotosSection = document.getElementById('editInspPhotosSection'); + const editExistingDocs = document.getElementById('editInspectionExistingDocsContainer'); + if (data.is_giep) { if (giepFieldsContainer) giepFieldsContainer.classList.remove('d-none'); + if (editNotesSection) editNotesSection.classList.add('d-none'); + if (editResultSection) editResultSection.classList.add('d-none'); + if (editPhotosSection) editPhotosSection.classList.add('d-none'); + if (editExistingDocs) editExistingDocs.classList.add('d-none'); + const editModal = document.getElementById('editInspectionModal'); if (editModal && typeof editModal.setGiepFormData === 'function') { editModal.setGiepFormData(data); @@ -774,6 +784,10 @@ document.addEventListener('DOMContentLoaded', function() { } } else { if (giepFieldsContainer) giepFieldsContainer.classList.add('d-none'); + if (editNotesSection) editNotesSection.classList.remove('d-none'); + if (editResultSection) editResultSection.classList.remove('d-none'); + if (editPhotosSection) editPhotosSection.classList.remove('d-none'); + if (editExistingDocs) editExistingDocs.classList.remove('d-none'); } // Affichage et préremplissage des champs spécifiques Hot Box (HotBoxInspection) @@ -1029,6 +1043,16 @@ document.addEventListener('DOMContentLoaded', function() { if (typeof window.toggleEditMissingResultChoice === 'function') { window.toggleEditMissingResultChoice(false); } + const editNotesSection = document.getElementById('editInspNotesSection'); + if (editNotesSection) editNotesSection.classList.remove('d-none'); + const editResultSection = document.getElementById('editInspResultSection'); + if (editResultSection) editResultSection.classList.remove('d-none'); + const editPhotosSection = document.getElementById('editInspPhotosSection'); + if (editPhotosSection) editPhotosSection.classList.remove('d-none'); + const editExistingDocs = document.getElementById('editInspectionExistingDocsContainer'); + if (editExistingDocs) editExistingDocs.classList.remove('d-none'); + const giepFieldsContainer = document.getElementById('editGiepSpecificFieldsContainer'); + if (giepFieldsContainer) giepFieldsContainer.classList.add('d-none'); }); } }); diff --git a/loko/inspections/templates/inspections/components/inspection_form_modal.html b/loko/inspections/templates/inspections/components/inspection_form_modal.html index f2df967..6e899b1 100644 --- a/loko/inspections/templates/inspections/components/inspection_form_modal.html +++ b/loko/inspections/templates/inspections/components/inspection_form_modal.html @@ -216,6 +216,12 @@ document.addEventListener('DOMContentLoaded', function() { if (typeof window.toggleMissingResultChoice === 'function') { window.toggleMissingResultChoice(false); } + const notesSection = document.getElementById('quickInspNotesSection'); + if (notesSection) notesSection.classList.remove('d-none'); + const resultSection = document.getElementById('quickInspResultSection'); + if (resultSection) resultSection.classList.remove('d-none'); + const photosSection = document.getElementById('quickInspPhotosSection'); + if (photosSection) photosSection.classList.remove('d-none'); }); } }); diff --git a/loko/interventions/templates/interventions/detail/card_controles.html b/loko/interventions/templates/interventions/detail/card_controles.html index c8d5af0..16f40c8 100644 --- a/loko/interventions/templates/interventions/detail/card_controles.html +++ b/loko/interventions/templates/interventions/detail/card_controles.html @@ -209,7 +209,7 @@ - {% if insp.notes %} + {% if insp.notes and not insp.is_giep %}
{% translate "Remarques" %}
{{ insp.notes }}