Cambios realizados v1.2.12 (Backend):

PDF Mejorado - Tipos de Pregunta:
CORREGIDO: Las preguntas de texto libre ya NO muestran estado "OK" en verde

Tipos de pregunta afectados:

 text - Campos de texto libre
 number - Campos numéricos
 date - Fechas
 time - Horas
 photo_only - Solo fotografías
 ai_assistant - Chat con IA
Cambios visuales en PDF:

ANTES:

Pregunta texto: ✓ ¿Observaciones? (verde)
Respuesta: "El motor suena raro" | Estado: OK (verde)
AHORA:

Pregunta texto: 📝 ¿Observaciones? (neutro)
Respuesta: "El motor suena raro" (sin badge de estado)
Preguntas CON estado (sin cambios):

boolean (Sí/No)
single_choice (Opción única)
multiple_choice (Múltiples opciones)
scale (Escala numérica)
pass_fail (Pasa/Falla)
Mejora:

 Más limpio y profesional
 No confunde con estados que no aplican
 Icono 📝 para preguntas informativas
 Iconos ✓ ⚠ ✕ solo para preguntas con evaluación
This commit is contained in:
2025-12-08 11:57:19 -03:00
parent 0c0812efe9
commit b3c0030a52
2 changed files with 38 additions and 17 deletions

View File

@@ -278,7 +278,7 @@ def extract_pdf_text_smart(pdf_content: bytes, max_chars: int = None) -> dict:
} }
BACKEND_VERSION = "1.2.11" BACKEND_VERSION = "1.2.12"
app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION) app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION)
# S3/MinIO configuration # S3/MinIO configuration
@@ -2025,7 +2025,14 @@ def generate_inspection_pdf(inspection_id: int, db: Session) -> str:
# Detectar si es pregunta con chat assistant # Detectar si es pregunta con chat assistant
is_ai_assistant = question.options and question.options.get('type') == 'ai_assistant' is_ai_assistant = question.options and question.options.get('type') == 'ai_assistant'
# Estado visual # Detectar tipo de pregunta para determinar si debe mostrar estado
question_type = question.options.get('type') if question.options else question.type
# Tipos de pregunta que NO deben mostrar estado de color (son informativas/texto libre)
text_based_types = ['text', 'number', 'date', 'time', 'photo_only', 'ai_assistant']
should_show_status = question_type not in text_based_types
# Estado visual (solo para preguntas con estado)
status_colors = { status_colors = {
'ok': colors.HexColor('#22c55e'), 'ok': colors.HexColor('#22c55e'),
'warning': colors.HexColor('#eab308'), 'warning': colors.HexColor('#eab308'),
@@ -2036,8 +2043,14 @@ def generate_inspection_pdf(inspection_id: int, db: Session) -> str:
'warning': '', 'warning': '',
'critical': '' 'critical': ''
} }
status_color = status_colors.get(ans.status, colors.HexColor('#64748b'))
status_icon = status_icons.get(ans.status, '') if should_show_status:
status_color = status_colors.get(ans.status, colors.HexColor('#64748b'))
status_icon = status_icons.get(ans.status, '')
else:
# Para preguntas de texto/info, usar estilo neutral
status_color = colors.HexColor('#64748b')
status_icon = '📝'
# Tabla de pregunta/respuesta # Tabla de pregunta/respuesta
question_data = [] question_data = []
@@ -2091,18 +2104,26 @@ def generate_inspection_pdf(inspection_id: int, db: Session) -> str:
# ===== LÓGICA NORMAL PARA OTROS TIPOS ===== # ===== LÓGICA NORMAL PARA OTROS TIPOS =====
else: else:
# Fila 2: Respuesta y estado - Convertir valor técnico a etiqueta legible # Fila 2: Respuesta - Convertir valor técnico a etiqueta legible
answer_text = get_readable_answer(ans.answer_value, question.options) answer_text = get_readable_answer(ans.answer_value, question.options)
question_data.append([
Table([ # Solo mostrar estado para preguntas que lo requieren (no texto libre)
[ if should_show_status:
Paragraph(f"<b>Respuesta:</b> {answer_text}", answer_style), question_data.append([
Paragraph(f"<b>Estado:</b> {ans.status.upper()}", Table([
ParagraphStyle('status', parent=answer_style, [
textColor=status_color, fontName='Helvetica-Bold')) Paragraph(f"<b>Respuesta:</b> {answer_text}", answer_style),
] Paragraph(f"<b>Estado:</b> {ans.status.upper()}",
], colWidths=[120*mm, 50*mm]) ParagraphStyle('status', parent=answer_style,
]) textColor=status_color, fontName='Helvetica-Bold'))
]
], colWidths=[120*mm, 50*mm])
])
else:
# Para preguntas de texto, solo mostrar la respuesta sin estado
question_data.append([
Paragraph(f"<b>Respuesta:</b> {answer_text}", answer_style)
])
# Fila 3: Comentario mejorado (si existe) # Fila 3: Comentario mejorado (si existe)
if ans.comment: if ans.comment:

View File

@@ -5069,12 +5069,12 @@ function InspectionModal({ checklist, existingInspection, user, onClose, onCompl
: 'bg-blue-50 border-blue-200' : 'bg-blue-50 border-blue-200'
}`}> }`}>
<div className="flex items-start gap-2"> <div className="flex items-start gap-2">
<span className="text-lg sm:text-xl flex-shrink-0">🤖</span> <span className="text-lg sm:text-xl flex-shrink-0">🛠</span>
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">
<p className={`text-xs sm:text-sm font-medium ${ <p className={`text-xs sm:text-sm font-medium ${
checklist.ai_mode === 'full' ? 'text-purple-900' : 'text-blue-900' checklist.ai_mode === 'full' ? 'text-purple-900' : 'text-blue-900'
}`}> }`}>
{checklist.ai_mode === 'full' ? 'Modo AUTOCOMPLETADO activado' : 'Modo ASISTIDO activado'} {checklist.ai_mode === 'full' ? 'Modo AUTOCOMPLETADO activado' : ' '}
</p> </p>
<p className={`text-xs ${ <p className={`text-xs ${
checklist.ai_mode === 'full' ? 'text-purple-700' : 'text-blue-700' checklist.ai_mode === 'full' ? 'text-purple-700' : 'text-blue-700'