feat: hide standard inspection sections for GIEP-specific inspections

This commit is contained in:
kdeterme 2026-09-25 11:34:04 +02:00
parent b30e65e0a1
commit ca8d8187c1
7 changed files with 97 additions and 40 deletions

View file

@ -1268,7 +1268,7 @@
document.getElementById('map-insp-summary').textContent = insp.details_summary || 'Aucun constat spécifique.'; document.getElementById('map-insp-summary').textContent = insp.details_summary || 'Aucun constat spécifique.';
const notesEl = document.getElementById('map-insp-notes'); const notesEl = document.getElementById('map-insp-notes');
if (notesEl) { if (notesEl) {
if (insp.notes) { if (insp.notes && !insp.is_giep) {
notesEl.textContent = insp.notes; notesEl.textContent = insp.notes;
notesEl.classList.remove('d-none'); notesEl.classList.remove('d-none');
} else { } else {
@ -1422,6 +1422,23 @@
window.currentGiepLocationId = props.location_id || (props.is_location ? objId : null) || objId; 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_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_code').textContent = props.code || props.target_display || (objId ? ('#' + objId) : '-');
document.getElementById('insp_target_name').textContent = props.name || props.name_fr || props.target_display || '-'; document.getElementById('insp_target_name').textContent = props.name || props.name_fr || props.target_display || '-';

View file

@ -37,7 +37,7 @@
<div id="quickInspectionAlert" class="alert alert-danger d-none mb-3"></div> <div id="quickInspectionAlert" class="alert alert-danger d-none mb-3"></div>
<!-- Résultat de contrôle avec boutons colorés --> <!-- Résultat de contrôle avec boutons colorés -->
<div class="mb-3"> <div class="mb-3" id="quickInspResultSection">
<label class="form-label fw-semibold d-block">{% translate "Résultat du contrôle" %} <span class="text-danger">*</span></label> <label class="form-label fw-semibold d-block">{% translate "Résultat du contrôle" %} <span class="text-danger">*</span></label>
<div class="d-flex flex-column gap-2" role="group" aria-label="{% translate 'Résultat' %}"> <div class="d-flex flex-column gap-2" role="group" aria-label="{% translate 'Résultat' %}">
<div class="row g-2"> <div class="row g-2">
@ -83,7 +83,7 @@
</div> </div>
<!-- Section Photos (Mode continu & Fichiers) --> <!-- Section Photos (Mode continu & Fichiers) -->
<div class="card border border-success-subtle mb-3" style="background-color: #e8f6f3;"> <div class="card border border-success-subtle mb-3" style="background-color: #e8f6f3;" id="quickInspPhotosSection">
<div class="card-header bg-transparent border-0 pb-0 pt-2 px-3"> <div class="card-header bg-transparent border-0 pb-0 pt-2 px-3">
<span class="fw-bold text-dark small"><i class="bi bi-camera me-1 text-teal"></i>{% translate "Photos & Fichiers" %}</span> <span class="fw-bold text-dark small"><i class="bi bi-camera me-1 text-teal"></i>{% translate "Photos & Fichiers" %}</span>
</div> </div>
@ -124,7 +124,7 @@
</div> </div>
<!-- Remarques --> <!-- Remarques -->
<div class="mb-3"> <div class="mb-3" id="quickInspNotesSection">
<label class="form-label fw-semibold mb-1">{% translate "Remarques / Remarques du constat" %}</label> <label class="form-label fw-semibold mb-1">{% translate "Remarques / Remarques du constat" %}</label>
<textarea name="notes" id="insp_notes" class="form-control" rows="2" placeholder="{% translate 'Saisir vos remarques ou détails...' %}"></textarea> <textarea name="notes" id="insp_notes" class="form-control" rows="2" placeholder="{% translate 'Saisir vos remarques ou détails...' %}"></textarea>
</div> </div>

View file

@ -1006,7 +1006,7 @@ window.openInspectionDetailModal = openInspectionDetailModal;
const notesCard = document.getElementById('detail-notes-card'); const notesCard = document.getElementById('detail-notes-card');
const notesText = document.getElementById('detail-notes-text'); const notesText = document.getElementById('detail-notes-text');
if (notesCard && notesText) { if (notesCard && notesText) {
if (data.notes) { if (data.notes && !data.is_giep) {
notesText.textContent = data.notes; notesText.textContent = data.notes;
notesCard.classList.remove('d-none'); notesCard.classList.remove('d-none');
} else { } else {

View file

@ -546,25 +546,22 @@
} }
function toggleParentGlobalSections(isGiep) { function toggleParentGlobalSections(isGiep) {
const sectionsToToggle = [ const ids = [
rootModal.querySelector('#quickInspResultSection'), 'quickInspResultSection',
rootModal.querySelector('#editInspResultSection'), 'editInspResultSection',
rootModal.querySelector('#quickInspPhotosSection'), 'quickInspPhotosSection',
rootModal.querySelector('#editInspPhotosSection'), 'editInspPhotosSection',
rootModal.querySelector('#quickInspNotesSection'), 'quickInspNotesSection',
rootModal.querySelector('#editInspNotesSection') 'editInspNotesSection',
'editInspectionExistingDocsContainer'
]; ];
sectionsToToggle.forEach(sec => { ids.forEach(id => {
if (sec) { const el = document.getElementById(id);
if (isGiep) sec.classList.add('d-none'); if (el) {
else sec.classList.remove('d-none'); 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() { function updateSerializedGiepData() {
@ -1605,35 +1602,48 @@
</div> </div>
<!-- Liaison Équipement GIEP / Ouvrage --> <!-- Liaison Équipement GIEP / Ouvrage -->
<div class="border rounded-3 p-2.5 mb-3 bg-white border-primary-subtle shadow-sm"> <div class="border rounded-3 p-3 mb-3 bg-white border-primary-subtle shadow-xs">
<div class="d-flex align-items-center justify-content-between mb-1.5"> <div class="d-flex align-items-center justify-content-between mb-2.5 pb-1 border-bottom border-light-subtle">
<span class="extra-small fw-bold text-primary text-uppercase"> <span class="extra-small fw-bold text-primary text-uppercase tracking-wider">
<i class="bi bi-link-45deg me-1"></i>{% translate "Équipement GIEP associé (Optionnel)" %} <i class="bi bi-link-45deg me-1 fs-6 align-middle"></i>{% translate "Équipement GIEP associé (Optionnel)" %}
</span> </span>
${ouv.asset_id ? `<button type="button" class="btn btn-link text-danger p-0 extra-small text-decoration-none clear-asset-btn" data-idx="${idx}"><i class="bi bi-x-circle me-1"></i>{% translate "Délier" %}</button>` : ''} ${ouv.asset_id ? `<button type="button" class="btn btn-link text-danger p-0 extra-small text-decoration-none clear-asset-btn" data-idx="${idx}"><i class="bi bi-x-circle me-1"></i>{% translate "Délier" %}</button>` : ''}
</div> </div>
${ouv.asset_id ? ` ${ouv.asset_id ? `
<div class="p-2.5 rounded-3 bg-primary-subtle bg-opacity-20 border border-primary-subtle d-flex align-items-center justify-content-between"> <div class="p-3 rounded-3 bg-primary-subtle bg-opacity-25 border border-primary-subtle d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center gap-2"> <div class="d-flex align-items-center gap-3">
<i class="bi bi-geo-alt-fill text-primary fs-5"></i> <div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center shadow-xs" style="width: 38px; height: 38px; min-width: 38px;">
<i class="bi bi-geo-alt-fill fs-5"></i>
</div>
<div> <div>
<strong class="small text-primary d-block">${ouv.asset_code}</strong> <div class="d-flex align-items-center gap-2">
<span class="extra-small text-muted">${ouv.asset_name || ''}</span> <strong class="text-primary fs-6">${ouv.asset_code}</strong>
<span class="badge bg-primary text-white rounded-pill extra-small px-2 py-0.5"><i class="bi bi-check2 me-1"></i>{% translate "Lié" %}</span>
</div>
<div class="small text-muted">${ouv.asset_name || ''}</div>
</div> </div>
</div> </div>
<span class="badge bg-primary text-white rounded-pill extra-small">{% translate "Lié" %}</span> <button type="button" class="btn btn-outline-danger btn-sm px-2.5 py-1 rounded-pill clear-asset-btn d-flex align-items-center gap-1" data-idx="${idx}">
</div> <i class="bi bi-x-circle"></i>
` : ` <span class="extra-small fw-semibold">{% translate "Délier" %}</span>
<div class="position-relative">
<div class="input-group input-group-sm">
<span class="input-group-text bg-white"><i class="bi bi-search text-muted"></i></span>
<input type="text" class="form-control asset-search-input" data-idx="${idx}" placeholder="{% filter escapejs %}{% translate "Rechercher un ouvrage par code ou type..." %}{% endfilter %}" autocomplete="off">
<button type="button" class="btn btn-outline-primary open-map-modal-btn" data-idx="${idx}">
<i class="bi bi-geo-alt-fill me-1"></i>{% translate "Choisir sur la carte" %}
</button> </button>
</div> </div>
<div class="list-group position-absolute w-100 shadow-lg d-none asset-autocomplete-dropdown" data-idx="${idx}" style="z-index: 1050; max-height: 200px; overflow-y: auto; background: white;"></div> ` : `
<div class="d-flex flex-column flex-sm-row gap-2.5 align-items-stretch">
<div class="position-relative flex-grow-1">
<div class="input-group">
<span class="input-group-text bg-white border-end-0 text-muted ps-3 pe-2">
<i class="bi bi-search"></i>
</span>
<input type="text" class="form-control border-start-0 ps-1 py-2 asset-search-input" data-idx="${idx}" placeholder="{% filter escapejs %}{% translate "Rechercher un ouvrage par code ou type..." %}{% endfilter %}" autocomplete="off">
</div>
<div class="list-group position-absolute w-100 shadow-lg d-none asset-autocomplete-dropdown" data-idx="${idx}" style="z-index: 1050; max-height: 220px; overflow-y: auto; background: white;"></div>
</div>
<button type="button" class="btn btn-outline-primary px-3 py-2 d-inline-flex align-items-center justify-content-center gap-2 rounded-2 open-map-modal-btn text-nowrap shadow-xs" data-idx="${idx}">
<i class="bi bi-geo-alt-fill"></i>
<span class="small fw-semibold">{% translate "Choisir sur la carte" %}</span>
</button>
</div> </div>
`} `}
</div> </div>

View file

@ -764,8 +764,18 @@ document.addEventListener('DOMContentLoaded', function() {
// Affichage et préremplissage des champs spécifiques GIEP (GiepInspection) // Affichage et préremplissage des champs spécifiques GIEP (GiepInspection)
const giepFieldsContainer = document.getElementById('editGiepSpecificFieldsContainer'); 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 (data.is_giep) {
if (giepFieldsContainer) giepFieldsContainer.classList.remove('d-none'); 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'); const editModal = document.getElementById('editInspectionModal');
if (editModal && typeof editModal.setGiepFormData === 'function') { if (editModal && typeof editModal.setGiepFormData === 'function') {
editModal.setGiepFormData(data); editModal.setGiepFormData(data);
@ -774,6 +784,10 @@ document.addEventListener('DOMContentLoaded', function() {
} }
} else { } else {
if (giepFieldsContainer) giepFieldsContainer.classList.add('d-none'); 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) // Affichage et préremplissage des champs spécifiques Hot Box (HotBoxInspection)
@ -1029,6 +1043,16 @@ document.addEventListener('DOMContentLoaded', function() {
if (typeof window.toggleEditMissingResultChoice === 'function') { if (typeof window.toggleEditMissingResultChoice === 'function') {
window.toggleEditMissingResultChoice(false); 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');
}); });
} }
}); });

View file

@ -216,6 +216,12 @@ document.addEventListener('DOMContentLoaded', function() {
if (typeof window.toggleMissingResultChoice === 'function') { if (typeof window.toggleMissingResultChoice === 'function') {
window.toggleMissingResultChoice(false); 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');
}); });
} }
}); });

View file

@ -209,7 +209,7 @@
</li> </li>
</ul> </ul>
{% if insp.notes %} {% if insp.notes and not insp.is_giep %}
<div class="card bg-light border-0 p-3 mb-3"> <div class="card bg-light border-0 p-3 mb-3">
<h6 class="fw-bold text-secondary mb-2"><i class="bi bi-journal-text me-2"></i>{% translate "Remarques" %}</h6> <h6 class="fw-bold text-secondary mb-2"><i class="bi bi-journal-text me-2"></i>{% translate "Remarques" %}</h6>
<div class="text-dark small">{{ insp.notes }}</div> <div class="text-dark small">{{ insp.notes }}</div>