wagtail-enap-designsystem 1.2.1.136__py3-none-any.whl → 1.2.1.138__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- enap_designsystem/blocks/__init__.py +2 -0
- enap_designsystem/blocks/form.py +160 -24
- enap_designsystem/blocks/html_blocks.py +39 -15
- enap_designsystem/blocks/semana_blocks.py +4 -0
- enap_designsystem/settings.py +2 -2
- enap_designsystem/templates/enap_designsystem/blocks/apresentacao_block.html +1 -2
- enap_designsystem/templates/enap_designsystem/blocks/cards_titles.html +35 -5
- enap_designsystem/templates/enap_designsystem/blocks/job_vacancy_filtered_block.html +7 -0
- enap_designsystem/templates/enap_designsystem/blocks/logos_simple_block.html +1 -1
- enap_designsystem/templates/enap_designsystem/blocks/numeros_block.html +58 -179
- enap_designsystem/templates/enap_designsystem/blocks/video_hero_banner.html +23 -9
- enap_designsystem/templates/enap_designsystem/form_templates/formulario_page.html +397 -1080
- enap_designsystem/templates/enap_designsystem/includes/form_field.html +935 -1
- enap_designsystem/templates/enap_designsystem/sistema_votacao_page.html +76 -18
- {wagtail_enap_designsystem-1.2.1.136.dist-info → wagtail_enap_designsystem-1.2.1.138.dist-info}/METADATA +1 -1
- {wagtail_enap_designsystem-1.2.1.136.dist-info → wagtail_enap_designsystem-1.2.1.138.dist-info}/RECORD +19 -19
- {wagtail_enap_designsystem-1.2.1.136.dist-info → wagtail_enap_designsystem-1.2.1.138.dist-info}/WHEEL +0 -0
- {wagtail_enap_designsystem-1.2.1.136.dist-info → wagtail_enap_designsystem-1.2.1.138.dist-info}/licenses/LICENSE +0 -0
- {wagtail_enap_designsystem-1.2.1.136.dist-info → wagtail_enap_designsystem-1.2.1.138.dist-info}/top_level.txt +0 -0
|
@@ -1356,13 +1356,10 @@
|
|
|
1356
1356
|
</div>
|
|
1357
1357
|
{% endif %}
|
|
1358
1358
|
|
|
1359
|
-
<!--
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
{% include 'enap_designsystem/includes/form_field.html' with block=block %}
|
|
1364
|
-
{% endfor %}
|
|
1365
|
-
</div>
|
|
1359
|
+
<!-- ✅ ESTRUTURA CORRIGIDA -->
|
|
1360
|
+
{% for block in section.fields %}
|
|
1361
|
+
{% include 'enap_designsystem/includes/form_field.html' with block=block %}
|
|
1362
|
+
{% endfor %}
|
|
1366
1363
|
{% endfor %}
|
|
1367
1364
|
</div>
|
|
1368
1365
|
</div>
|
|
@@ -1420,599 +1417,417 @@
|
|
|
1420
1417
|
</div>
|
|
1421
1418
|
|
|
1422
1419
|
<script>
|
|
1423
|
-
window.FormularioSystem = window.FormularioSystem || {
|
|
1424
|
-
multiRedirectFields: new Map(),
|
|
1425
|
-
initialized: false
|
|
1426
|
-
};
|
|
1427
1420
|
// VARIÁVEIS GLOBAIS
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1421
|
+
let currentStep = 0;
|
|
1422
|
+
let currentActiveWizardIndex = 0;
|
|
1423
|
+
let isScrolling = false;
|
|
1424
|
+
const formSteps = {{ all_steps|length }};
|
|
1425
|
+
const totalSteps = formSteps + 2;
|
|
1426
|
+
const successStepIndex = formSteps + 1;
|
|
1427
|
+
let wizardSteps = [];
|
|
1428
|
+
|
|
1429
|
+
// DADOS DO DJANGO
|
|
1430
|
+
let sectionMapData = {};
|
|
1431
|
+
let navigationDataRaw = {};
|
|
1432
|
+
|
|
1433
|
+
try {
|
|
1434
|
+
{% if section_map_json %}
|
|
1435
|
+
sectionMapData = {{ section_map_json|safe }};
|
|
1436
|
+
{% endif %}
|
|
1437
|
+
} catch(e) {
|
|
1438
|
+
console.log('Section map não disponível');
|
|
1439
|
+
sectionMapData = {};
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
try {
|
|
1443
|
+
{% if navigation_data_json %}
|
|
1444
|
+
navigationDataRaw = {{ navigation_data_json|safe }};
|
|
1445
|
+
{% endif %}
|
|
1446
|
+
} catch(e) {
|
|
1447
|
+
console.log('Navigation data não disponível');
|
|
1448
|
+
navigationDataRaw = {};
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// NAVEGAÇÃO PRINCIPAL
|
|
1452
|
+
function nextStep() {
|
|
1453
|
+
if (currentStep === 0) {
|
|
1454
|
+
currentStep = 1;
|
|
1455
|
+
showStep(currentStep);
|
|
1456
|
+
return;
|
|
1447
1457
|
}
|
|
1448
1458
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
} catch(e) {
|
|
1454
|
-
console.log('Navigation data não disponível');
|
|
1455
|
-
navigationDataRaw = {};
|
|
1459
|
+
if (currentStep >= 1 && currentStep <= formSteps) {
|
|
1460
|
+
if (!validateCurrentStep()) {
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1456
1463
|
}
|
|
1457
1464
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
console.log('Config: formSteps=' + formSteps + ', totalSteps=' + totalSteps);
|
|
1465
|
+
if (currentStep === formSteps) {
|
|
1466
|
+
document.getElementById('wagtailForm').submit();
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1464
1469
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
if (currentStep >= 1 && currentStep <= formSteps) {
|
|
1476
|
-
if (!validateCurrentStep()) {
|
|
1477
|
-
console.log('Validação falhou');
|
|
1478
|
-
return;
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
if (currentStep === formSteps) {
|
|
1483
|
-
const form = document.getElementById('wagtailForm');
|
|
1484
|
-
if (form) {
|
|
1485
|
-
form.submit();
|
|
1486
|
-
}
|
|
1487
|
-
return;
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
if (currentStep < totalSteps - 1) {
|
|
1491
|
-
currentStep++;
|
|
1492
|
-
showStep(currentStep);
|
|
1493
|
-
}
|
|
1470
|
+
if (currentStep < totalSteps - 1) {
|
|
1471
|
+
currentStep++;
|
|
1472
|
+
showStep(currentStep);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
function prevStep() {
|
|
1477
|
+
if (currentStep > 1) {
|
|
1478
|
+
currentStep--;
|
|
1479
|
+
showStep(currentStep);
|
|
1494
1480
|
}
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
function showStep(step) {
|
|
1484
|
+
// Ocultar todos os steps
|
|
1485
|
+
document.querySelectorAll('.step-content').forEach(el => {
|
|
1486
|
+
el.classList.remove('active');
|
|
1487
|
+
});
|
|
1495
1488
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1489
|
+
// Mostrar step atual
|
|
1490
|
+
const stepElement = document.getElementById('step' + step);
|
|
1491
|
+
if (stepElement) {
|
|
1492
|
+
stepElement.classList.add('active');
|
|
1501
1493
|
}
|
|
1502
1494
|
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1495
|
+
// Controlar wizard e navegação
|
|
1496
|
+
const wizardContainer = document.getElementById('wizardContainer');
|
|
1497
|
+
const navigation = document.getElementById('navigation');
|
|
1498
|
+
|
|
1499
|
+
if (step === 0) {
|
|
1500
|
+
if (wizardContainer) wizardContainer.style.display = 'none';
|
|
1501
|
+
if (navigation) navigation.style.display = 'none';
|
|
1502
|
+
} else if (step === successStepIndex) {
|
|
1503
|
+
if (wizardContainer) wizardContainer.style.display = 'none';
|
|
1504
|
+
if (navigation) navigation.style.display = 'none';
|
|
1505
|
+
setTimeout(createConfetti, 500);
|
|
1506
|
+
} else {
|
|
1507
|
+
if (wizardContainer) wizardContainer.style.display = 'flex';
|
|
1508
|
+
if (navigation) navigation.style.display = 'flex';
|
|
1517
1509
|
|
|
1518
|
-
// Controlar wizard e navegação
|
|
1519
|
-
const wizardContainer = document.getElementById('wizardContainer');
|
|
1520
|
-
const navigation = document.getElementById('navigation');
|
|
1521
1510
|
const prevBtn = document.getElementById('prevBtn');
|
|
1522
1511
|
const nextBtn = document.getElementById('nextBtn');
|
|
1523
1512
|
|
|
1524
|
-
if (step ===
|
|
1525
|
-
|
|
1526
|
-
if (wizardContainer) wizardContainer.style.display = 'none';
|
|
1527
|
-
if (navigation) navigation.style.display = 'none';
|
|
1528
|
-
} else if (step === successStepIndex) {
|
|
1529
|
-
// Tela de sucesso
|
|
1530
|
-
if (wizardContainer) wizardContainer.style.display = 'none';
|
|
1531
|
-
if (navigation) navigation.style.display = 'none';
|
|
1532
|
-
setTimeout(createConfetti, 500);
|
|
1533
|
-
} else {
|
|
1534
|
-
// Steps do formulário
|
|
1535
|
-
if (wizardContainer) wizardContainer.style.display = 'flex';
|
|
1536
|
-
if (navigation) navigation.style.display = 'flex';
|
|
1537
|
-
|
|
1538
|
-
// Configurar botões de navegação
|
|
1539
|
-
if (prevBtn) prevBtn.style.display = step === 1 ? 'none' : 'inline-block';
|
|
1540
|
-
if (nextBtn) nextBtn.textContent = step === formSteps ? 'Finalizar Inscrição' : 'Próximo →';
|
|
1541
|
-
|
|
1542
|
-
// Inicializar wizard se necessário
|
|
1543
|
-
if (wizardSteps.length === 0) {
|
|
1544
|
-
initializeWizard();
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
// Configurar scroll listener
|
|
1548
|
-
setTimeout(function() {
|
|
1549
|
-
setupScrollDetection();
|
|
1550
|
-
if (currentActiveWizardIndex === 0) {
|
|
1551
|
-
updateWizardVisual();
|
|
1552
|
-
updateDividerVisual();
|
|
1553
|
-
}
|
|
1554
|
-
}, 200);
|
|
1555
|
-
}
|
|
1513
|
+
if (prevBtn) prevBtn.style.display = step === 1 ? 'none' : 'inline-block';
|
|
1514
|
+
if (nextBtn) nextBtn.textContent = step === formSteps ? 'Finalizar Inscrição' : 'Próximo →';
|
|
1556
1515
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
if (formContent) {
|
|
1560
|
-
formContent.scrollTop = 0;
|
|
1516
|
+
if (wizardSteps.length === 0) {
|
|
1517
|
+
initializeWizard();
|
|
1561
1518
|
}
|
|
1562
1519
|
}
|
|
1563
1520
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1521
|
+
const formContent = document.getElementById('formContent');
|
|
1522
|
+
if (formContent) formContent.scrollTop = 0;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
function validateCurrentStep() {
|
|
1526
|
+
const currentStepElement = document.getElementById('step' + currentStep);
|
|
1527
|
+
if (!currentStepElement) return true;
|
|
1528
|
+
|
|
1529
|
+
let isValid = true;
|
|
1530
|
+
const requiredInputs = currentStepElement.querySelectorAll('input[required], select[required], textarea[required]');
|
|
1531
|
+
|
|
1532
|
+
requiredInputs.forEach(input => {
|
|
1533
|
+
// Verificar se está oculto
|
|
1534
|
+
const isHidden = (
|
|
1535
|
+
input.offsetParent === null ||
|
|
1536
|
+
input.closest('[style*="display: none"]') ||
|
|
1537
|
+
input.closest('.conditional-container[style*="display: none"]')
|
|
1538
|
+
);
|
|
1569
1539
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1540
|
+
if (isHidden) {
|
|
1541
|
+
input.required = false;
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1572
1544
|
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
input.style.display === 'none' ||
|
|
1579
|
-
input.offsetParent === null ||
|
|
1580
|
-
input.closest('[style*="display: none"]') ||
|
|
1581
|
-
input.closest('.conditional-fields[style*="display: none"]') ||
|
|
1582
|
-
input.closest('.conditional-condicional-fields[style*="display: none"]')
|
|
1583
|
-
);
|
|
1584
|
-
|
|
1585
|
-
if (isHidden) {
|
|
1586
|
-
console.log(`Pulando campo oculto: ${input.name}`);
|
|
1587
|
-
// REMOVER temporariamente o required de campos ocultos
|
|
1588
|
-
input.required = false;
|
|
1589
|
-
continue;
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
let hasValue = false;
|
|
1593
|
-
|
|
1594
|
-
if (input.type === 'checkbox') {
|
|
1595
|
-
hasValue = input.checked;
|
|
1596
|
-
} else if (input.type === 'radio') {
|
|
1597
|
-
const radioGroup = currentStepElement.querySelectorAll('input[name="' + input.name + '"]');
|
|
1598
|
-
for (let j = 0; j < radioGroup.length; j++) {
|
|
1599
|
-
if (radioGroup[j].checked) {
|
|
1600
|
-
hasValue = true;
|
|
1601
|
-
break;
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1545
|
+
let hasValue = false;
|
|
1546
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
1547
|
+
if (input.type === 'radio') {
|
|
1548
|
+
const radioGroup = currentStepElement.querySelectorAll(`input[name="${input.name}"]`);
|
|
1549
|
+
hasValue = Array.from(radioGroup).some(radio => radio.checked);
|
|
1604
1550
|
} else {
|
|
1605
|
-
hasValue = input.
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
if (!hasValue) {
|
|
1609
|
-
showFieldError(input, 'Este campo é obrigatório');
|
|
1610
|
-
isValid = false;
|
|
1551
|
+
hasValue = input.checked;
|
|
1611
1552
|
}
|
|
1553
|
+
} else {
|
|
1554
|
+
hasValue = input.value.trim() !== '';
|
|
1612
1555
|
}
|
|
1613
1556
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
function showFieldError(input, message) {
|
|
1618
|
-
let errorDiv = input.parentNode.querySelector('.error-message');
|
|
1619
|
-
if (!errorDiv) {
|
|
1620
|
-
errorDiv = document.createElement('div');
|
|
1621
|
-
errorDiv.className = 'error-message';
|
|
1622
|
-
input.parentNode.appendChild(errorDiv);
|
|
1557
|
+
if (!hasValue) {
|
|
1558
|
+
showFieldError(input, 'Este campo é obrigatório');
|
|
1559
|
+
isValid = false;
|
|
1623
1560
|
}
|
|
1624
|
-
|
|
1625
|
-
errorDiv.style.display = 'block';
|
|
1626
|
-
|
|
1627
|
-
input.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
1628
|
-
input.focus();
|
|
1629
|
-
}
|
|
1561
|
+
});
|
|
1630
1562
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
}
|
|
1563
|
+
return isValid;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
function showFieldError(input, message) {
|
|
1567
|
+
let errorDiv = input.parentNode.querySelector('.error-message');
|
|
1568
|
+
if (!errorDiv) {
|
|
1569
|
+
errorDiv = document.createElement('div');
|
|
1570
|
+
errorDiv.className = 'error-message';
|
|
1571
|
+
input.parentNode.appendChild(errorDiv);
|
|
1572
|
+
}
|
|
1573
|
+
errorDiv.textContent = message;
|
|
1574
|
+
errorDiv.style.display = 'block';
|
|
1575
|
+
|
|
1576
|
+
input.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
1577
|
+
input.focus();
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// CAMPOS CONDICIONAIS SIMPLIFICADOS
|
|
1581
|
+
function initializeConditionalFields() {
|
|
1582
|
+
console.log('Inicializando campos condicionais...');
|
|
1652
1583
|
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
if (!fieldContainer) return;
|
|
1656
|
-
|
|
1657
|
-
const fieldId = fieldContainer.dataset.fieldId;
|
|
1658
|
-
const selectedValue = getSelectedValue(element);
|
|
1659
|
-
|
|
1660
|
-
if (!navigationData[fieldId] || !selectedValue) {
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
const actionData = navigationData[fieldId][selectedValue];
|
|
1665
|
-
if (!actionData) {
|
|
1666
|
-
return;
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
console.log('Navegação ativada: ' + fieldId + ' -> ' + selectedValue);
|
|
1670
|
-
|
|
1671
|
-
// Executar ação baseada no tipo
|
|
1672
|
-
switch (actionData.action_type) {
|
|
1673
|
-
case 'continue':
|
|
1674
|
-
console.log('Continuando navegação normal');
|
|
1675
|
-
break;
|
|
1676
|
-
|
|
1677
|
-
case 'jump_to_section':
|
|
1678
|
-
handleJumpToSection(actionData.target_section);
|
|
1679
|
-
break;
|
|
1680
|
-
|
|
1681
|
-
case 'finish_form':
|
|
1682
|
-
handleFinishForm();
|
|
1683
|
-
break;
|
|
1684
|
-
|
|
1685
|
-
case 'show_message_and_finish':
|
|
1686
|
-
handleShowMessageAndFinish(actionData);
|
|
1687
|
-
break;
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1584
|
+
// Selects com data-field-id (conditional_field_condicional)
|
|
1585
|
+
const conditionalTriggers = document.querySelectorAll('select[data-field-id]');
|
|
1690
1586
|
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
return null;
|
|
1700
|
-
} else if (element.type === 'checkbox') {
|
|
1701
|
-
return element.checked ? element.value : null;
|
|
1702
|
-
} else if (element.tagName === 'SELECT') {
|
|
1703
|
-
return element.value;
|
|
1587
|
+
conditionalTriggers.forEach(trigger => {
|
|
1588
|
+
trigger.addEventListener('change', function() {
|
|
1589
|
+
handleConditionalField(this);
|
|
1590
|
+
});
|
|
1591
|
+
|
|
1592
|
+
// Estado inicial
|
|
1593
|
+
if (trigger.value) {
|
|
1594
|
+
handleConditionalField(trigger);
|
|
1704
1595
|
}
|
|
1705
|
-
|
|
1706
|
-
}
|
|
1596
|
+
});
|
|
1707
1597
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
const targetSection = sectionMap[targetSectionName];
|
|
1715
|
-
showSection(targetSectionName);
|
|
1716
|
-
|
|
1717
|
-
currentStep = targetSection.step;
|
|
1718
|
-
showStep(currentStep);
|
|
1719
|
-
|
|
1720
|
-
setTimeout(function() {
|
|
1721
|
-
scrollToSection(targetSection.block_id);
|
|
1722
|
-
}, 100);
|
|
1723
|
-
|
|
1724
|
-
console.log('Pulando para seção: ' + targetSectionName);
|
|
1725
|
-
}
|
|
1598
|
+
console.log(`Triggers configurados: ${conditionalTriggers.length}`);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
function handleConditionalField(triggerElement) {
|
|
1602
|
+
const fieldId = triggerElement.dataset.fieldId;
|
|
1603
|
+
const selectedValue = triggerElement.value;
|
|
1726
1604
|
|
|
1727
|
-
|
|
1728
|
-
currentStep = totalSteps - 1;
|
|
1729
|
-
showStep(currentStep);
|
|
1730
|
-
console.log('Formulário finalizado antecipadamente');
|
|
1731
|
-
}
|
|
1605
|
+
console.log(`Campo condicional: ${fieldId} = "${selectedValue}"`);
|
|
1732
1606
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
for (let i = 0; i < sections.length; i++) {
|
|
1736
|
-
const sectionName = sections[i];
|
|
1737
|
-
const sectionData = sectionMap[sectionName];
|
|
1738
|
-
if (sectionData.hidden_by_default) {
|
|
1739
|
-
hideSection(sectionName);
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1607
|
+
// Encontrar containers condicionais
|
|
1608
|
+
const conditionalContainers = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
1743
1609
|
|
|
1744
|
-
|
|
1745
|
-
const
|
|
1746
|
-
if (!sectionData) return;
|
|
1610
|
+
conditionalContainers.forEach(container => {
|
|
1611
|
+
const triggerValue = container.dataset.triggerValue;
|
|
1747
1612
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1613
|
+
if (selectedValue === triggerValue) {
|
|
1614
|
+
// Mostrar
|
|
1615
|
+
container.style.display = 'block';
|
|
1616
|
+
enableFieldsInContainer(container);
|
|
1617
|
+
console.log(`Mostrando container para: ${triggerValue}`);
|
|
1618
|
+
} else {
|
|
1619
|
+
// Ocultar
|
|
1620
|
+
container.style.display = 'none';
|
|
1621
|
+
disableFieldsInContainer(container);
|
|
1754
1622
|
}
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
function enableFieldsInContainer(container) {
|
|
1627
|
+
const inputs = container.querySelectorAll('input, select, textarea');
|
|
1628
|
+
inputs.forEach(input => {
|
|
1629
|
+
if (input.dataset.originalRequired === 'true') {
|
|
1630
|
+
input.required = true;
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
function disableFieldsInContainer(container) {
|
|
1636
|
+
const inputs = container.querySelectorAll('input, select, textarea');
|
|
1637
|
+
inputs.forEach(input => {
|
|
1638
|
+
if (input.dataset.originalRequired === undefined) {
|
|
1639
|
+
input.dataset.originalRequired = input.required.toString();
|
|
1640
|
+
}
|
|
1641
|
+
input.required = false;
|
|
1755
1642
|
|
|
1756
|
-
|
|
1757
|
-
|
|
1643
|
+
// Limpar valores
|
|
1644
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
1645
|
+
input.checked = false;
|
|
1646
|
+
} else {
|
|
1647
|
+
input.value = '';
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
// MULTI-REDIRECT FIELDS
|
|
1653
|
+
function initializeMultiRedirectFields() {
|
|
1654
|
+
const groups = document.querySelectorAll('[data-field-type="checkbox_multi_redirect_field"]');
|
|
1758
1655
|
|
|
1759
|
-
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
hiddenSections.delete(sectionName);
|
|
1656
|
+
groups.forEach(group => {
|
|
1657
|
+
const fieldId = group.dataset.fieldId;
|
|
1658
|
+
const inputs = group.querySelectorAll('input[type="checkbox"], input[type="radio"], select');
|
|
1764
1659
|
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
}
|
|
1660
|
+
inputs.forEach(input => {
|
|
1661
|
+
input.addEventListener('change', function() {
|
|
1662
|
+
handleMultiRedirectField(this, fieldId);
|
|
1663
|
+
});
|
|
1664
|
+
});
|
|
1770
1665
|
|
|
1771
|
-
console.log(
|
|
1772
|
-
}
|
|
1666
|
+
console.log(`Multi-redirect configurado: ${fieldId}`);
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
function handleMultiRedirectField(input, fieldId) {
|
|
1671
|
+
const selectedValue = input.value;
|
|
1773
1672
|
|
|
1774
|
-
|
|
1775
|
-
const fields = sectionElement.querySelectorAll('input, select, textarea');
|
|
1776
|
-
for (let i = 0; i < fields.length; i++) {
|
|
1777
|
-
const field = fields[i];
|
|
1778
|
-
field.dataset.wasRequired = field.required ? 'true' : 'false';
|
|
1779
|
-
field.required = false;
|
|
1780
|
-
field.disabled = true;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1673
|
+
if (!input.checked && input.type !== 'select-one') return;
|
|
1783
1674
|
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1675
|
+
console.log(`Multi-redirect: ${fieldId} = ${selectedValue}`);
|
|
1676
|
+
|
|
1677
|
+
// Ocultar todos os containers condicionais deste campo
|
|
1678
|
+
const allContainers = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
1679
|
+
allContainers.forEach(container => {
|
|
1680
|
+
container.style.display = 'none';
|
|
1681
|
+
disableFieldsInContainer(container);
|
|
1682
|
+
});
|
|
1683
|
+
|
|
1684
|
+
// Mostrar apenas o container específico
|
|
1685
|
+
const targetContainer = document.querySelector(`[data-parent-field="${fieldId}"][data-option-value="${selectedValue}"]`);
|
|
1686
|
+
if (targetContainer) {
|
|
1687
|
+
targetContainer.style.display = 'block';
|
|
1688
|
+
enableFieldsInContainer(targetContainer);
|
|
1793
1689
|
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
// WIZARD FUNCTIONS (mantém as funções existentes do wizard)
|
|
1693
|
+
function initializeWizard() {
|
|
1694
|
+
const allDividers = [];
|
|
1794
1695
|
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
const stepElement = document.getElementById('step' + i);
|
|
1801
|
-
if (stepElement) {
|
|
1802
|
-
const dividers = stepElement.querySelectorAll('.divider-title');
|
|
1803
|
-
for (let j = 0; j < dividers.length; j++) {
|
|
1804
|
-
allDividers.push({
|
|
1805
|
-
title: dividers[j].textContent.trim(),
|
|
1806
|
-
element: dividers[j],
|
|
1807
|
-
stepNumber: i
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
if (allDividers.length === 0) {
|
|
1814
|
-
for (let i = 1; i <= formSteps; i++) {
|
|
1696
|
+
for (let i = 1; i <= formSteps; i++) {
|
|
1697
|
+
const stepElement = document.getElementById('step' + i);
|
|
1698
|
+
if (stepElement) {
|
|
1699
|
+
const dividers = stepElement.querySelectorAll('.divider-title');
|
|
1700
|
+
dividers.forEach(divider => {
|
|
1815
1701
|
allDividers.push({
|
|
1816
|
-
title:
|
|
1817
|
-
element:
|
|
1702
|
+
title: divider.textContent.trim(),
|
|
1703
|
+
element: divider,
|
|
1818
1704
|
stepNumber: i
|
|
1819
1705
|
});
|
|
1820
|
-
}
|
|
1706
|
+
});
|
|
1821
1707
|
}
|
|
1822
|
-
|
|
1823
|
-
wizardSteps = allDividers;
|
|
1824
|
-
createWizardSteps();
|
|
1825
1708
|
}
|
|
1826
1709
|
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
for (let i = 0; i < wizardSteps.length; i++) {
|
|
1834
|
-
const step = wizardSteps[i];
|
|
1835
|
-
const stepDiv = document.createElement('div');
|
|
1836
|
-
stepDiv.className = 'wizard-step';
|
|
1837
|
-
stepDiv.style.cursor = 'pointer';
|
|
1838
|
-
stepDiv.setAttribute('data-index', i);
|
|
1839
|
-
stepDiv.setAttribute('data-step-number', step.stepNumber);
|
|
1840
|
-
|
|
1841
|
-
stepDiv.innerHTML = '<div class="step-circle"><span>' + (i + 1) + '</span></div><div class="step-label">' + step.title + '</div>';
|
|
1842
|
-
|
|
1843
|
-
stepDiv.addEventListener('click', function() {
|
|
1844
|
-
scrollToWizardStep(i);
|
|
1710
|
+
if (allDividers.length === 0) {
|
|
1711
|
+
for (let i = 1; i <= formSteps; i++) {
|
|
1712
|
+
allDividers.push({
|
|
1713
|
+
title: 'Etapa ' + i,
|
|
1714
|
+
element: null,
|
|
1715
|
+
stepNumber: i
|
|
1845
1716
|
});
|
|
1846
|
-
|
|
1847
|
-
wizardContainer.appendChild(stepDiv);
|
|
1848
1717
|
}
|
|
1849
1718
|
}
|
|
1850
1719
|
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
}
|
|
1720
|
+
wizardSteps = allDividers;
|
|
1721
|
+
createWizardSteps();
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
function createWizardSteps() {
|
|
1725
|
+
const wizardContainer = document.getElementById('wizardSteps');
|
|
1726
|
+
if (!wizardContainer) return;
|
|
1727
|
+
|
|
1728
|
+
wizardContainer.innerHTML = '';
|
|
1729
|
+
|
|
1730
|
+
wizardSteps.forEach((step, i) => {
|
|
1731
|
+
const stepDiv = document.createElement('div');
|
|
1732
|
+
stepDiv.className = 'wizard-step';
|
|
1733
|
+
stepDiv.style.cursor = 'pointer';
|
|
1734
|
+
stepDiv.setAttribute('data-index', i);
|
|
1735
|
+
stepDiv.innerHTML = `
|
|
1736
|
+
<div class="step-circle"><span>${i + 1}</span></div>
|
|
1737
|
+
<div class="step-label">${step.title}</div>
|
|
1738
|
+
`;
|
|
1739
|
+
|
|
1740
|
+
stepDiv.addEventListener('click', () => scrollToWizardStep(i));
|
|
1741
|
+
wizardContainer.appendChild(stepDiv);
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
function scrollToWizardStep(stepIndex) {
|
|
1746
|
+
if (stepIndex < 0 || stepIndex >= wizardSteps.length) return;
|
|
1879
1747
|
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
if (!formContent) return;
|
|
1883
|
-
|
|
1884
|
-
let scrollTimeout;
|
|
1885
|
-
|
|
1886
|
-
function handleScroll() {
|
|
1887
|
-
if (isScrolling) return;
|
|
1888
|
-
|
|
1889
|
-
const scrollTop = formContent.scrollTop;
|
|
1890
|
-
const containerHeight = formContent.clientHeight;
|
|
1891
|
-
const viewportCenter = scrollTop + (containerHeight / 3);
|
|
1892
|
-
|
|
1893
|
-
let newActiveIndex = 0;
|
|
1894
|
-
|
|
1895
|
-
for (let i = 0; i < wizardSteps.length; i++) {
|
|
1896
|
-
const step = wizardSteps[i];
|
|
1897
|
-
if (!step.element) continue;
|
|
1898
|
-
|
|
1899
|
-
const elementRect = step.element.getBoundingClientRect();
|
|
1900
|
-
const containerRect = formContent.getBoundingClientRect();
|
|
1901
|
-
const elementTop = elementRect.top - containerRect.top + scrollTop;
|
|
1902
|
-
|
|
1903
|
-
if (elementTop <= viewportCenter + 50) {
|
|
1904
|
-
newActiveIndex = i;
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
if (newActiveIndex !== currentActiveWizardIndex) {
|
|
1909
|
-
currentActiveWizardIndex = newActiveIndex;
|
|
1910
|
-
updateWizardVisual();
|
|
1911
|
-
updateDividerVisual();
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
currentActiveWizardIndex = 0;
|
|
1916
|
-
updateWizardVisual();
|
|
1917
|
-
updateDividerVisual();
|
|
1918
|
-
|
|
1919
|
-
formContent.addEventListener('scroll', function() {
|
|
1920
|
-
clearTimeout(scrollTimeout);
|
|
1921
|
-
scrollTimeout = setTimeout(handleScroll, 30);
|
|
1922
|
-
});
|
|
1923
|
-
|
|
1924
|
-
setTimeout(handleScroll, 300);
|
|
1925
|
-
}
|
|
1748
|
+
const step = wizardSteps[stepIndex];
|
|
1749
|
+
const formContent = document.getElementById('formContent');
|
|
1926
1750
|
|
|
1927
|
-
|
|
1928
|
-
const allSteps = document.querySelectorAll('.wizard-step');
|
|
1929
|
-
|
|
1930
|
-
for (let i = 0; i < allSteps.length; i++) {
|
|
1931
|
-
const stepElement = allSteps[i];
|
|
1932
|
-
stepElement.classList.remove('active', 'completed');
|
|
1933
|
-
|
|
1934
|
-
if (i < currentActiveWizardIndex) {
|
|
1935
|
-
stepElement.classList.add('completed');
|
|
1936
|
-
} else if (i === currentActiveWizardIndex) {
|
|
1937
|
-
stepElement.classList.add('active');
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1751
|
+
if (!step.element || !formContent) return;
|
|
1941
1752
|
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
}
|
|
1753
|
+
isScrolling = true;
|
|
1754
|
+
|
|
1755
|
+
const elementRect = step.element.getBoundingClientRect();
|
|
1756
|
+
const containerRect = formContent.getBoundingClientRect();
|
|
1757
|
+
const relativeTop = elementRect.top - containerRect.top + formContent.scrollTop;
|
|
1758
|
+
const targetScrollTop = relativeTop - 100;
|
|
1759
|
+
|
|
1760
|
+
formContent.scrollTo({
|
|
1761
|
+
top: targetScrollTop,
|
|
1762
|
+
behavior: 'smooth'
|
|
1763
|
+
});
|
|
1764
|
+
|
|
1765
|
+
currentActiveWizardIndex = stepIndex;
|
|
1766
|
+
updateWizardVisual();
|
|
1953
1767
|
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1768
|
+
setTimeout(() => { isScrolling = false; }, 1000);
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
function updateWizardVisual() {
|
|
1772
|
+
const allSteps = document.querySelectorAll('.wizard-step');
|
|
1773
|
+
|
|
1774
|
+
allSteps.forEach((stepElement, i) => {
|
|
1775
|
+
stepElement.classList.remove('active', 'completed');
|
|
1957
1776
|
|
|
1958
|
-
if (
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1777
|
+
if (i < currentActiveWizardIndex) {
|
|
1778
|
+
stepElement.classList.add('completed');
|
|
1779
|
+
} else if (i === currentActiveWizardIndex) {
|
|
1780
|
+
stepElement.classList.add('active');
|
|
1962
1781
|
}
|
|
1963
|
-
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
function createConfetti() {
|
|
1786
|
+
const colors = ['#2d5530', '#4CAF50', '#ffd700', '#ff6b6b'];
|
|
1787
|
+
|
|
1788
|
+
for (let i = 0; i < 50; i++) {
|
|
1789
|
+
setTimeout(() => {
|
|
1790
|
+
const confetti = document.createElement('div');
|
|
1791
|
+
confetti.className = 'confetti';
|
|
1792
|
+
Object.assign(confetti.style, {
|
|
1793
|
+
position: 'fixed',
|
|
1794
|
+
left: Math.random() * 100 + 'vw',
|
|
1795
|
+
top: '-10px',
|
|
1796
|
+
width: '10px',
|
|
1797
|
+
height: '10px',
|
|
1798
|
+
background: colors[Math.floor(Math.random() * colors.length)],
|
|
1799
|
+
borderRadius: Math.random() > 0.5 ? '50%' : '0',
|
|
1800
|
+
zIndex: '1001',
|
|
1801
|
+
pointerEvents: 'none',
|
|
1802
|
+
animation: `confetti-fall ${Math.random() * 3 + 2}s linear infinite`
|
|
1803
|
+
});
|
|
1804
|
+
|
|
1805
|
+
document.body.appendChild(confetti);
|
|
1806
|
+
setTimeout(() => confetti.remove(), 5000);
|
|
1807
|
+
}, i * 50);
|
|
1964
1808
|
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// INICIALIZAÇÃO
|
|
1812
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1813
|
+
console.log('Formulário carregando...');
|
|
1965
1814
|
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
confetti.style.position = 'fixed';
|
|
1974
|
-
confetti.style.left = Math.random() * 100 + 'vw';
|
|
1975
|
-
confetti.style.top = '-10px';
|
|
1976
|
-
confetti.style.width = '10px';
|
|
1977
|
-
confetti.style.height = '10px';
|
|
1978
|
-
confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
|
|
1979
|
-
confetti.style.borderRadius = Math.random() > 0.5 ? '50%' : '0';
|
|
1980
|
-
confetti.style.zIndex = '1001';
|
|
1981
|
-
confetti.style.pointerEvents = 'none';
|
|
1982
|
-
confetti.style.animation = 'confetti-fall ' + (Math.random() * 3 + 2) + 's linear infinite';
|
|
1983
|
-
confetti.style.animationDelay = Math.random() * 2 + 's';
|
|
1984
|
-
|
|
1985
|
-
document.body.appendChild(confetti);
|
|
1986
|
-
|
|
1987
|
-
setTimeout(function() {
|
|
1988
|
-
if (confetti.parentNode) {
|
|
1989
|
-
confetti.remove();
|
|
1990
|
-
}
|
|
1991
|
-
}, 5000);
|
|
1992
|
-
}, i * 50);
|
|
1993
|
-
}
|
|
1815
|
+
// Verificar success na URL
|
|
1816
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
1817
|
+
if (urlParams.get('success') === '1') {
|
|
1818
|
+
currentStep = successStepIndex;
|
|
1819
|
+
showStep(currentStep);
|
|
1820
|
+
} else {
|
|
1821
|
+
showStep(0);
|
|
1994
1822
|
}
|
|
1995
1823
|
|
|
1996
|
-
//
|
|
1997
|
-
|
|
1998
|
-
console.log('DOM carregado');
|
|
1999
|
-
|
|
2000
|
-
// Inicializar sistemas
|
|
2001
|
-
initializeSmartNavigation();
|
|
2002
|
-
|
|
1824
|
+
// Inicializar sistemas
|
|
1825
|
+
setTimeout(() => {
|
|
2003
1826
|
initializeConditionalFields();
|
|
2004
1827
|
initializeMultiRedirectFields();
|
|
2005
|
-
|
|
2006
|
-
// Verificar success na URL primeiro
|
|
2007
|
-
if (!checkForSuccess()) {
|
|
2008
|
-
showStep(0);
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
// Scroll inicial para o topo
|
|
2012
|
-
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
2013
|
-
});
|
|
1828
|
+
}, 500);
|
|
2014
1829
|
|
|
2015
|
-
//
|
|
1830
|
+
// Formatação CPF/telefone
|
|
2016
1831
|
document.addEventListener('input', function(e) {
|
|
2017
1832
|
if (e.target.classList.contains('cpf-field')) {
|
|
2018
1833
|
let value = e.target.value.replace(/[^\d]/g, '');
|
|
@@ -2041,7 +1856,7 @@
|
|
|
2041
1856
|
}
|
|
2042
1857
|
});
|
|
2043
1858
|
|
|
2044
|
-
//
|
|
1859
|
+
// Rating com estrelas
|
|
2045
1860
|
document.addEventListener('click', function(e) {
|
|
2046
1861
|
if (e.target.classList.contains('star')) {
|
|
2047
1862
|
const ratingGroup = e.target.parentNode;
|
|
@@ -2052,570 +1867,72 @@
|
|
|
2052
1867
|
hiddenInput.value = value;
|
|
2053
1868
|
|
|
2054
1869
|
const stars = ratingGroup.querySelectorAll('.star');
|
|
2055
|
-
|
|
1870
|
+
stars.forEach((star, i) => {
|
|
2056
1871
|
if (i < value) {
|
|
2057
|
-
|
|
1872
|
+
star.classList.add('active');
|
|
2058
1873
|
} else {
|
|
2059
|
-
|
|
1874
|
+
star.classList.remove('active');
|
|
2060
1875
|
}
|
|
2061
|
-
}
|
|
1876
|
+
});
|
|
2062
1877
|
|
|
2063
1878
|
const ratingText = ratingGroup.querySelector('.rating-text');
|
|
2064
1879
|
if (ratingText) {
|
|
2065
|
-
|
|
2066
|
-
ratingText.textContent = value + ' de ' + maxRating + ' estrelas';
|
|
1880
|
+
ratingText.textContent = `${value} de ${stars.length} estrelas`;
|
|
2067
1881
|
}
|
|
2068
1882
|
}
|
|
2069
1883
|
}
|
|
2070
1884
|
});
|
|
2071
1885
|
|
|
2072
|
-
|
|
1886
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
1887
|
+
console.log('Formulário carregado!');
|
|
1888
|
+
});
|
|
2073
1889
|
|
|
2074
|
-
|
|
2075
|
-
function
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
if (
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
1890
|
+
// FUNÇÕES DE UPLOAD (mantém as existentes)
|
|
1891
|
+
function updateFileName(input) {
|
|
1892
|
+
const fieldId = input.id;
|
|
1893
|
+
const displayDiv = document.getElementById(`file-display-${fieldId}`);
|
|
1894
|
+
const errorDiv = document.getElementById(`file-error-${fieldId}`);
|
|
1895
|
+
const dropzone = document.getElementById(`dropzone-${fieldId}`);
|
|
1896
|
+
|
|
1897
|
+
errorDiv.style.display = 'none';
|
|
1898
|
+
errorDiv.textContent = '';
|
|
1899
|
+
|
|
1900
|
+
if (input.files && input.files.length > 0) {
|
|
1901
|
+
const maxSize = parseInt(input.dataset.maxSize) * 1024 * 1024;
|
|
1902
|
+
const file = input.files[0];
|
|
1903
|
+
|
|
1904
|
+
if (file.size > maxSize) {
|
|
1905
|
+
errorDiv.textContent = `Arquivo excede ${input.dataset.maxSize}MB`;
|
|
1906
|
+
errorDiv.style.display = 'block';
|
|
1907
|
+
input.value = '';
|
|
1908
|
+
return;
|
|
2092
1909
|
}
|
|
2093
1910
|
|
|
2094
|
-
|
|
1911
|
+
const fileSize = (file.size / (1024 * 1024)).toFixed(2);
|
|
1912
|
+
displayDiv.innerHTML = `
|
|
1913
|
+
<div style="display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; background: #f8f9fa; border-radius: 4px;">
|
|
1914
|
+
<span>📎</span>
|
|
1915
|
+
<span style="flex: 1;">${file.name}</span>
|
|
1916
|
+
<span style="color: #666; font-size: 0.8rem;">${fileSize}MB</span>
|
|
1917
|
+
<span style="color: #28a745;">✓</span>
|
|
1918
|
+
</div>
|
|
1919
|
+
`;
|
|
1920
|
+
displayDiv.style.display = 'block';
|
|
2095
1921
|
}
|
|
2096
1922
|
}
|
|
2097
1923
|
|
|
2098
|
-
function
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2101
|
-
'
|
|
2102
|
-
'
|
|
2103
|
-
'
|
|
2104
|
-
|
|
2105
|
-
];
|
|
2106
|
-
|
|
2107
|
-
childrenQuestionIds.forEach(questionId => {
|
|
2108
|
-
const questionElement = document.querySelector(questionId);
|
|
2109
|
-
if (questionElement) {
|
|
2110
|
-
questionElement.style.display = 'block';
|
|
2111
|
-
questionElement.style.animation = 'fadeIn 0.3s ease-in-out';
|
|
2112
|
-
|
|
2113
|
-
// Reativar campos obrigatórios
|
|
2114
|
-
const inputs = questionElement.querySelectorAll('input, select, textarea');
|
|
2115
|
-
inputs.forEach(input => {
|
|
2116
|
-
if (input.dataset.originalRequired === 'true') {
|
|
2117
|
-
input.required = true;
|
|
2118
|
-
}
|
|
2119
|
-
});
|
|
2120
|
-
}
|
|
2121
|
-
});
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
function hideChildrenQuestions() {
|
|
2125
|
-
// IDs ou seletores das perguntas 2-5 sobre filhos
|
|
2126
|
-
const childrenQuestionIds = [
|
|
2127
|
-
'#question-2-children', // Substitua pelos IDs reais
|
|
2128
|
-
'#question-3-children',
|
|
2129
|
-
'#question-4-children',
|
|
2130
|
-
'#question-5-children'
|
|
2131
|
-
];
|
|
2132
|
-
|
|
2133
|
-
childrenQuestionIds.forEach(questionId => {
|
|
2134
|
-
const questionElement = document.querySelector(questionId);
|
|
2135
|
-
if (questionElement) {
|
|
2136
|
-
questionElement.style.display = 'none';
|
|
2137
|
-
|
|
2138
|
-
// Salvar estado required e desativar
|
|
2139
|
-
const inputs = questionElement.querySelectorAll('input, select, textarea');
|
|
2140
|
-
inputs.forEach(input => {
|
|
2141
|
-
// Salvar estado original
|
|
2142
|
-
if (!input.dataset.originalRequired) {
|
|
2143
|
-
input.dataset.originalRequired = input.required.toString();
|
|
2144
|
-
}
|
|
2145
|
-
input.required = false;
|
|
2146
|
-
|
|
2147
|
-
// Limpar valores
|
|
2148
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2149
|
-
input.checked = false;
|
|
2150
|
-
} else {
|
|
2151
|
-
input.value = '';
|
|
2152
|
-
}
|
|
2153
|
-
});
|
|
2154
|
-
}
|
|
2155
|
-
});
|
|
1924
|
+
function getFileIcon(filename) {
|
|
1925
|
+
const ext = filename.split('.').pop().toLowerCase();
|
|
1926
|
+
const icons = {
|
|
1927
|
+
'pdf': '📄', 'doc': '📝', 'docx': '📝',
|
|
1928
|
+
'xls': '📊', 'xlsx': '📊',
|
|
1929
|
+
'jpg': '🖼️', 'jpeg': '🖼️', 'png': '🖼️'
|
|
1930
|
+
};
|
|
1931
|
+
return icons[ext] || '📎';
|
|
2156
1932
|
}
|
|
2157
|
-
|
|
2158
|
-
function handleSmartNavigation(element) {
|
|
2159
|
-
const fieldContainer = element.closest('[data-field-type="smart_navigation_field"], [data-field-type="checkbox_multi_redirect_field"]');
|
|
2160
|
-
if (!fieldContainer) return;
|
|
2161
|
-
|
|
2162
|
-
const fieldId = fieldContainer.dataset.fieldId;
|
|
2163
|
-
const selectedValue = getSelectedValue(element);
|
|
2164
|
-
|
|
2165
|
-
console.log(`Smart navigation: ${fieldId} = ${selectedValue}`);
|
|
2166
|
-
|
|
2167
|
-
if (!selectedValue) return;
|
|
2168
|
-
|
|
2169
|
-
// Para multi-redirect fields
|
|
2170
|
-
if (fieldContainer.dataset.fieldType === 'checkbox_multi_redirect_field') {
|
|
2171
|
-
const configData = fieldContainer.dataset.fieldConfig;
|
|
2172
|
-
if (configData) {
|
|
2173
|
-
try {
|
|
2174
|
-
const config = JSON.parse(configData);
|
|
2175
|
-
const option = config.options.find(opt => opt.value === selectedValue);
|
|
2176
|
-
|
|
2177
|
-
if (option) {
|
|
2178
|
-
console.log(`Ação encontrada: ${option.action} para ${selectedValue}`);
|
|
2179
|
-
|
|
2180
|
-
// Limpar campos condicionais primeiro
|
|
2181
|
-
hideAllConditionalFields(fieldId);
|
|
2182
|
-
|
|
2183
|
-
switch(option.action) {
|
|
2184
|
-
case 'show_fields':
|
|
2185
|
-
showConditionalFields(fieldId, selectedValue);
|
|
2186
|
-
break;
|
|
2187
|
-
case 'skip_to_end':
|
|
2188
|
-
setTimeout(() => {
|
|
2189
|
-
const form = document.getElementById('wagtailForm');
|
|
2190
|
-
if (form) form.submit();
|
|
2191
|
-
}, (option.delay || 1) * 1000);
|
|
2192
|
-
break;
|
|
2193
|
-
case 'continue':
|
|
2194
|
-
console.log('Continuando normalmente');
|
|
2195
|
-
break;
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
} catch(e) {
|
|
2199
|
-
console.error('Erro config multi-redirect:', e);
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
return;
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
// Para smart navigation normal
|
|
2206
|
-
if (!navigationData[fieldId]) return;
|
|
2207
|
-
const actionData = navigationData[fieldId][selectedValue];
|
|
2208
|
-
if (!actionData) return;
|
|
2209
|
-
|
|
2210
|
-
switch (actionData.action_type) {
|
|
2211
|
-
case 'jump_to_section':
|
|
2212
|
-
handleJumpToSection(actionData.target_section);
|
|
2213
|
-
break;
|
|
2214
|
-
case 'finish_form':
|
|
2215
|
-
handleFinishForm();
|
|
2216
|
-
break;
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
function showConditionalFields(fieldId, value) {
|
|
2221
|
-
console.log(`Mostrando campos condicionais para ${fieldId} = ${value}`);
|
|
2222
|
-
|
|
2223
|
-
// Primeiro: esconder TODOS os campos condicionais deste campo
|
|
2224
|
-
hideAllConditionalFields(fieldId);
|
|
2225
|
-
|
|
2226
|
-
// Segundo: mostrar apenas o campo específico para este valor
|
|
2227
|
-
const specificField = document.querySelector(
|
|
2228
|
-
`[data-parent-field="${fieldId}"][data-option-value="${value}"]`
|
|
2229
|
-
);
|
|
2230
|
-
|
|
2231
|
-
if (specificField) {
|
|
2232
|
-
specificField.style.display = 'block';
|
|
2233
|
-
|
|
2234
|
-
// Animação suave
|
|
2235
|
-
specificField.style.opacity = '0';
|
|
2236
|
-
specificField.style.transform = 'translateY(-10px)';
|
|
2237
|
-
|
|
2238
|
-
setTimeout(() => {
|
|
2239
|
-
specificField.style.transition = 'all 0.3s ease';
|
|
2240
|
-
specificField.style.opacity = '1';
|
|
2241
|
-
specificField.style.transform = 'translateY(0)';
|
|
2242
|
-
}, 10);
|
|
2243
|
-
|
|
2244
|
-
console.log(`✅ Campo condicional mostrado para valor: ${value}`);
|
|
2245
|
-
|
|
2246
|
-
// Scroll suave para o campo que apareceu
|
|
2247
|
-
setTimeout(() => {
|
|
2248
|
-
specificField.scrollIntoView({
|
|
2249
|
-
behavior: 'smooth',
|
|
2250
|
-
block: 'nearest'
|
|
2251
|
-
});
|
|
2252
|
-
}, 200);
|
|
2253
|
-
} else {
|
|
2254
|
-
console.log(`⚠️ Nenhum campo condicional encontrado para valor: ${value}`);
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
function hideAllConditionalFields(fieldId) {
|
|
2259
|
-
// Esconder apenas os campos condicionais DESTE campo específico
|
|
2260
|
-
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
2261
|
-
|
|
2262
|
-
conditionalFields.forEach(field => {
|
|
2263
|
-
field.style.display = 'none';
|
|
2264
|
-
|
|
2265
|
-
// Limpar valores dos campos ocultos
|
|
2266
|
-
const inputs = field.querySelectorAll('input, select, textarea');
|
|
2267
|
-
inputs.forEach(input => {
|
|
2268
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2269
|
-
input.checked = false;
|
|
2270
|
-
} else {
|
|
2271
|
-
input.value = '';
|
|
2272
|
-
}
|
|
2273
|
-
input.required = false;
|
|
2274
|
-
});
|
|
2275
|
-
});
|
|
2276
|
-
|
|
2277
|
-
console.log(`Campos condicionais ocultos para: ${fieldId}`);
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
// SUBSTITUA as funções de campos condicionais por estas:
|
|
2281
|
-
|
|
2282
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
2283
|
-
console.log('DOM carregado - inicializando campos condicionais');
|
|
2284
|
-
|
|
2285
|
-
// Aguardar um pouco para garantir que tudo carregou
|
|
2286
|
-
setTimeout(() => {
|
|
2287
|
-
initializeAllConditionalFields();
|
|
2288
|
-
}, 500);
|
|
2289
|
-
});
|
|
2290
|
-
|
|
2291
|
-
function initializeAllConditionalFields() {
|
|
2292
|
-
// Campos conditional_field_condicional
|
|
2293
|
-
const triggers = document.querySelectorAll('select[data-field-id*="conditional_field_condicional"]');
|
|
2294
|
-
console.log(`Triggers encontrados: ${triggers.length}`);
|
|
2295
|
-
|
|
2296
|
-
triggers.forEach(trigger => {
|
|
2297
|
-
console.log(`Configurando trigger: ${trigger.id}`);
|
|
2298
|
-
|
|
2299
|
-
trigger.addEventListener('change', function() {
|
|
2300
|
-
const fieldId = this.dataset.fieldId;
|
|
2301
|
-
const selectedValue = this.value;
|
|
2302
|
-
|
|
2303
|
-
console.log(`Mudança detectada: ${fieldId} = "${selectedValue}"`);
|
|
2304
|
-
|
|
2305
|
-
// Encontrar containers condicionais
|
|
2306
|
-
const containers = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
2307
|
-
console.log(`Containers encontrados: ${containers.length}`);
|
|
2308
|
-
|
|
2309
|
-
// Esconder todos primeiro
|
|
2310
|
-
containers.forEach(container => {
|
|
2311
|
-
container.style.display = 'none';
|
|
2312
|
-
console.log(`Ocultando container com triggerValue: ${container.dataset.triggerValue}`);
|
|
2313
|
-
});
|
|
2314
|
-
|
|
2315
|
-
// Mostrar apenas o correto
|
|
2316
|
-
if (selectedValue) {
|
|
2317
|
-
const targetContainer = document.querySelector(`[data-parent-field="${fieldId}"][data-trigger-value="${selectedValue}"]`);
|
|
2318
|
-
if (targetContainer) {
|
|
2319
|
-
targetContainer.style.display = 'block';
|
|
2320
|
-
console.log(`Mostrando container para: ${selectedValue}`);
|
|
2321
|
-
} else {
|
|
2322
|
-
console.log(`Container não encontrado para valor: ${selectedValue}`);
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
2326
|
-
});
|
|
2327
|
-
|
|
2328
|
-
// Multi-redirect fields
|
|
2329
|
-
const multiRedirectGroups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
2330
|
-
console.log(`Multi-redirect groups: ${multiRedirectGroups.length}`);
|
|
2331
|
-
|
|
2332
|
-
multiRedirectGroups.forEach(group => {
|
|
2333
|
-
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
2334
|
-
const fieldId = group.dataset.fieldId;
|
|
2335
|
-
|
|
2336
|
-
inputs.forEach(input => {
|
|
2337
|
-
input.addEventListener('change', function() {
|
|
2338
|
-
const selectedValue = this.value;
|
|
2339
|
-
const configData = group.dataset.fieldConfig;
|
|
2340
|
-
|
|
2341
|
-
console.log(`Multi-redirect mudou: ${fieldId} = "${selectedValue}"`);
|
|
2342
|
-
|
|
2343
|
-
if (configData) {
|
|
2344
|
-
try {
|
|
2345
|
-
const config = JSON.parse(configData);
|
|
2346
|
-
const option = config.options.find(opt => opt.value === selectedValue);
|
|
2347
|
-
|
|
2348
|
-
if (option) {
|
|
2349
|
-
console.log(`Ação: ${option.action} para ${selectedValue}`);
|
|
2350
|
-
|
|
2351
|
-
// Mostrar mensagem se configurada
|
|
2352
|
-
if (option.message) {
|
|
2353
|
-
showRedirectMessage(fieldId, option, config.options.indexOf(option));
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
if (option.action === 'skip_to_end') {
|
|
2357
|
-
console.log('Finalizando formulário...');
|
|
2358
|
-
|
|
2359
|
-
// Mostrar mensagem por X segundos antes de finalizar
|
|
2360
|
-
const delay = (option.delay || 1) * 1000;
|
|
2361
|
-
|
|
2362
|
-
setTimeout(() => {
|
|
2363
|
-
const form = document.getElementById('wagtailForm');
|
|
2364
|
-
if (form) {
|
|
2365
|
-
form.submit();
|
|
2366
|
-
} else {
|
|
2367
|
-
console.log('Formulário não encontrado!');
|
|
2368
|
-
}
|
|
2369
|
-
}, delay);
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
} catch(e) {
|
|
2373
|
-
console.error('Erro ao processar config:', e);
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
});
|
|
2377
|
-
});
|
|
2378
|
-
});
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
function showRedirectMessage(fieldId, option, optionIndex) {
|
|
2382
|
-
const blockId = fieldId.split('_').pop();
|
|
2383
|
-
const messageEl = document.getElementById(`redirect_message_${blockId}_${optionIndex}`);
|
|
2384
|
-
|
|
2385
|
-
if (messageEl) {
|
|
2386
|
-
messageEl.style.display = 'block';
|
|
2387
|
-
console.log(`Mensagem mostrada: ${option.message}`);
|
|
2388
|
-
|
|
2389
|
-
// Scroll para a mensagem
|
|
2390
|
-
setTimeout(() => {
|
|
2391
|
-
messageEl.scrollIntoView({
|
|
2392
|
-
behavior: 'smooth',
|
|
2393
|
-
block: 'center'
|
|
2394
|
-
});
|
|
2395
|
-
}, 100);
|
|
2396
|
-
} else {
|
|
2397
|
-
console.log(`Elemento de mensagem não encontrado: redirect_message_${blockId}_${optionIndex}`);
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2401
|
-
function handleConditionalFieldFixed(triggerElement) {
|
|
2402
|
-
const fieldId = triggerElement.dataset.fieldId;
|
|
2403
|
-
const selectedValue = triggerElement.value;
|
|
2404
|
-
|
|
2405
|
-
console.log(`🎯 Campo condicional: ${fieldId} = "${selectedValue}"`);
|
|
2406
|
-
|
|
2407
|
-
// Encontrar APENAS os divs condicionais diretos
|
|
2408
|
-
const conditionalContainers = document.querySelectorAll(`div[data-parent-field="${fieldId}"]`);
|
|
2409
|
-
|
|
2410
|
-
console.log(`Containers encontrados: ${conditionalContainers.length}`);
|
|
2411
|
-
|
|
2412
|
-
conditionalContainers.forEach((container, index) => {
|
|
2413
|
-
const triggerValue = container.dataset.triggerValue;
|
|
2414
|
-
console.log(`Container ${index}: triggerValue="${triggerValue}", selectedValue="${selectedValue}"`);
|
|
2415
|
-
|
|
2416
|
-
if (selectedValue === triggerValue) {
|
|
2417
|
-
console.log(`✅ Mostrando container para valor: ${triggerValue}`);
|
|
2418
|
-
container.style.display = 'block';
|
|
2419
|
-
|
|
2420
|
-
// Reativar campos dentro do container
|
|
2421
|
-
const inputs = container.querySelectorAll('input, select, textarea');
|
|
2422
|
-
inputs.forEach(input => {
|
|
2423
|
-
if (input.dataset.wasRequired === 'true') {
|
|
2424
|
-
input.required = true;
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
} else {
|
|
2428
|
-
console.log(`❌ Ocultando container para valor: ${triggerValue}`);
|
|
2429
|
-
container.style.display = 'none';
|
|
2430
|
-
|
|
2431
|
-
// Desativar campos dentro do container
|
|
2432
|
-
const inputs = container.querySelectorAll('input, select, textarea');
|
|
2433
|
-
inputs.forEach(input => {
|
|
2434
|
-
if (!input.dataset.wasRequired) {
|
|
2435
|
-
input.dataset.wasRequired = input.required ? 'true' : 'false';
|
|
2436
|
-
}
|
|
2437
|
-
input.required = false;
|
|
2438
|
-
|
|
2439
|
-
// Limpar valores
|
|
2440
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2441
|
-
input.checked = false;
|
|
2442
|
-
} else {
|
|
2443
|
-
input.value = '';
|
|
2444
|
-
}
|
|
2445
|
-
});
|
|
2446
|
-
}
|
|
2447
|
-
});
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
|
-
function initializeMultiRedirectFields() {
|
|
2451
|
-
const groups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
2452
|
-
|
|
2453
|
-
groups.forEach(group => {
|
|
2454
|
-
const fieldId = group.dataset.fieldId;
|
|
2455
|
-
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
2456
|
-
|
|
2457
|
-
inputs.forEach(input => {
|
|
2458
|
-
input.addEventListener('change', function() {
|
|
2459
|
-
const selectedValue = this.value;
|
|
2460
|
-
|
|
2461
|
-
console.log(`Multi-redirect mudou: ${fieldId} = ${selectedValue}`);
|
|
2462
|
-
|
|
2463
|
-
// Limpar todos os campos condicionais deste grupo primeiro
|
|
2464
|
-
hideAllConditionalFields(fieldId);
|
|
2465
|
-
|
|
2466
|
-
// Se tem valor selecionado, mostrar campos específicos
|
|
2467
|
-
if (this.checked || (this.tagName === 'SELECT' && selectedValue)) {
|
|
2468
|
-
// Verificar se tem campos condicionais para esta opção
|
|
2469
|
-
const conditionalField = document.querySelector(
|
|
2470
|
-
`[data-parent-field="${fieldId}"][data-option-value="${selectedValue}"]`
|
|
2471
|
-
);
|
|
2472
|
-
|
|
2473
|
-
if (conditionalField) {
|
|
2474
|
-
conditionalField.style.display = 'block';
|
|
2475
|
-
console.log(`Mostrando campos condicionais para: ${selectedValue}`);
|
|
2476
|
-
|
|
2477
|
-
// Animação suave
|
|
2478
|
-
setTimeout(() => {
|
|
2479
|
-
conditionalField.scrollIntoView({
|
|
2480
|
-
behavior: 'smooth',
|
|
2481
|
-
block: 'nearest'
|
|
2482
|
-
});
|
|
2483
|
-
}, 200);
|
|
2484
|
-
} else {
|
|
2485
|
-
console.log(`Nenhum campo condicional configurado para: ${selectedValue}`);
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
});
|
|
2490
|
-
|
|
2491
|
-
console.log(`Multi-redirect configurado: ${fieldId}`);
|
|
2492
|
-
});
|
|
2493
|
-
|
|
2494
|
-
console.log(`Multi-redirect fields inicializados: ${groups.length}`);
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
function hideAllConditionalFields(fieldId) {
|
|
2498
|
-
// Esconder apenas os campos condicionais DESTE campo específico
|
|
2499
|
-
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"].multi-redirect-fields`);
|
|
2500
|
-
|
|
2501
|
-
conditionalFields.forEach(field => {
|
|
2502
|
-
field.style.display = 'none';
|
|
2503
|
-
|
|
2504
|
-
// Limpar valores dos campos ocultos
|
|
2505
|
-
const inputs = field.querySelectorAll('input, select, textarea');
|
|
2506
|
-
inputs.forEach(input => {
|
|
2507
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2508
|
-
input.checked = false;
|
|
2509
|
-
} else {
|
|
2510
|
-
input.value = '';
|
|
2511
|
-
}
|
|
2512
|
-
input.required = false;
|
|
2513
|
-
});
|
|
2514
|
-
});
|
|
2515
|
-
|
|
2516
|
-
console.log(`Campos condicionais multi-redirect ocultos para: ${fieldId}`);
|
|
2517
|
-
}
|
|
2518
|
-
|
|
2519
|
-
// Função melhorada para redirecionar para seção específica
|
|
2520
|
-
function redirectToSpecificSection(sectionTitle) {
|
|
2521
|
-
console.log(`Procurando seção: "${sectionTitle}"`);
|
|
2522
|
-
|
|
2523
|
-
// Procurar por diferentes tipos de elementos que podem conter o título da seção
|
|
2524
|
-
const selectors = [
|
|
2525
|
-
'.divider-title',
|
|
2526
|
-
'.section-title',
|
|
2527
|
-
'[data-section-title]',
|
|
2528
|
-
'h2', 'h3', 'h4'
|
|
2529
|
-
];
|
|
2530
|
-
|
|
2531
|
-
for (let selector of selectors) {
|
|
2532
|
-
const elements = document.querySelectorAll(selector);
|
|
2533
|
-
|
|
2534
|
-
for (let element of elements) {
|
|
2535
|
-
const elementText = element.textContent?.trim() || '';
|
|
2536
|
-
const dataTitle = element.dataset.sectionTitle || '';
|
|
2537
|
-
|
|
2538
|
-
// Verificar se o texto corresponde (ignorando case e espaços extras)
|
|
2539
|
-
if (elementText.toLowerCase().includes(sectionTitle.toLowerCase()) ||
|
|
2540
|
-
dataTitle.toLowerCase().includes(sectionTitle.toLowerCase()) ||
|
|
2541
|
-
sectionTitle.toLowerCase().includes(elementText.toLowerCase())) {
|
|
2542
|
-
|
|
2543
|
-
console.log(`Seção encontrada: "${elementText}"`);
|
|
2544
|
-
|
|
2545
|
-
// Scroll suave para a seção
|
|
2546
|
-
setTimeout(() => {
|
|
2547
|
-
const formContent = document.getElementById('formContent');
|
|
2548
|
-
if (formContent) {
|
|
2549
|
-
const offset = 120;
|
|
2550
|
-
const elementPosition = element.getBoundingClientRect().top +
|
|
2551
|
-
formContent.scrollTop - offset;
|
|
2552
|
-
|
|
2553
|
-
formContent.scrollTo({
|
|
2554
|
-
top: elementPosition,
|
|
2555
|
-
behavior: 'smooth'
|
|
2556
|
-
});
|
|
2557
|
-
|
|
2558
|
-
// Destacar temporariamente a seção
|
|
2559
|
-
element.style.background = 'rgba(42, 94, 44, 0.1)';
|
|
2560
|
-
element.style.padding = '1rem';
|
|
2561
|
-
element.style.borderRadius = '8px';
|
|
2562
|
-
element.style.transition = 'all 0.3s ease';
|
|
2563
|
-
|
|
2564
|
-
setTimeout(() => {
|
|
2565
|
-
element.style.background = '';
|
|
2566
|
-
element.style.padding = '';
|
|
2567
|
-
}, 2000);
|
|
2568
|
-
}
|
|
2569
|
-
}, 100);
|
|
2570
|
-
|
|
2571
|
-
return true;
|
|
2572
|
-
}
|
|
2573
|
-
}
|
|
2574
|
-
}
|
|
2575
|
-
|
|
2576
|
-
console.log(`Seção "${sectionTitle}" não encontrada`);
|
|
2577
|
-
return false;
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
// ADICIONE esta função para debug
|
|
2585
|
-
window.testConditional = function() {
|
|
2586
|
-
console.log('=== TESTE MANUAL ===');
|
|
2587
|
-
|
|
2588
|
-
// Listar todos os selects
|
|
2589
|
-
const selects = document.querySelectorAll('select');
|
|
2590
|
-
console.log(`Total de selects: ${selects.length}`);
|
|
2591
|
-
|
|
2592
|
-
selects.forEach((select, i) => {
|
|
2593
|
-
console.log(`Select ${i}:`, {
|
|
2594
|
-
id: select.id,
|
|
2595
|
-
name: select.name,
|
|
2596
|
-
fieldId: select.dataset.fieldId,
|
|
2597
|
-
classes: select.className
|
|
2598
|
-
});
|
|
2599
|
-
});
|
|
2600
|
-
|
|
2601
|
-
// Listar containers condicionais
|
|
2602
|
-
const containers = document.querySelectorAll('[data-parent-field]');
|
|
2603
|
-
console.log(`Containers condicionais: ${containers.length}`);
|
|
2604
|
-
|
|
2605
|
-
containers.forEach((container, i) => {
|
|
2606
|
-
console.log(`Container ${i}:`, {
|
|
2607
|
-
parentField: container.dataset.parentField,
|
|
2608
|
-
triggerValue: container.dataset.triggerValue,
|
|
2609
|
-
display: container.style.display
|
|
2610
|
-
});
|
|
2611
|
-
});
|
|
2612
|
-
};
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
1933
|
+
</script>
|
|
2616
1934
|
|
|
2617
1935
|
|
|
2618
|
-
|
|
1936
|
+
{% endblock %}
|
|
2619
1937
|
|
|
2620
1938
|
|
|
2621
|
-
{% endblock %}
|