diff --git a/frontend/package.json b/frontend/package.json index d22c7e2..1855700 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "checklist-frontend", "private": true, - "version": "1.0.97", + "version": "1.0.98", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/public/service-worker.js b/frontend/public/service-worker.js index 2fdde6f..27499b4 100644 --- a/frontend/public/service-worker.js +++ b/frontend/public/service-worker.js @@ -1,6 +1,6 @@ // Service Worker para PWA con detección de actualizaciones // IMPORTANTE: Actualizar esta versión cada vez que se despliegue una nueva versión -const CACHE_NAME = 'ayutec-v1.0.97'; +const CACHE_NAME = 'ayutec-v1.0.98'; const urlsToCache = [ '/', '/index.html' diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 0fef5be..0e87f2d 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1692,134 +1692,124 @@ function QuestionsManagerModal({ checklist, onClose }) { /> - {/* Pregunta Condicional - Subpreguntas Anidadas hasta 5 niveles */} + {/* Subpreguntas y Preguntas Condicionales - Anidadas hasta 5 niveles */}

- ⚡ Pregunta Condicional - Subpreguntas Anidadas (hasta 5 niveles) + 📋 Subpreguntas y Preguntas Condicionales (hasta 5 niveles)

- {/* Solo permitir condicionales para boolean y single_choice */} - {(() => { - const currentType = formData.options?.type || formData.type - const allowConditional = ['boolean', 'single_choice'].includes(currentType) - - if (!allowConditional) { + +
+ {/* Selector de pregunta padre - SIEMPRE disponible */} +
+ + +

+ Si seleccionas una pregunta padre, esta pregunta se mostrará como subpregunta debajo de ella +

+
+ + {/* Condición - Solo si hay padre y el padre es boolean/single_choice */} + {formData.parent_question_id && (() => { + const parentQ = questions.find(q => q.id === formData.parent_question_id) + if (!parentQ) return null + + const config = parentQ.options || {} + const parentType = config.type || parentQ.type + const isConditionalParent = ['boolean', 'single_choice'].includes(parentType) + + if (!isConditionalParent) { + return ( +
+

+ ✓ Esta subpregunta aparecerá SIEMPRE debajo de la pregunta padre seleccionada +

+
+ ) + } + return ( -
-

- ℹ️ Las preguntas condicionales solo están disponibles para tipos Boolean y Opción Única +

+ + +

+ {formData.show_if_answer + ? '⚡ Se mostrará SOLO cuando la respuesta del padre coincida' + : '✓ Se mostrará SIEMPRE debajo de la pregunta padre'}

) - } - - return ( - <> -
-
- - -

- Esta pregunta aparecerá solo si se cumple la condición de la pregunta padre -

-
-
- - -

- La pregunta solo se mostrará con esta respuesta específica -

-
+ })()} + + {/* Indicador de profundidad */} + {formData.parent_question_id && (() => { + const parentQ = questions.find(q => q.id === formData.parent_question_id) + const parentDepth = parentQ?.depth_level || 0 + const newDepth = parentDepth + 1 + + return ( +
= 5 ? 'bg-red-50 border border-red-200' : 'bg-blue-100'}`}> +

+ 📊 Profundidad: Nivel {newDepth} de 5 máximo + {newDepth >= 5 && ' ⚠️ Máximo alcanzado'} +

- - {/* Indicador de profundidad */} - {formData.parent_question_id && (() => { - const parentQ = questions.find(q => q.id === formData.parent_question_id) - const parentDepth = parentQ?.depth_level || 0 - const newDepth = parentDepth + 1 - - return ( -
= 5 ? 'bg-red-50 border border-red-200' : 'bg-blue-100'}`}> -

- 📊 Profundidad: Nivel {newDepth} de 5 máximo - {newDepth >= 5 && ' ⚠️ Máximo alcanzado'} -

-
- ) - })()} - - ) - })()} + ) + })()} +
{/* AI Prompt - Solo visible si el checklist tiene IA habilitada */} @@ -1979,15 +1969,22 @@ function QuestionsManagerModal({ checklist, onClose }) {
{isSubQuestion && ( - - ⚡ Condicional + + {question.show_if_answer ? '⚡ Condicional' : '📎 Subpregunta'} )}

{question.text}

{isSubQuestion && parentQuestion && ( -

- → Aparece si #{question.parent_question_id} es {question.show_if_answer} +

+ {question.show_if_answer + ? `→ Aparece si #${question.parent_question_id} es ${question.show_if_answer}` + : `→ Siempre visible debajo de #${question.parent_question_id}` + }

)}
@@ -4416,11 +4413,16 @@ function InspectionModal({ checklist, existingInspection, user, onClose, onCompl // If no parent, always visible if (!q.parent_question_id) return true - // Check parent answer + // If has parent but NO condition (show_if_answer is null/empty), always show if parent was answered + if (!q.show_if_answer) { + const parentAnswer = answers[q.parent_question_id] + return !!parentAnswer // Show if parent has any answer + } + + // If has parent AND condition, check if parent answer matches const parentAnswer = answers[q.parent_question_id] if (!parentAnswer) return false - // Show if parent answer matches trigger return parentAnswer.value === q.show_if_answer }) .sort((a, b) => a.order - b.order) // Mantener orden del backend