wagtail-enap-designsystem 1.2.1.131__py3-none-any.whl → 1.2.1.133__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.
Potentially problematic release.
This version of wagtail-enap-designsystem might be problematic. Click here for more details.
- enap_designsystem/blocks/form.py +84 -50
- enap_designsystem/migrations/0406_alter_areaaluno_body_alter_cursoeadpage_curso_and_more.py +55023 -0
- enap_designsystem/migrations/0407_alter_formulariopage_form_steps.py +1277 -0
- enap_designsystem/migrations/0408_alter_areaaluno_body_alter_enapcomponentes_body_and_more.py +53961 -0
- enap_designsystem/migrations/0409_alter_areaaluno_body_alter_enapcomponentes_body_and_more.py +54062 -0
- enap_designsystem/migrations/0410_alter_formulariopage_form_steps.py +1278 -0
- enap_designsystem/migrations/0411_alter_formulariopage_form_steps.py +1277 -0
- enap_designsystem/settings.py +14 -1
- enap_designsystem/templates/enap_designsystem/form_templates/formulario_page.html +456 -109
- enap_designsystem/templates/enap_designsystem/includes/form_field.html +196 -443
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.133.dist-info}/METADATA +1 -1
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.133.dist-info}/RECORD +15 -9
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.133.dist-info}/WHEEL +0 -0
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.133.dist-info}/licenses/LICENSE +0 -0
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.133.dist-info}/top_level.txt +0 -0
|
@@ -421,10 +421,106 @@
|
|
|
421
421
|
{% include 'enap_designsystem/includes/form_field.html' with block=field_block %}
|
|
422
422
|
{% endfor %}
|
|
423
423
|
</div>
|
|
424
|
+
{% elif option_block.value.action == 'end_form' %}
|
|
425
|
+
<div class="end-form-message"
|
|
426
|
+
data-parent-field="{{ block.block_type }}_{{ block.id }}"
|
|
427
|
+
data-trigger-value="{{ option_block.value.value }}"
|
|
428
|
+
data-auto-submit="true"
|
|
429
|
+
style="display: none; margin-top: 1rem; padding: 1rem; border: 1px solid #f5c6cb; border-radius: 8px; background: #f8d7da; color: #721c24;">
|
|
430
|
+
<p>A ENAP AGRADECE SUA PARTICIPAÇÃO NESSA CHAMADA PÚBLICA SIMPLIFICADA...</p>
|
|
431
|
+
<div class="loading-spinner" style="text-align: center; margin-top: 1rem;">
|
|
432
|
+
<div style="display: inline-block; width: 20px; height: 20px; border: 3px solid #f3f3f3; border-top: 3px solid #721c24; border-radius: 50%; animation: spin 1s linear infinite;"></div>
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
424
435
|
{% endif %}
|
|
425
436
|
{% endfor %}
|
|
426
437
|
</div>
|
|
427
438
|
|
|
439
|
+
|
|
440
|
+
<script>
|
|
441
|
+
// JavaScript para campos condicionais com auto-submit
|
|
442
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
443
|
+
// Função para lidar com campos condicionais
|
|
444
|
+
function handleConditionalFields() {
|
|
445
|
+
const conditionalBlocks = document.querySelectorAll('[data-parent-field]');
|
|
446
|
+
|
|
447
|
+
conditionalBlocks.forEach(block => {
|
|
448
|
+
const parentFieldName = block.dataset.parentField;
|
|
449
|
+
const triggerValue = block.dataset.triggerValue;
|
|
450
|
+
const parentInputs = document.querySelectorAll(`[name="${parentFieldName}"]`);
|
|
451
|
+
|
|
452
|
+
if (parentInputs.length === 0) return;
|
|
453
|
+
|
|
454
|
+
function checkAndToggle() {
|
|
455
|
+
let shouldShow = false;
|
|
456
|
+
|
|
457
|
+
parentInputs.forEach(input => {
|
|
458
|
+
if (input.type === 'radio') {
|
|
459
|
+
if (input.checked && input.value === triggerValue) {
|
|
460
|
+
shouldShow = true;
|
|
461
|
+
}
|
|
462
|
+
} else if (input.type === 'select-one') {
|
|
463
|
+
if (input.value === triggerValue) {
|
|
464
|
+
shouldShow = true;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
if (shouldShow) {
|
|
470
|
+
block.style.display = 'block';
|
|
471
|
+
|
|
472
|
+
// Se tem auto-submit, finalizar formulário automaticamente
|
|
473
|
+
if (block.dataset.autoSubmit === 'true') {
|
|
474
|
+
setTimeout(() => {
|
|
475
|
+
// Submeter o formulário
|
|
476
|
+
const form = document.getElementById('wagtailForm');
|
|
477
|
+
if (form) {
|
|
478
|
+
// Adicionar um campo hidden para indicar finalização automática
|
|
479
|
+
const autoEndInput = document.createElement('input');
|
|
480
|
+
autoEndInput.type = 'hidden';
|
|
481
|
+
autoEndInput.name = 'auto_end_form';
|
|
482
|
+
autoEndInput.value = 'true';
|
|
483
|
+
form.appendChild(autoEndInput);
|
|
484
|
+
|
|
485
|
+
// Submeter
|
|
486
|
+
form.submit();
|
|
487
|
+
}
|
|
488
|
+
}, 2000); // Aguarda 2 segundos para mostrar a mensagem
|
|
489
|
+
}
|
|
490
|
+
} else {
|
|
491
|
+
block.style.display = 'none';
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Adicionar listeners
|
|
496
|
+
parentInputs.forEach(input => {
|
|
497
|
+
if (input.type === 'radio') {
|
|
498
|
+
input.addEventListener('change', checkAndToggle);
|
|
499
|
+
} else if (input.type === 'select-one') {
|
|
500
|
+
input.addEventListener('change', checkAndToggle);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// Verificar estado inicial
|
|
505
|
+
checkAndToggle();
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Inicializar
|
|
510
|
+
handleConditionalFields();
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// CSS para animação de loading
|
|
514
|
+
const style = document.createElement('style');
|
|
515
|
+
style.textContent = `
|
|
516
|
+
@keyframes spin {
|
|
517
|
+
0% { transform: rotate(0deg); }
|
|
518
|
+
100% { transform: rotate(360deg); }
|
|
519
|
+
}
|
|
520
|
+
`;
|
|
521
|
+
document.head.appendChild(style);
|
|
522
|
+
</script>
|
|
523
|
+
|
|
428
524
|
{% elif block.block_type == 'country_field' %}
|
|
429
525
|
<div class="form-group">
|
|
430
526
|
<label for="{{ block.block_type }}_{{ block.id }}">
|
|
@@ -729,214 +825,118 @@
|
|
|
729
825
|
{% endfor %}
|
|
730
826
|
</div>
|
|
731
827
|
|
|
732
|
-
<script>
|
|
733
|
-
// JavaScript específico para conditional_field_condicional
|
|
734
|
-
(function() {
|
|
735
|
-
console.log('🔧 Inicializando conditional_field_condicional para {{ block.block_type }}_{{ block.id }}');
|
|
736
|
-
|
|
737
|
-
function initConditionalField() {
|
|
738
|
-
const fieldId = '{{ block.block_type }}_{{ block.id }}';
|
|
739
|
-
const triggers = document.querySelectorAll(`[data-field-id="${fieldId}"].conditional-condicional-trigger`);
|
|
740
|
-
|
|
741
|
-
console.log(`🎯 Encontrados ${triggers.length} triggers para ${fieldId}`);
|
|
742
|
-
|
|
743
|
-
if (triggers.length === 0) {
|
|
744
|
-
console.warn(`⚠️ Nenhum trigger encontrado para ${fieldId}`);
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
triggers.forEach((trigger, index) => {
|
|
749
|
-
console.log(`🔗 Configurando trigger ${index + 1}:`, trigger.type, trigger.name);
|
|
750
|
-
|
|
751
|
-
trigger.addEventListener('change', function() {
|
|
752
|
-
console.log(`📝 Trigger mudou: ${this.value}`);
|
|
753
|
-
handleConditionalChange(fieldId, this.value);
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
// Verificar estado inicial
|
|
757
|
-
if (trigger.checked || (trigger.type === 'select-one' && trigger.value)) {
|
|
758
|
-
console.log(`🚀 Estado inicial detectado: ${trigger.value}`);
|
|
759
|
-
handleConditionalChange(fieldId, trigger.value);
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
function handleConditionalChange(fieldId, selectedValue) {
|
|
765
|
-
console.log(`🔄 Campo ${fieldId} mudou para: "${selectedValue}"`);
|
|
766
|
-
|
|
767
|
-
// Ocultar todos os campos condicionais deste campo
|
|
768
|
-
const allFields = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
769
|
-
console.log(`📦 Encontrados ${allFields.length} campos condicionais`);
|
|
770
|
-
|
|
771
|
-
allFields.forEach((field, index) => {
|
|
772
|
-
field.style.display = 'none';
|
|
773
|
-
console.log(`👁️ Ocultando campo ${index + 1}`);
|
|
774
|
-
|
|
775
|
-
// Limpar valores dos campos ocultos
|
|
776
|
-
const inputs = field.querySelectorAll('input, select, textarea');
|
|
777
|
-
inputs.forEach(input => {
|
|
778
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
779
|
-
input.checked = false;
|
|
780
|
-
} else {
|
|
781
|
-
input.value = '';
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// Disparar evento change para outros condicionais aninhados
|
|
785
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
// Mostrar campos para o valor selecionado
|
|
790
|
-
if (selectedValue) {
|
|
791
|
-
const targetField = document.querySelector(`[data-parent-field="${fieldId}"][data-trigger-value="${selectedValue}"]`);
|
|
792
|
-
if (targetField) {
|
|
793
|
-
targetField.style.display = 'block';
|
|
794
|
-
|
|
795
|
-
// Animação suave
|
|
796
|
-
targetField.style.opacity = '0';
|
|
797
|
-
targetField.style.transform = 'translateY(-10px)';
|
|
798
|
-
|
|
799
|
-
setTimeout(() => {
|
|
800
|
-
targetField.style.transition = 'all 0.3s ease';
|
|
801
|
-
targetField.style.opacity = '1';
|
|
802
|
-
targetField.style.transform = 'translateY(0)';
|
|
803
|
-
}, 10);
|
|
804
|
-
|
|
805
|
-
console.log(`✅ Campos mostrados para: "${selectedValue}"`);
|
|
806
|
-
|
|
807
|
-
// Scroll suave para os campos que apareceram
|
|
808
|
-
setTimeout(() => {
|
|
809
|
-
targetField.scrollIntoView({
|
|
810
|
-
behavior: 'smooth',
|
|
811
|
-
block: 'nearest'
|
|
812
|
-
});
|
|
813
|
-
}, 300);
|
|
814
|
-
} else {
|
|
815
|
-
console.warn(`⚠️ Nenhum campo condicional encontrado para valor: "${selectedValue}"`);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
// Inicializar quando DOM estiver pronto
|
|
821
|
-
if (document.readyState === 'loading') {
|
|
822
|
-
document.addEventListener('DOMContentLoaded', initConditionalField);
|
|
823
|
-
} else {
|
|
824
|
-
initConditionalField();
|
|
825
|
-
}
|
|
826
|
-
})();
|
|
827
|
-
</script>
|
|
828
828
|
|
|
829
829
|
<style>
|
|
830
|
-
/* Estilos específicos para conditional_field_condicional */
|
|
831
|
-
.conditional-field-condicional-group {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
.conditional-condicional-fields {
|
|
837
|
-
border-left: 4px solid var(--primary-color, #2A5E2C);
|
|
838
|
-
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
839
|
-
transition: all 0.3s ease;
|
|
840
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
|
841
|
-
border-radius: 8px;
|
|
842
|
-
overflow: hidden;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
.conditional-condicional-fields:hover {
|
|
846
|
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
.conditional-fields-header {
|
|
850
|
-
margin-bottom: 1rem;
|
|
851
|
-
padding-bottom: 0.5rem;
|
|
852
|
-
border-bottom: 1px solid #dee2e6;
|
|
853
|
-
background: rgba(42, 94, 44, 0.05);
|
|
854
|
-
margin: -1rem -1rem 1rem -1rem;
|
|
855
|
-
padding: 0.75rem 1rem;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
.conditional-fields-header .text-muted {
|
|
859
|
-
color: var(--primary-color, #2A5E2C) !important;
|
|
860
|
-
font-weight: 600;
|
|
861
|
-
font-size: 0.9rem;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
/* Melhorar a aparência dos campos aninhados */
|
|
865
|
-
.conditional-condicional-fields .form-group {
|
|
866
|
-
margin-bottom: 1.25rem;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
.conditional-condicional-fields .form-group:last-child {
|
|
870
|
-
margin-bottom: 0;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
.conditional-condicional-fields .form-control {
|
|
874
|
-
border-color: #d1d9e0;
|
|
875
|
-
background: white;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
.conditional-condicional-fields .form-control:focus {
|
|
879
|
-
border-color: var(--primary-color, #2A5E2C);
|
|
880
|
-
box-shadow: 0 0 0 2px rgba(42, 94, 44, 0.1);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/* Animações */
|
|
884
|
-
@keyframes slideInDown {
|
|
885
|
-
from {
|
|
886
|
-
opacity: 0;
|
|
887
|
-
transform: translateY(-15px);
|
|
888
|
-
}
|
|
889
|
-
to {
|
|
890
|
-
opacity: 1;
|
|
891
|
-
transform: translateY(0);
|
|
830
|
+
/* Estilos específicos para conditional_field_condicional */
|
|
831
|
+
.conditional-field-condicional-group {
|
|
832
|
+
position: relative;
|
|
833
|
+
margin-bottom: 1.5rem;
|
|
892
834
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
.conditional-condicional-fields.show {
|
|
896
|
-
animation: slideInDown 0.3s ease-out;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
/* Indicador visual para campos condicionais ativos */
|
|
900
|
-
.conditional-condicional-fields::before {
|
|
901
|
-
content: '';
|
|
902
|
-
position: absolute;
|
|
903
|
-
left: -4px;
|
|
904
|
-
top: 0;
|
|
905
|
-
bottom: 0;
|
|
906
|
-
width: 4px;
|
|
907
|
-
background: linear-gradient(to bottom, var(--primary-color, #2A5E2C), #4CAF50);
|
|
908
|
-
border-radius: 0 2px 2px 0;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
/* Responsivo */
|
|
912
|
-
@media (max-width: 768px) {
|
|
835
|
+
|
|
913
836
|
.conditional-condicional-fields {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
837
|
+
border-left: 4px solid var(--primary-color, #2A5E2C);
|
|
838
|
+
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
839
|
+
transition: all 0.3s ease;
|
|
840
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
|
841
|
+
border-radius: 8px;
|
|
842
|
+
overflow: hidden;
|
|
917
843
|
}
|
|
918
|
-
|
|
844
|
+
|
|
845
|
+
.conditional-condicional-fields:hover {
|
|
846
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
847
|
+
}
|
|
848
|
+
|
|
919
849
|
.conditional-fields-header {
|
|
920
|
-
margin:
|
|
921
|
-
padding: 0.
|
|
850
|
+
margin-bottom: 1rem;
|
|
851
|
+
padding-bottom: 0.5rem;
|
|
852
|
+
border-bottom: 1px solid #dee2e6;
|
|
853
|
+
background: rgba(42, 94, 44, 0.05);
|
|
854
|
+
margin: -1rem -1rem 1rem -1rem;
|
|
855
|
+
padding: 0.75rem 1rem;
|
|
922
856
|
}
|
|
923
|
-
|
|
857
|
+
|
|
924
858
|
.conditional-fields-header .text-muted {
|
|
925
|
-
|
|
859
|
+
color: var(--primary-color, #2A5E2C) !important;
|
|
860
|
+
font-weight: 600;
|
|
861
|
+
font-size: 0.9rem;
|
|
926
862
|
}
|
|
927
|
-
}
|
|
928
863
|
|
|
929
|
-
|
|
930
|
-
.conditional-condicional-fields {
|
|
931
|
-
|
|
932
|
-
border-left-width: 2px;
|
|
864
|
+
/* Melhorar a aparência dos campos aninhados */
|
|
865
|
+
.conditional-condicional-fields .form-group {
|
|
866
|
+
margin-bottom: 1.25rem;
|
|
933
867
|
}
|
|
934
|
-
|
|
935
|
-
.conditional-fields-
|
|
936
|
-
margin:
|
|
937
|
-
|
|
868
|
+
|
|
869
|
+
.conditional-condicional-fields .form-group:last-child {
|
|
870
|
+
margin-bottom: 0;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.conditional-condicional-fields .form-control {
|
|
874
|
+
border-color: #d1d9e0;
|
|
875
|
+
background: white;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.conditional-condicional-fields .form-control:focus {
|
|
879
|
+
border-color: var(--primary-color, #2A5E2C);
|
|
880
|
+
box-shadow: 0 0 0 2px rgba(42, 94, 44, 0.1);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/* Animações */
|
|
884
|
+
@keyframes slideInDown {
|
|
885
|
+
from {
|
|
886
|
+
opacity: 0;
|
|
887
|
+
transform: translateY(-15px);
|
|
888
|
+
}
|
|
889
|
+
to {
|
|
890
|
+
opacity: 1;
|
|
891
|
+
transform: translateY(0);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
.conditional-condicional-fields.show {
|
|
896
|
+
animation: slideInDown 0.3s ease-out;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/* Indicador visual para campos condicionais ativos */
|
|
900
|
+
.conditional-condicional-fields::before {
|
|
901
|
+
content: '';
|
|
902
|
+
position: absolute;
|
|
903
|
+
left: -4px;
|
|
904
|
+
top: 0;
|
|
905
|
+
bottom: 0;
|
|
906
|
+
width: 4px;
|
|
907
|
+
background: linear-gradient(to bottom, var(--primary-color, #2A5E2C), #4CAF50);
|
|
908
|
+
border-radius: 0 2px 2px 0;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/* Responsivo */
|
|
912
|
+
@media (max-width: 768px) {
|
|
913
|
+
.conditional-condicional-fields {
|
|
914
|
+
padding: 0.75rem;
|
|
915
|
+
margin-top: 0.75rem;
|
|
916
|
+
border-left-width: 3px;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.conditional-fields-header {
|
|
920
|
+
margin: -0.75rem -0.75rem 0.75rem -0.75rem;
|
|
921
|
+
padding: 0.6rem 0.75rem;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
.conditional-fields-header .text-muted {
|
|
925
|
+
font-size: 0.85rem;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
@media (max-width: 480px) {
|
|
930
|
+
.conditional-condicional-fields {
|
|
931
|
+
padding: 0.6rem;
|
|
932
|
+
border-left-width: 2px;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
.conditional-fields-header {
|
|
936
|
+
margin: -0.6rem -0.6rem 0.6rem -0.6rem;
|
|
937
|
+
padding: 0.5rem 0.6rem;
|
|
938
|
+
}
|
|
938
939
|
}
|
|
939
|
-
}
|
|
940
940
|
</style>
|
|
941
941
|
|
|
942
942
|
|
|
@@ -1639,253 +1639,6 @@
|
|
|
1639
1639
|
});
|
|
1640
1640
|
|
|
1641
1641
|
|
|
1642
|
-
// ADICIONE ESTE CÓDIGO AO FINAL DO SEU <script> NO form_field.html
|
|
1643
|
-
|
|
1644
|
-
// ========================================
|
|
1645
|
-
// SISTEMA MULTI-REDIRECIONAMENTO
|
|
1646
|
-
// ========================================
|
|
1647
|
-
|
|
1648
|
-
// Variáveis de controle
|
|
1649
|
-
let multiRedirectFields = new Map();
|
|
1650
|
-
let pendingActions = new Map();
|
|
1651
|
-
|
|
1652
|
-
// INICIALIZAÇÃO DOS CAMPOS MULTI-REDIRECT
|
|
1653
|
-
function initializeMultiRedirectFields() {
|
|
1654
|
-
console.log('🔀 Inicializando multi-redirecionamento...');
|
|
1655
|
-
|
|
1656
|
-
const groups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
1657
|
-
console.log(`🔍 Encontrados ${groups.length} grupos multi-redirect`);
|
|
1658
|
-
|
|
1659
|
-
groups.forEach(group => {
|
|
1660
|
-
try {
|
|
1661
|
-
const configData = group.getAttribute('data-field-config');
|
|
1662
|
-
if (!configData) {
|
|
1663
|
-
console.log('⚠️ Configuração não encontrada para grupo:', group);
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
const config = JSON.parse(configData);
|
|
1668
|
-
multiRedirectFields.set(config.fieldId, config);
|
|
1669
|
-
|
|
1670
|
-
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
1671
|
-
inputs.forEach(input => {
|
|
1672
|
-
input.addEventListener('change', function() {
|
|
1673
|
-
handleMultiRedirectChange(config, this);
|
|
1674
|
-
});
|
|
1675
|
-
});
|
|
1676
|
-
|
|
1677
|
-
console.log(`✅ Campo configurado: ${config.fieldId} (${config.fieldType})`);
|
|
1678
|
-
|
|
1679
|
-
} catch (error) {
|
|
1680
|
-
console.error('❌ Erro configuração multi-redirect:', error, group);
|
|
1681
|
-
}
|
|
1682
|
-
});
|
|
1683
|
-
|
|
1684
|
-
console.log(`🔀 ${multiRedirectFields.size} campos multi-redirect ativos`);
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
// GERENCIAR MUDANÇA NO CAMPO
|
|
1688
|
-
function handleMultiRedirectChange(config, input) {
|
|
1689
|
-
const value = input.value;
|
|
1690
|
-
const isSelected = input.checked || (input.tagName === 'SELECT' && value);
|
|
1691
|
-
|
|
1692
|
-
console.log(`🎯 Campo ${config.fieldId}: valor="${value}", selecionado=${isSelected}`);
|
|
1693
|
-
|
|
1694
|
-
// Para radio e select, sempre processar se tem valor
|
|
1695
|
-
// Para checkbox, só processar se estiver marcado
|
|
1696
|
-
const shouldProcess = (config.fieldType === 'checkbox') ? input.checked : Boolean(value);
|
|
1697
|
-
|
|
1698
|
-
if (!shouldProcess) {
|
|
1699
|
-
hideAllMessages(config.fieldId);
|
|
1700
|
-
hideAllConditionalFields(config.fieldId);
|
|
1701
|
-
return;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
const option = config.options.find(opt => opt.value === value);
|
|
1705
|
-
if (!option) {
|
|
1706
|
-
console.log(`⚠️ Opção não encontrada para valor: ${value}`);
|
|
1707
|
-
return;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
console.log(`🚀 Executando ação: ${option.action} para "${option.value}"`);
|
|
1711
|
-
|
|
1712
|
-
// Limpar ações/mensagens anteriores
|
|
1713
|
-
clearPreviousActions(config.fieldId);
|
|
1714
|
-
|
|
1715
|
-
// Mostrar mensagem se configurada
|
|
1716
|
-
if (option.message) {
|
|
1717
|
-
showMultiRedirectMessage(config.fieldId, option);
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
// Processar ação
|
|
1721
|
-
const delay = (option.delay || 1) * 1000;
|
|
1722
|
-
|
|
1723
|
-
switch (option.action) {
|
|
1724
|
-
case 'continue':
|
|
1725
|
-
console.log('➡️ Continuando normalmente');
|
|
1726
|
-
break;
|
|
1727
|
-
|
|
1728
|
-
case 'next_step':
|
|
1729
|
-
console.log('⏩ Programando próxima etapa');
|
|
1730
|
-
setTimeout(() => {
|
|
1731
|
-
if (typeof nextStep === 'function') {
|
|
1732
|
-
nextStep();
|
|
1733
|
-
} else {
|
|
1734
|
-
console.log('⚠️ Função nextStep não encontrada');
|
|
1735
|
-
}
|
|
1736
|
-
}, delay);
|
|
1737
|
-
break;
|
|
1738
|
-
|
|
1739
|
-
case 'specific_section':
|
|
1740
|
-
if (option.targetSection) {
|
|
1741
|
-
console.log(`🎯 Programando redirecionamento para: ${option.targetSection}`);
|
|
1742
|
-
setTimeout(() => {
|
|
1743
|
-
if (typeof redirectToSpecificSection === 'function') {
|
|
1744
|
-
redirectToSpecificSection(option.targetSection);
|
|
1745
|
-
} else {
|
|
1746
|
-
console.log('⚠️ Função redirectToSpecificSection não encontrada');
|
|
1747
|
-
}
|
|
1748
|
-
}, delay);
|
|
1749
|
-
}
|
|
1750
|
-
break;
|
|
1751
|
-
|
|
1752
|
-
case 'skip_to_end':
|
|
1753
|
-
console.log('⏭️ Programando finalização');
|
|
1754
|
-
setTimeout(() => {
|
|
1755
|
-
skipToFinalStep();
|
|
1756
|
-
}, delay);
|
|
1757
|
-
break;
|
|
1758
|
-
|
|
1759
|
-
case 'show_fields':
|
|
1760
|
-
console.log(`👁️ Mostrando campos condicionais para: ${value}`);
|
|
1761
|
-
showConditionalFields(config.fieldId, value);
|
|
1762
|
-
break;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
// MOSTRAR MENSAGEM DE REDIRECIONAMENTO
|
|
1767
|
-
function showMultiRedirectMessage(fieldId, option) {
|
|
1768
|
-
const blockId = fieldId.split('_').pop();
|
|
1769
|
-
const optionIndex = multiRedirectFields.get(fieldId).options.findIndex(opt => opt.value === option.value);
|
|
1770
|
-
const messageEl = document.getElementById(`redirect_message_${blockId}_${optionIndex}`);
|
|
1771
|
-
|
|
1772
|
-
if (messageEl) {
|
|
1773
|
-
messageEl.style.display = 'block';
|
|
1774
|
-
console.log(`💬 Mensagem mostrada para opção: ${option.value}`);
|
|
1775
|
-
|
|
1776
|
-
setTimeout(() => {
|
|
1777
|
-
messageEl.scrollIntoView({
|
|
1778
|
-
behavior: 'smooth',
|
|
1779
|
-
block: 'center'
|
|
1780
|
-
});
|
|
1781
|
-
}, 100);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
// MOSTRAR CAMPOS CONDICIONAIS
|
|
1786
|
-
function showConditionalFields(fieldId, value) {
|
|
1787
|
-
// Primeiro esconder todos os campos condicionais deste campo
|
|
1788
|
-
hideAllConditionalFields(fieldId);
|
|
1789
|
-
|
|
1790
|
-
// Mostrar apenas o campo correspondente ao valor selecionado
|
|
1791
|
-
const conditionalField = document.querySelector(
|
|
1792
|
-
`[data-parent-field="${fieldId}"][data-option-value="${value}"]`
|
|
1793
|
-
);
|
|
1794
|
-
|
|
1795
|
-
if (conditionalField) {
|
|
1796
|
-
conditionalField.style.display = 'block';
|
|
1797
|
-
console.log(`👁️ Campos condicionais mostrados para: ${value}`);
|
|
1798
|
-
|
|
1799
|
-
setTimeout(() => {
|
|
1800
|
-
conditionalField.scrollIntoView({
|
|
1801
|
-
behavior: 'smooth',
|
|
1802
|
-
block: 'center'
|
|
1803
|
-
});
|
|
1804
|
-
}, 200);
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
// OCULTAR TODAS AS MENSAGENS
|
|
1809
|
-
function hideAllMessages(fieldId) {
|
|
1810
|
-
const blockId = fieldId.split('_').pop();
|
|
1811
|
-
const messages = document.querySelectorAll(`[id^="redirect_message_${blockId}_"]`);
|
|
1812
|
-
|
|
1813
|
-
messages.forEach(message => {
|
|
1814
|
-
message.style.display = 'none';
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
// OCULTAR TODOS OS CAMPOS CONDICIONAIS
|
|
1819
|
-
function hideAllConditionalFields(fieldId) {
|
|
1820
|
-
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
1821
|
-
|
|
1822
|
-
conditionalFields.forEach(field => {
|
|
1823
|
-
field.style.display = 'none';
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
// LIMPAR AÇÕES ANTERIORES
|
|
1828
|
-
function clearPreviousActions(fieldId) {
|
|
1829
|
-
pendingActions.delete(fieldId);
|
|
1830
|
-
hideAllMessages(fieldId);
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
// PULAR PARA ETAPA FINAL
|
|
1834
|
-
function skipToFinalStep() {
|
|
1835
|
-
console.log(`⏭️ Executando pulo para final`);
|
|
1836
|
-
|
|
1837
|
-
// Adicionar campo hidden indicando redirecionamento
|
|
1838
|
-
const form = document.getElementById('wagtailForm');
|
|
1839
|
-
if (form) {
|
|
1840
|
-
let skipField = form.querySelector('input[name="form_redirected"]');
|
|
1841
|
-
if (!skipField) {
|
|
1842
|
-
skipField = document.createElement('input');
|
|
1843
|
-
skipField.type = 'hidden';
|
|
1844
|
-
skipField.name = 'form_redirected';
|
|
1845
|
-
form.appendChild(skipField);
|
|
1846
|
-
}
|
|
1847
|
-
skipField.value = 'true';
|
|
1848
|
-
|
|
1849
|
-
console.log('📨 Submetendo formulário...');
|
|
1850
|
-
form.submit();
|
|
1851
|
-
} else {
|
|
1852
|
-
console.log('⚠️ Formulário não encontrado');
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
// FUNÇÃO PARA REDIRECIONAR PARA SEÇÃO ESPECÍFICA (caso não exista)
|
|
1857
|
-
if (typeof redirectToSpecificSection === 'undefined') {
|
|
1858
|
-
function redirectToSpecificSection(sectionTitle) {
|
|
1859
|
-
console.log(`🎯 Procurando seção: "${sectionTitle}"`);
|
|
1860
|
-
|
|
1861
|
-
// Procurar divisores com título correspondente
|
|
1862
|
-
const dividers = document.querySelectorAll('.divider-title');
|
|
1863
|
-
|
|
1864
|
-
for (const divider of dividers) {
|
|
1865
|
-
const dividerTitle = divider.textContent?.trim() || '';
|
|
1866
|
-
|
|
1867
|
-
if (dividerTitle.toLowerCase().includes(sectionTitle.toLowerCase()) ||
|
|
1868
|
-
sectionTitle.toLowerCase().includes(dividerTitle.toLowerCase())) {
|
|
1869
|
-
|
|
1870
|
-
console.log(`✅ Seção encontrada: "${dividerTitle}"`);
|
|
1871
|
-
|
|
1872
|
-
// Scroll para o divisor
|
|
1873
|
-
setTimeout(() => {
|
|
1874
|
-
divider.scrollIntoView({
|
|
1875
|
-
behavior: 'smooth',
|
|
1876
|
-
block: 'center'
|
|
1877
|
-
});
|
|
1878
|
-
}, 100);
|
|
1879
|
-
|
|
1880
|
-
return true;
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
console.log(`❌ Seção "${sectionTitle}" não encontrada`);
|
|
1885
|
-
return false;
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
1642
|
// INICIALIZAÇÃO QUANDO DOM CARREGAR
|
|
1890
1643
|
document.addEventListener('DOMContentLoaded', function() {
|
|
1891
1644
|
// Aguardar um pouco para garantir que tudo carregou
|