nuevas correciones
This commit is contained in:
@@ -323,10 +323,8 @@
|
||||
);
|
||||
|
||||
renderExpedientesTable(filtered);
|
||||
$('#pagination').empty(); // Limpiar paginación en búsqueda
|
||||
$('#pagination').empty();
|
||||
}
|
||||
|
||||
// Guardar nuevo expediente
|
||||
function saveExpediente() {
|
||||
const formData = new FormData($('#createForm')[0]);
|
||||
|
||||
@@ -337,7 +335,6 @@
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
// Mostrar siempre el mensaje que viene en response.message
|
||||
const message = response.message ||
|
||||
(response.success ? 'Operación completada' : 'Error en la operación');
|
||||
|
||||
@@ -351,7 +348,6 @@
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
// Extraer el message del JSON si existe
|
||||
let message = 'Error en la solicitud';
|
||||
try {
|
||||
const jsonResponse = JSON.parse(xhr.responseText);
|
||||
@@ -359,7 +355,6 @@
|
||||
message = jsonResponse.message;
|
||||
}
|
||||
} catch (e) {
|
||||
// Si no es JSON válido, usar el texto de respuesta
|
||||
if (xhr.responseText) {
|
||||
message = xhr.responseText;
|
||||
}
|
||||
@@ -378,7 +373,6 @@
|
||||
$('#editModalBody').html(data);
|
||||
$('#editModal').modal('show');
|
||||
|
||||
// Mostrar/ocultar botón de eliminar imagen según si hay imagen personalizada
|
||||
const fotoUrl = $('#editForm input[name="FotoUrl"]').val();
|
||||
const deleteBtn = $('#deleteFotoEdit');
|
||||
if (fotoUrl && fotoUrl !== '/images/default-avatar.png') {
|
||||
@@ -441,8 +435,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ========== FUNCIONES PARA MANEJO DE IMÁGENES ==========
|
||||
|
||||
// Mostrar vista previa de imagen
|
||||
function previewImage(input, previewId) {
|
||||
const preview = document.getElementById(previewId);
|
||||
@@ -519,16 +511,13 @@
|
||||
}
|
||||
}
|
||||
showAlert('error', message);
|
||||
// Restaurar imagen predeterminada
|
||||
preview.src = '/images/default-avatar.png';
|
||||
// Ocultar botón de eliminar
|
||||
const deleteBtnId = isEdit ? 'deleteFotoEdit' : 'deleteFoto';
|
||||
$(`#${deleteBtnId}`).hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Eliminar imagen
|
||||
function deleteImage(isEdit = false) {
|
||||
const formId = isEdit ? 'editForm' : 'createForm';
|
||||
const hiddenInput = $(`#${formId} input[name="FotoUrl"]`);
|
||||
@@ -544,7 +533,6 @@
|
||||
data: { imageUrl: imageUrl },
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Restaurar imagen predeterminada
|
||||
$(`#${previewId}`).attr('src', '/images/default-avatar.png');
|
||||
hiddenInput.val('/images/default-avatar.png');
|
||||
$(`#${deleteBtnId}`).hide();
|
||||
@@ -561,9 +549,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ========== FUNCIONES UTILITARIAS ==========
|
||||
|
||||
// Calcular edad
|
||||
function calculateAge(birthDate) {
|
||||
const today = new Date();
|
||||
const birth = new Date(birthDate);
|
||||
@@ -577,7 +562,6 @@
|
||||
return age;
|
||||
}
|
||||
|
||||
// Formatear fecha
|
||||
function formatDate(dateString) {
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleDateString('es-ES', {
|
||||
@@ -587,9 +571,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Mostrar alerta
|
||||
function showAlert(type, message) {
|
||||
// Crear elemento de alerta
|
||||
const alertDiv = document.createElement('div');
|
||||
alertDiv.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
|
||||
alertDiv.style.cssText = 'top: 20px; right: 20px; z-index: 1050; min-width: 300px;';
|
||||
@@ -598,10 +580,8 @@
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
`;
|
||||
|
||||
// Agregar al body
|
||||
document.body.appendChild(alertDiv);
|
||||
|
||||
// Auto-eliminar después de 5 segundos
|
||||
setTimeout(() => {
|
||||
if (alertDiv.parentNode) {
|
||||
alertDiv.remove();
|
||||
|
||||
Reference in New Issue
Block a user