loko/streetup/home/templates/home/_new_inspection_modal.html
2026-07-22 14:48:40 +02:00

79 lines
3.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% load i18n %}
<!-- Modal for choosing inspection type -->
<div class="modal fade" id="newInspectionModal" tabindex="-1" aria-labelledby="newInspectionModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content shadow-lg border-0 rounded-3">
<div class="modal-header bg-light border-0 py-3">
<h5 class="modal-title fs-5 fw-bold text-dark" id="newInspectionModalLabel">
<i class="bi bi-search me-2 text-primary"></i>{% translate "Choisir le type d’inspection" %}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% translate 'Fermer' %}"></button>
</div>
<div class="modal-body d-flex flex-column gap-3 p-4">
{% for config in inspection_configs %}
<button type="button"
class="btn btn-outline-primary text-start py-3 px-4 border-2 rounded-3 hover-scale-btn shadow-sm"
onclick="startInspection('{{ config.thematic.code }}', '{{ config.id }}')">
<div class="d-flex align-items-center justify-content-between mb-1">
<span class="fs-6 fw-bold">{{ config.name }}</span>
<span class="badge text-bg-light border text-muted px-2 py-1 small">
<i class="bi bi-tag-fill me-1 text-secondary"></i>{{ config.thematic.name }}
</span>
</div>
{% if config.description %}
<small class="text-muted d-block lh-sm mt-1">{{ config.description }}</small>
{% endif %}
</button>
{% empty %}
<div class="alert alert-warning border-0 shadow-sm d-flex align-items-center gap-2 mb-0" role="alert">
<i class="bi bi-exclamation-triangle-fill fs-5 text-warning"></i>
<div>
{% translate "Aucun type d'inspection n'est actuellement configuré dans l'administration." %}
</div>
</div>
{% endfor %}
</div>
<div class="modal-footer bg-light border-0 py-2">
<button type="button" class="btn btn-secondary px-3" data-bs-dismiss="modal">{% translate "Annuler" %}</button>
</div>
</div>
</div>
</div>
<script>
function startInspection(thematicCode, configId) {
// Detect if accessing from a mobile client or path
const isMobilePath = window.location.pathname.startsWith('/mobile/');
const isMobileUserAgent = /android|iphone|ipad|ipod|mobile/i.test(navigator.userAgent);
let url = `/interventions/${thematicCode}/add/`;
if (isMobilePath || isMobileUserAgent) {
url = `/mobile/interventions/${thematicCode}/add-mobile/`;
}
// Hide modal cleanly before redirect
const modalEl = document.getElementById('newInspectionModal');
const modal = bootstrap.Modal.getInstance(modalEl);
if (modal) {
modal.hide();
}
// Redirect with config_id parameter
window.location.href = `${url}?inspection_config_id=${configId}`;
}
</script>
<style>
.hover-scale-btn {
transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hover-scale-btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}
</style>