update form veh 27nov
This commit is contained in:
Vendored
BIN
Binary file not shown.
+110
-21
@@ -71,11 +71,13 @@
|
|||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div class="page-eyebrow">Vehículos</div>
|
<div class="page-eyebrow">Vehículos</div>
|
||||||
<div class="page-title">{{ 'Editar vehículo ' ~ vehiculo['m_oficial'] if vehiculo else 'Nuevo vehículo' }}</div>
|
|
||||||
|
|
||||||
<div class="page-subtitle">
|
<div class="page-title" style="float:left; opacity: 0.7;">{{ 'Editar vehículo ' ~ vehiculo['m_oficial'] if vehiculo else 'Nuevo vehículo' }}</div>
|
||||||
|
<div class="page-title" style="float:right; opacity: 0.5;">{{ vehiculo['marca'] ~ ' ' ~ vehiculo['modelo'] if vehiculo else '' }}</div>
|
||||||
|
<div class="page-subtitle" style="clear: both;">
|
||||||
{{ 'Modifica los datos del vehículo.' if vehiculo else 'Completa el formulario para registrar un nuevo vehículo.' }}
|
{{ 'Modifica los datos del vehículo.' if vehiculo else 'Completa el formulario para registrar un nuevo vehículo.' }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-card">
|
<div class="form-card">
|
||||||
<form method="POST" id="formVehiculo">
|
<form method="POST" id="formVehiculo">
|
||||||
@@ -131,14 +133,14 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="viat">Via-T</label>
|
<label class="form-label" for="viat">Via-T</label>
|
||||||
<input class="form-input" type="text" id="viat" name="viat" style="width: 210px; padding-left: 10px;"
|
<input class="form-input" type="text" id="viat" name="viat" style="width: 210px;"
|
||||||
oninput="this.value = this.value.toUpperCase();"
|
oninput="this.value = this.value.toUpperCase();"
|
||||||
value="{{ (vehiculo['viat'] or '') if vehiculo else request.form.get('viat', '') }}">
|
value="{{ (vehiculo['viat'] or '') if vehiculo else request.form.get('viat', '') }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group" >
|
||||||
<label class="form-label" for="legajo">Legajo</label>
|
<label class="form-label" for="legajo">Legajo</label>
|
||||||
<input class="form-input" id="legajo" name="legajo"
|
<input class="form-input" id="legajo" name="legajo" style="width: 130px"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
value="{{ (vehiculo['legajo'] or '') if vehiculo else request.form.get('legajo', '') }}">
|
value="{{ (vehiculo['legajo'] or '') if vehiculo else request.form.get('legajo', '') }}">
|
||||||
</div>
|
</div>
|
||||||
@@ -199,7 +201,7 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="plazas">Plazas</label>
|
<label class="form-label" for="plazas">Plazas</label>
|
||||||
<input class="form-input" type="text" id="plazas" name="plazas"
|
<input class="form-input" type="number" id="plazas" name="plazas" min="0"
|
||||||
placeholder="Nº de plazas"
|
placeholder="Nº de plazas"
|
||||||
value="{{ (vehiculo['plazas'] or '') if vehiculo else request.form.get('plazas', '') }}">
|
value="{{ (vehiculo['plazas'] or '') if vehiculo else request.form.get('plazas', '') }}">
|
||||||
</div>
|
</div>
|
||||||
@@ -375,17 +377,17 @@
|
|||||||
|
|
||||||
<div class="form-actions" style="margin:25px">
|
<div class="form-actions" style="margin:25px">
|
||||||
<button type="submit" class="btn btn-primary" id="btnGuardar" form="formVehiculo"> <i class="bi bi-floppy" style="font-size: 1rem;"></i>
|
<button type="submit" class="btn btn-primary" id="btnGuardar" form="formVehiculo"> <i class="bi bi-floppy" style="font-size: 1rem;"></i>
|
||||||
{{ 'GUARDAR CAMBIOS' if vehiculo else ' Registrar vehículo' }}
|
{{ 'GUARDAR CAMBIOS' if vehiculo else ' REGISTRAR VEHÍCULO' }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{# Cancelar #}
|
{# Cancelar #}
|
||||||
|
|
||||||
{% if origen == 'viat' %}
|
{% if origen == 'viat' %}
|
||||||
<a href="/viat?q={{ q_viat }}" class="btn btn-ghost" id="btnCancelar" style="background-color: gray; color: white;"><i class="bi bi-box-arrow-left"></i>VOLVER</a>
|
<a href="/viat?q={{ q_viat }}" class="btn btn-ghost" id="btnCancelar" style="background-color: gray; color: white;"><i class="bi bi-box-arrow-left"></i>SALIR</a>
|
||||||
{% elif desde or hasta or q_itv %}
|
{% elif desde or hasta or q_itv %}
|
||||||
<a href="/itv?desde={{ desde }}&hasta={{ hasta }}&q_itv={{ q_itv }}" class="btn btn-ghost" id="btnCancelar" style="background-color: gray; color: white;"><i class="bi bi-box-arrow-left"></i>VOLVER</a>
|
<a href="/itv?desde={{ desde }}&hasta={{ hasta }}&q_itv={{ q_itv }}" class="btn btn-ghost" id="btnCancelar" style="background-color: gray; color: white;"><i class="bi bi-box-arrow-left"></i>SALIR</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ url_for('vehiculos_list', q=q) if q else url_for('vehiculos_list') }}" class="btn btn-ghost" id="btnCancelar" style="background-color: gray; color: white;"><i class="bi bi-box-arrow-left"></i>VOLVER</a>
|
<a href="{{ url_for('vehiculos_list', q=q) if q else url_for('vehiculos_list') }}" class="btn btn-ghost" id="btnCancelar" style="background-color: gray; color: white;"><i class="bi bi-box-arrow-left"></i>SALIR</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- <div style="display:flex;justify-content:space-between;align-items:center;margin-top:12px;"> -->
|
<!-- <div style="display:flex;justify-content:space-between;align-items:center;margin-top:12px;"> -->
|
||||||
@@ -395,17 +397,16 @@
|
|||||||
Ficha - Imprimir/PDF
|
Ficha - Imprimir/PDF
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- </div> -->
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form> {# ← CIERRE del formulario principal #}
|
</form> {# ← CIERRE del formulario principal #}
|
||||||
|
|
||||||
|
|
||||||
<div class="form-card">
|
|
||||||
|
|
||||||
{# ── HISTORIAL (fuera del form principal) ── #}
|
{# ── HISTORIAL (fuera del form principal) ── #}
|
||||||
{% if vehiculo %}
|
{% if vehiculo %}
|
||||||
|
<div class="form-card">
|
||||||
<div class="section-title" style="margin-top:0px">Historial</div>
|
<div class="section-title" style="margin-top:0px">Historial</div>
|
||||||
|
|
||||||
{% if historial %}
|
{% if historial %}
|
||||||
@@ -660,14 +661,14 @@
|
|||||||
|
|
||||||
<div class="modal-backdrop" id="modalCambios" role="dialog" aria-modal="true"
|
<div class="modal-backdrop" id="modalCambios" role="dialog" aria-modal="true"
|
||||||
aria-labelledby="modalCambiosTitulo">
|
aria-labelledby="modalCambiosTitulo">
|
||||||
<div class="modal-box" style="max-width: 400px; text-align:center;">
|
<div class="modal-box" style="max-width: 440px; text-align:center;">
|
||||||
<h3 id="modalCambiosTitulo">Hay cambios sin guardar</h3>
|
<!-- <h3 id="modalCambiosTitulo">Hay cambios sin guardar</h3> -->
|
||||||
<p>Has modificado datos de este vehículo.</p>
|
<h4 style="font-weight: bold">¿Quiere guardar los cambios efectuados en {{ vehiculo['m_oficial'] }}?</h4>
|
||||||
<p>¿Qué quieres hacer con los cambios?</p>
|
<p style="color: red">Los cambios se perderán si no los guarda.</p>
|
||||||
<div class="modal-actions">
|
<div class="modal-actions" style="text-align:center;"></div>
|
||||||
<button type="button" class="btn btn-ghost" id="mcSeguir">Seguir editando</button>
|
|
||||||
<button type="button" class="btn btn-danger" id="mcDescartar">Descartar</button>
|
|
||||||
<button type="button" class="btn btn-primary" id="mcGuardar">Guardar</button>
|
<button type="button" class="btn btn-primary" id="mcGuardar">Guardar</button>
|
||||||
|
<button type="button" class="btn" id="mcDescartar">No guardar</button>
|
||||||
|
<button type="button" class="btn" id="mcSeguir">Cancelar</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -914,11 +915,18 @@ checkbox.addEventListener('change', function () {
|
|||||||
guardar();
|
guardar();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* ── Interceptar todo lo que haga salir de la página o recargarla ──
|
/* ── Interceptar todo lo que haga salir de la página o recargarla ──
|
||||||
Cancelar, enlaces del menú lateral y los botones de los otros formularios
|
Cancelar, enlaces del menú lateral y los botones de los otros formularios
|
||||||
(añadir/eliminar historial, subir/eliminar documento, eliminar vehículo…) */
|
(añadir/eliminar historial, subir/eliminar documento, eliminar vehículo…) */
|
||||||
|
// Botones/enlaces que recargan o abandonan la página
|
||||||
|
var OTROS = 'form:not(#formVehiculo) ';
|
||||||
var SALIDAS = '#btnCancelar, nav a[href], ' +
|
var SALIDAS = '#btnCancelar, nav a[href], ' +
|
||||||
'form:not(#formVehiculo) button, form:not(#formVehiculo) input[type="submit"]';
|
OTROS + 'button[type="submit"], ' + OTROS + 'input[type="submit"], ' +
|
||||||
|
OTROS + 'button[onclick*="submit"], ' + OTROS + 'button[onclick*="confirmarEliminar"]';
|
||||||
|
|
||||||
|
// Estos dos guardan los cambios del vehículo SIN preguntar y después continúan
|
||||||
|
var AUTOGUARDAR = 'form[action*="/historial/nuevo"], form[action*="/documentos/upload"]';
|
||||||
|
|
||||||
document.addEventListener('click', function(e) {
|
document.addEventListener('click', function(e) {
|
||||||
if (saltar || !hayCambios()) return;
|
if (saltar || !hayCambios()) return;
|
||||||
@@ -928,6 +936,25 @@ checkbox.addEventListener('change', function () {
|
|||||||
var h = el.getAttribute('href') || '';
|
var h = el.getAttribute('href') || '';
|
||||||
if (h.charAt(0) === '#' || /^javascript:/i.test(h) || el.target === '_blank') return;
|
if (h.charAt(0) === '#' || /^javascript:/i.test(h) || el.target === '_blank') return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Añadir al historial / Subir documento: guardar primero, sin modal */
|
||||||
|
var fAuto = EDITANDO ? el.closest(AUTOGUARDAR) : null;
|
||||||
|
if (fAuto) {
|
||||||
|
if (!fAuto.checkValidity()) return; // falta algo en ese formulario: que el navegador lo indique
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
if (!form.checkValidity()) { // campos obligatorios del vehículo sin rellenar
|
||||||
|
toast('Completa los campos obligatorios del vehículo antes de continuar.', 'error');
|
||||||
|
form.reportValidity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
guardar().then(function(ok) {
|
||||||
|
if (ok) { saltar = true; el.click(); saltar = false; } // ahora sí: añadir / subir
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Resto de salidas: preguntar qué hacer con los cambios */
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopImmediatePropagation(); // evita que corra el onclick/confirm del botón
|
e.stopImmediatePropagation(); // evita que corra el onclick/confirm del botón
|
||||||
abrir(function() { saltar = true; el.click(); saltar = false; }); // se relanza tras decidir
|
abrir(function() { saltar = true; el.click(); saltar = false; }); // se relanza tras decidir
|
||||||
@@ -962,6 +989,68 @@ checkbox.addEventListener('change', function () {
|
|||||||
if (e.target === modal) { pendiente = null; cerrar(); }
|
if (e.target === modal) { pendiente = null; cerrar(); }
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ── Interceptar todo lo que haga salir de la página o recargarla ──
|
||||||
|
Cancelar, enlaces del menú lateral y los botones de los otros formularios
|
||||||
|
(añadir/eliminar historial, subir/eliminar documento, eliminar vehículo…) */
|
||||||
|
// var SALIDAS = '#btnCancelar, nav a[href], ' +
|
||||||
|
// 'form:not(#formVehiculo) button, form:not(#formVehiculo) input[type="submit"]';
|
||||||
|
|
||||||
|
// document.addEventListener('click', function(e) {
|
||||||
|
// if (saltar || !hayCambios()) return;
|
||||||
|
// var el = e.target.closest(SALIDAS);
|
||||||
|
// if (!el) return;
|
||||||
|
// if (el.matches('a')) { // enlaces que no abandonan la página
|
||||||
|
// var h = el.getAttribute('href') || '';
|
||||||
|
// if (h.charAt(0) === '#' || /^javascript:/i.test(h) || el.target === '_blank') return;
|
||||||
|
// }
|
||||||
|
// e.preventDefault();
|
||||||
|
// e.stopImmediatePropagation(); // evita que corra el onclick/confirm del botón
|
||||||
|
// abrir(function() { saltar = true; el.click(); saltar = false; }); // se relanza tras decidir
|
||||||
|
// }, true);
|
||||||
|
|
||||||
|
// /* ── Botones del modal ── */
|
||||||
|
// document.getElementById('mcSeguir').addEventListener('click', function() {
|
||||||
|
// pendiente = null; cerrar();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// document.getElementById('mcDescartar').addEventListener('click', function() {
|
||||||
|
// cerrar(); continuar(); // se descartan los cambios y se hace lo que se pedía
|
||||||
|
// });
|
||||||
|
|
||||||
|
// document.getElementById('mcGuardar').addEventListener('click', function() {
|
||||||
|
// cerrar();
|
||||||
|
// if (!EDITANDO) { // alta nueva: envío normal
|
||||||
|
// if (form.requestSubmit) form.requestSubmit(); else form.submit();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (form.checkValidity && !form.checkValidity()) { // respeta los campos obligatorios
|
||||||
|
// pendiente = null; form.reportValidity(); return;
|
||||||
|
// }
|
||||||
|
// guardar().then(function(ok) { if (ok) continuar(); else pendiente = null; });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Escape o clic fuera del cuadro = seguir editando
|
||||||
|
// document.addEventListener('keydown', function(e) {
|
||||||
|
// if (e.key === 'Escape' && modal.classList.contains('open')) { pendiente = null; cerrar(); }
|
||||||
|
// });
|
||||||
|
// modal.addEventListener('click', function(e) {
|
||||||
|
// if (e.target === modal) { pendiente = null; cerrar(); }
|
||||||
|
// });
|
||||||
|
// })();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var estado = { col: -1, asc: true };
|
var estado = { col: -1, asc: true };
|
||||||
document.querySelectorAll('#tablaViat thead th').forEach(function(th, idx) {
|
document.querySelectorAll('#tablaViat thead th').forEach(function(th, idx) {
|
||||||
th.style.cursor = 'pointer'; th.style.userSelect = 'none';
|
th.style.cursor = 'pointer'; th.style.userSelect = 'none'; th.title = 'Pulsa para ordenar';
|
||||||
var icon = document.createElement('span');
|
var icon = document.createElement('span');
|
||||||
icon.style.cssText = 'margin-left:5px;opacity:.3;font-size:10px;';
|
icon.style.cssText = 'margin-left:5px;opacity:.3;font-size:10px;';
|
||||||
icon.textContent = '⇅'; icon.className = 'sort-icon';
|
icon.textContent = '⇅'; icon.className = 'sort-icon';
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user