wagtail-enap-designsystem 1.2.1.127__py3-none-any.whl → 1.2.1.128__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/form.py +296 -5
- enap_designsystem/migrations/0390_alter_areaaluno_body_alter_cursoeadpage_curso_and_more.py +53322 -0
- enap_designsystem/migrations/0391_alter_formulariopage_form_steps.py +1240 -0
- enap_designsystem/migrations/0392_alter_formulariopage_form_steps.py +1237 -0
- enap_designsystem/migrations/0393_alter_formulariopage_form_steps.py +1264 -0
- enap_designsystem/static/enap_designsystem/blocks/card_courses.css +2 -1
- enap_designsystem/static/enap_designsystem/blocks/suap/suap_courses_block.css +28 -6
- enap_designsystem/templates/enap_designsystem/blocks/clientes_block.html +1 -1
- enap_designsystem/templates/enap_designsystem/blocks/suap/suap_courses_block.html +9 -2
- enap_designsystem/templates/enap_designsystem/form_templates/formulario_page.html +631 -934
- enap_designsystem/templates/enap_designsystem/includes/form_field.html +798 -382
- {wagtail_enap_designsystem-1.2.1.127.dist-info → wagtail_enap_designsystem-1.2.1.128.dist-info}/METADATA +1 -1
- {wagtail_enap_designsystem-1.2.1.127.dist-info → wagtail_enap_designsystem-1.2.1.128.dist-info}/RECORD +16 -12
- {wagtail_enap_designsystem-1.2.1.127.dist-info → wagtail_enap_designsystem-1.2.1.128.dist-info}/WHEEL +0 -0
- {wagtail_enap_designsystem-1.2.1.127.dist-info → wagtail_enap_designsystem-1.2.1.128.dist-info}/licenses/LICENSE +0 -0
- {wagtail_enap_designsystem-1.2.1.127.dist-info → wagtail_enap_designsystem-1.2.1.128.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,55 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!-- enap_designsystem/includes/form_field.html -->
|
|
2
2
|
{% load wagtailcore_tags %}
|
|
3
3
|
{% load wagtailimages_tags %}
|
|
4
4
|
<style>
|
|
5
|
+
.conditional-field-condicional-group {
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.conditional-condicional-fields {
|
|
10
|
+
border-left: 3px solid var(--primary-color);
|
|
11
|
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
|
12
|
+
transition: all 0.3s ease;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.conditional-condicional-fields:hover {
|
|
16
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.conditional-fields-header {
|
|
20
|
+
margin-bottom: 1rem;
|
|
21
|
+
padding-bottom: 0.5rem;
|
|
22
|
+
border-bottom: 1px solid #dee2e6;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.conditional-fields-header .text-muted {
|
|
26
|
+
font-style: italic;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Animações específicas para campos condicionais */
|
|
30
|
+
.conditional-condicional-fields.show {
|
|
31
|
+
animation: slideInDown 0.3s ease-out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@keyframes slideInDown {
|
|
35
|
+
from {
|
|
36
|
+
opacity: 0;
|
|
37
|
+
transform: translateY(-20px);
|
|
38
|
+
}
|
|
39
|
+
to {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
transform: translateY(0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Responsividade para campos condicionais */
|
|
46
|
+
@media (max-width: 768px) {
|
|
47
|
+
.conditional-condicional-fields {
|
|
48
|
+
padding: 0.75rem;
|
|
49
|
+
margin-top: 0.75rem;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
5
53
|
.conditional-fields {
|
|
6
54
|
border-left: 4px solid var(--primary-color);
|
|
7
55
|
background: #f8f9fa;
|
|
@@ -612,6 +660,288 @@
|
|
|
612
660
|
>
|
|
613
661
|
</div>
|
|
614
662
|
|
|
663
|
+
{% elif block.block_type == 'conditional_field_condicional' %}
|
|
664
|
+
<div class="form-group conditional-field-condicional-group">
|
|
665
|
+
<label for="{{ block.block_type }}_{{ block.id }}">
|
|
666
|
+
{{ block.value.label_con }}
|
|
667
|
+
{% if block.value.required_con %}<span class="required">*</span>{% endif %}
|
|
668
|
+
</label>
|
|
669
|
+
{% if block.value.help_text_con %}
|
|
670
|
+
<div class="help-text">{{ block.value.help_text_con }}</div>
|
|
671
|
+
{% endif %}
|
|
672
|
+
|
|
673
|
+
{% if block.value.field_type_con == 'dropdown' %}
|
|
674
|
+
<select
|
|
675
|
+
id="{{ block.block_type }}_{{ block.id }}"
|
|
676
|
+
name="{{ block.block_type }}_{{ block.id }}"
|
|
677
|
+
class="form-control conditional-condicional-trigger"
|
|
678
|
+
{% if block.value.required_con %}required{% endif %}
|
|
679
|
+
data-field-id="{{ block.block_type }}_{{ block.id }}"
|
|
680
|
+
>
|
|
681
|
+
<option value="">Selecione uma opção...</option>
|
|
682
|
+
{% for option_block in block.value.conditional_options_con %}
|
|
683
|
+
<option value="{{ option_block.value.value_con }}"
|
|
684
|
+
{% if form_data == option_block.value.value_con %}selected{% endif %}>
|
|
685
|
+
{{ option_block.value.value_con }}
|
|
686
|
+
</option>
|
|
687
|
+
{% endfor %}
|
|
688
|
+
</select>
|
|
689
|
+
{% else %}
|
|
690
|
+
<!-- Radio buttons -->
|
|
691
|
+
<div class="radio-group">
|
|
692
|
+
{% for option_block in block.value.conditional_options_con %}
|
|
693
|
+
<div class="radio-item">
|
|
694
|
+
<input
|
|
695
|
+
type="radio"
|
|
696
|
+
id="{{ block.block_type }}_{{ block.id }}_{{ forloop.counter }}"
|
|
697
|
+
name="{{ block.block_type }}_{{ block.id }}"
|
|
698
|
+
value="{{ option_block.value.value_con }}"
|
|
699
|
+
class="conditional-condicional-trigger"
|
|
700
|
+
data-field-id="{{ block.block_type }}_{{ block.id }}"
|
|
701
|
+
{% if form_data == option_block.value.value_con %}checked{% endif %}
|
|
702
|
+
{% if block.value.required_con %}required{% endif %}
|
|
703
|
+
>
|
|
704
|
+
<label for="{{ block.block_type }}_{{ block.id }}_{{ forloop.counter }}">
|
|
705
|
+
{{ option_block.value.value_con }}
|
|
706
|
+
</label>
|
|
707
|
+
</div>
|
|
708
|
+
{% endfor %}
|
|
709
|
+
</div>
|
|
710
|
+
{% endif %}
|
|
711
|
+
|
|
712
|
+
<!-- Campos condicionais -->
|
|
713
|
+
{% for option_block in block.value.conditional_options_con %}
|
|
714
|
+
{% if option_block.value.action_con == 'show_fields_con' %}
|
|
715
|
+
<div class="conditional-condicional-fields"
|
|
716
|
+
data-parent-field="{{ block.block_type }}_{{ block.id }}"
|
|
717
|
+
data-trigger-value="{{ option_block.value.value_con }}"
|
|
718
|
+
style="display: none; margin-top: 1rem; padding: 1rem; border: 1px solid #e1e5e9; border-radius: 8px; background: #f8f9fa;">
|
|
719
|
+
|
|
720
|
+
<div class="conditional-fields-header">
|
|
721
|
+
|
|
722
|
+
</div>
|
|
723
|
+
|
|
724
|
+
{% for field_block in option_block.value.fields_to_show_con %}
|
|
725
|
+
{% include 'enap_designsystem/includes/form_field.html' with block=field_block %}
|
|
726
|
+
{% endfor %}
|
|
727
|
+
</div>
|
|
728
|
+
{% endif %}
|
|
729
|
+
{% endfor %}
|
|
730
|
+
</div>
|
|
731
|
+
|
|
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
|
+
|
|
829
|
+
<style>
|
|
830
|
+
/* Estilos específicos para conditional_field_condicional */
|
|
831
|
+
.conditional-field-condicional-group {
|
|
832
|
+
position: relative;
|
|
833
|
+
margin-bottom: 1.5rem;
|
|
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);
|
|
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
|
+
}
|
|
939
|
+
}
|
|
940
|
+
</style>
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
615
945
|
{% elif block.block_type == 'checkbox_field' %}
|
|
616
946
|
<div class="form-group">
|
|
617
947
|
<label>{{ block.value.label }}</label>
|
|
@@ -1000,6 +1330,90 @@
|
|
|
1000
1330
|
{% endif %}
|
|
1001
1331
|
</div>
|
|
1002
1332
|
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
{% elif block.block_type == 'section_divider' %}
|
|
1336
|
+
<div class="section-divider"
|
|
1337
|
+
data-section-name="{{ block.value.section_name }}"
|
|
1338
|
+
data-block-id="{{ block.id }}"
|
|
1339
|
+
{% if block.value.is_hidden_by_default %}style="display: none;"{% endif %}>
|
|
1340
|
+
|
|
1341
|
+
<div class="divider-header">
|
|
1342
|
+
<h2 class="section-title">{{ block.value.title }}</h2>
|
|
1343
|
+
{% if block.value.subtitle %}
|
|
1344
|
+
<p class="section-subtitle">{{ block.value.subtitle }}</p>
|
|
1345
|
+
{% endif %}
|
|
1346
|
+
</div>
|
|
1347
|
+
<hr class="section-line">
|
|
1348
|
+
</div>
|
|
1349
|
+
|
|
1350
|
+
{% elif block.block_type == 'smart_navigation_field' %}
|
|
1351
|
+
<!-- CAMPO COM NAVEGAÇÃO INTELIGENTE -->
|
|
1352
|
+
<div class="form-group smart-navigation-group"
|
|
1353
|
+
data-field-type="smart_navigation_field"
|
|
1354
|
+
data-field-id="smart_navigation_field_{{ block.id }}">
|
|
1355
|
+
|
|
1356
|
+
<label>
|
|
1357
|
+
{{ block.value.label }}
|
|
1358
|
+
{% if block.value.required %}<span class="required">*</span>{% endif %}
|
|
1359
|
+
</label>
|
|
1360
|
+
|
|
1361
|
+
{% if block.value.help_text %}
|
|
1362
|
+
<div class="help-text">{{ block.value.help_text }}</div>
|
|
1363
|
+
{% endif %}
|
|
1364
|
+
|
|
1365
|
+
{% if block.value.field_type == 'radio' %}
|
|
1366
|
+
<!-- Radio buttons -->
|
|
1367
|
+
<div class="radio-group">
|
|
1368
|
+
{% for option in block.value.navigation_options %}
|
|
1369
|
+
<div class="radio-item">
|
|
1370
|
+
<input
|
|
1371
|
+
type="radio"
|
|
1372
|
+
name="smart_navigation_field_{{ block.id }}"
|
|
1373
|
+
id="smart_nav_{{ block.id }}_{{ forloop.counter }}"
|
|
1374
|
+
value="{{ option.value.value }}"
|
|
1375
|
+
class="smart-navigation-trigger"
|
|
1376
|
+
{% if block.value.required %}required{% endif %}>
|
|
1377
|
+
<label for="smart_nav_{{ block.id }}_{{ forloop.counter }}">
|
|
1378
|
+
{{ option.value.value }}
|
|
1379
|
+
</label>
|
|
1380
|
+
</div>
|
|
1381
|
+
{% endfor %}
|
|
1382
|
+
</div>
|
|
1383
|
+
|
|
1384
|
+
{% elif block.value.field_type == 'dropdown' %}
|
|
1385
|
+
<!-- Dropdown -->
|
|
1386
|
+
<select
|
|
1387
|
+
class="form-control smart-navigation-trigger"
|
|
1388
|
+
name="smart_navigation_field_{{ block.id }}"
|
|
1389
|
+
id="smart_navigation_field_{{ block.id }}"
|
|
1390
|
+
{% if block.value.required %}required{% endif %}>
|
|
1391
|
+
<option value="">Selecione uma opção...</option>
|
|
1392
|
+
{% for option in block.value.navigation_options %}
|
|
1393
|
+
<option value="{{ option.value.value }}">
|
|
1394
|
+
{{ option.value.value }}
|
|
1395
|
+
</option>
|
|
1396
|
+
{% endfor %}
|
|
1397
|
+
</select>
|
|
1398
|
+
|
|
1399
|
+
{% elif block.value.field_type == 'checkbox' %}
|
|
1400
|
+
<!-- Checkbox único -->
|
|
1401
|
+
{% for option in block.value.navigation_options %}
|
|
1402
|
+
<div class="checkbox-item">
|
|
1403
|
+
<input
|
|
1404
|
+
type="checkbox"
|
|
1405
|
+
name="smart_navigation_field_{{ block.id }}"
|
|
1406
|
+
id="smart_nav_{{ block.id }}_{{ forloop.counter }}"
|
|
1407
|
+
value="{{ option.value.value }}"
|
|
1408
|
+
class="smart-navigation-trigger"
|
|
1409
|
+
{% if block.value.required %}required{% endif %}>
|
|
1410
|
+
<label for="smart_nav_{{ block.id }}_{{ forloop.counter }}">
|
|
1411
|
+
{{ option.value.value }}
|
|
1412
|
+
</label>
|
|
1413
|
+
</div>
|
|
1414
|
+
{% endfor %}
|
|
1415
|
+
{% endif %}
|
|
1416
|
+
</div>
|
|
1003
1417
|
|
|
1004
1418
|
|
|
1005
1419
|
{% endif %}
|
|
@@ -1129,445 +1543,447 @@
|
|
|
1129
1543
|
e.currentTarget.style.background = '#f8f9fa';
|
|
1130
1544
|
}
|
|
1131
1545
|
|
|
1132
|
-
// Atualizar texto de rating
|
|
1133
|
-
document.addEventListener('click', function(e) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1546
|
+
// Atualizar texto de rating
|
|
1547
|
+
document.addEventListener('click', function(e) {
|
|
1548
|
+
if (e.target.classList.contains('star')) {
|
|
1549
|
+
const ratingGroup = e.target.parentNode;
|
|
1550
|
+
const value = parseInt(e.target.dataset.value);
|
|
1551
|
+
const maxRating = ratingGroup.querySelectorAll('.star').length;
|
|
1552
|
+
const ratingText = ratingGroup.querySelector('.rating-text');
|
|
1553
|
+
|
|
1554
|
+
if (ratingText) {
|
|
1555
|
+
ratingText.textContent = `${value} de ${maxRating} estrelas`;
|
|
1556
|
+
}
|
|
1142
1557
|
}
|
|
1143
|
-
}
|
|
1144
|
-
});
|
|
1558
|
+
});
|
|
1145
1559
|
|
|
1146
1560
|
|
|
1147
1561
|
|
|
1148
|
-
// JavaScript para campos condicionais
|
|
1149
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1562
|
+
// JavaScript para campos condicionais
|
|
1563
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1564
|
+
// Encontrar todos os campos condicionais
|
|
1565
|
+
const conditionalTriggers = document.querySelectorAll('.conditional-trigger');
|
|
1566
|
+
|
|
1567
|
+
conditionalTriggers.forEach(trigger => {
|
|
1568
|
+
// Adicionar listener de mudança
|
|
1569
|
+
trigger.addEventListener('change', function() {
|
|
1570
|
+
handleConditionalField(this);
|
|
1571
|
+
});
|
|
1572
|
+
|
|
1573
|
+
// Processar estado inicial se já tem valor
|
|
1574
|
+
if (trigger.value) {
|
|
1575
|
+
handleConditionalField(trigger);
|
|
1576
|
+
}
|
|
1157
1577
|
});
|
|
1578
|
+
|
|
1579
|
+
// Adicione esta função após validateCPF no template
|
|
1580
|
+
|
|
1581
|
+
function validateCNPJ(cnpj) {
|
|
1582
|
+
const digits = cnpj.replace(/[^0-9]/g, '');
|
|
1583
|
+
return digits.length === 14;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// E adicione esta validação no método validateCurrentStep, após a validação do CPF:
|
|
1587
|
+
|
|
1588
|
+
if (input.classList.contains('cnpj-field') && input.value) {
|
|
1589
|
+
if (!validateCNPJ(input.value)) {
|
|
1590
|
+
showFieldError(input, 'CNPJ deve ter 14 dígitos');
|
|
1591
|
+
isValid = false;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1158
1594
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1595
|
+
function handleConditionalField(triggerElement) {
|
|
1596
|
+
const fieldId = triggerElement.dataset.fieldId;
|
|
1597
|
+
const selectedValue = triggerElement.value;
|
|
1598
|
+
|
|
1599
|
+
// Encontrar todos os campos condicionais relacionados
|
|
1600
|
+
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
1601
|
+
|
|
1602
|
+
conditionalFields.forEach(fieldContainer => {
|
|
1603
|
+
const triggerValue = fieldContainer.dataset.triggerValue;
|
|
1604
|
+
|
|
1605
|
+
if (selectedValue === triggerValue) {
|
|
1606
|
+
// Mostrar campos
|
|
1607
|
+
fieldContainer.style.display = 'block';
|
|
1608
|
+
|
|
1609
|
+
// Ativar validação dos campos filhos
|
|
1610
|
+
const inputs = fieldContainer.querySelectorAll('input, select, textarea');
|
|
1611
|
+
inputs.forEach(input => {
|
|
1612
|
+
if (input.dataset.originalRequired !== undefined) {
|
|
1613
|
+
input.required = input.dataset.originalRequired === 'true';
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
} else {
|
|
1617
|
+
// Esconder campos
|
|
1618
|
+
fieldContainer.style.display = 'none';
|
|
1619
|
+
|
|
1620
|
+
// Desativar validação e limpar valores
|
|
1621
|
+
const inputs = fieldContainer.querySelectorAll('input, select, textarea');
|
|
1622
|
+
inputs.forEach(input => {
|
|
1623
|
+
// Salvar estado original do required
|
|
1624
|
+
if (input.dataset.originalRequired === undefined) {
|
|
1625
|
+
input.dataset.originalRequired = input.required.toString();
|
|
1626
|
+
}
|
|
1627
|
+
input.required = false;
|
|
1628
|
+
|
|
1629
|
+
// Limpar valores
|
|
1630
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
1631
|
+
input.checked = false;
|
|
1632
|
+
} else {
|
|
1633
|
+
input.value = '';
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1162
1638
|
}
|
|
1163
1639
|
});
|
|
1164
1640
|
|
|
1165
|
-
// Adicione esta função após validateCPF no template
|
|
1166
1641
|
|
|
1167
|
-
|
|
1168
|
-
const digits = cnpj.replace(/[^0-9]/g, '');
|
|
1169
|
-
return digits.length === 14;
|
|
1170
|
-
}
|
|
1642
|
+
// ADICIONE ESTE CÓDIGO AO FINAL DO SEU <script> NO form_field.html
|
|
1171
1643
|
|
|
1172
|
-
//
|
|
1644
|
+
// ========================================
|
|
1645
|
+
// SISTEMA MULTI-REDIRECIONAMENTO
|
|
1646
|
+
// ========================================
|
|
1173
1647
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
function handleConditionalField(triggerElement) {
|
|
1182
|
-
const fieldId = triggerElement.dataset.fieldId;
|
|
1183
|
-
const selectedValue = triggerElement.value;
|
|
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...');
|
|
1184
1655
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1656
|
+
const groups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
1657
|
+
console.log(`🔍 Encontrados ${groups.length} grupos multi-redirect`);
|
|
1187
1658
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
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
|
+
}
|
|
1194
1666
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
inputs.forEach(input => {
|
|
1198
|
-
if (input.dataset.originalRequired !== undefined) {
|
|
1199
|
-
input.required = input.dataset.originalRequired === 'true';
|
|
1200
|
-
}
|
|
1201
|
-
});
|
|
1202
|
-
} else {
|
|
1203
|
-
// Esconder campos
|
|
1204
|
-
fieldContainer.style.display = 'none';
|
|
1667
|
+
const config = JSON.parse(configData);
|
|
1668
|
+
multiRedirectFields.set(config.fieldId, config);
|
|
1205
1669
|
|
|
1206
|
-
|
|
1207
|
-
const inputs = fieldContainer.querySelectorAll('input, select, textarea');
|
|
1670
|
+
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
1208
1671
|
inputs.forEach(input => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1213
|
-
input.required = false;
|
|
1214
|
-
|
|
1215
|
-
// Limpar valores
|
|
1216
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
1217
|
-
input.checked = false;
|
|
1218
|
-
} else {
|
|
1219
|
-
input.value = '';
|
|
1220
|
-
}
|
|
1672
|
+
input.addEventListener('change', function() {
|
|
1673
|
+
handleMultiRedirectChange(config, this);
|
|
1674
|
+
});
|
|
1221
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);
|
|
1222
1681
|
}
|
|
1223
1682
|
});
|
|
1683
|
+
|
|
1684
|
+
console.log(`🔀 ${multiRedirectFields.size} campos multi-redirect ativos`);
|
|
1224
1685
|
}
|
|
1225
|
-
});
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
// ADICIONE ESTE CÓDIGO AO FINAL DO SEU <script> NO form_field.html
|
|
1229
1686
|
|
|
1230
|
-
//
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
//
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
groups.forEach(group => {
|
|
1246
|
-
try {
|
|
1247
|
-
const configData = group.getAttribute('data-field-config');
|
|
1248
|
-
if (!configData) {
|
|
1249
|
-
console.log('⚠️ Configuração não encontrada para grupo:', group);
|
|
1250
|
-
return;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
const config = JSON.parse(configData);
|
|
1254
|
-
multiRedirectFields.set(config.fieldId, config);
|
|
1255
|
-
|
|
1256
|
-
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
1257
|
-
inputs.forEach(input => {
|
|
1258
|
-
input.addEventListener('change', function() {
|
|
1259
|
-
handleMultiRedirectChange(config, this);
|
|
1260
|
-
});
|
|
1261
|
-
});
|
|
1262
|
-
|
|
1263
|
-
console.log(`✅ Campo configurado: ${config.fieldId} (${config.fieldType})`);
|
|
1264
|
-
|
|
1265
|
-
} catch (error) {
|
|
1266
|
-
console.error('❌ Erro configuração multi-redirect:', error, group);
|
|
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;
|
|
1267
1702
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
console.log(`🚀 Executando ação: ${option.action} para "${option.value}"`);
|
|
1297
|
-
|
|
1298
|
-
// Limpar ações/mensagens anteriores
|
|
1299
|
-
clearPreviousActions(config.fieldId);
|
|
1300
|
-
|
|
1301
|
-
// Mostrar mensagem se configurada
|
|
1302
|
-
if (option.message) {
|
|
1303
|
-
showMultiRedirectMessage(config.fieldId, option);
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
// Processar ação
|
|
1307
|
-
const delay = (option.delay || 1) * 1000;
|
|
1308
|
-
|
|
1309
|
-
switch (option.action) {
|
|
1310
|
-
case 'continue':
|
|
1311
|
-
console.log('➡️ Continuando normalmente');
|
|
1312
|
-
break;
|
|
1313
|
-
|
|
1314
|
-
case 'next_step':
|
|
1315
|
-
console.log('⏩ Programando próxima etapa');
|
|
1316
|
-
setTimeout(() => {
|
|
1317
|
-
if (typeof nextStep === 'function') {
|
|
1318
|
-
nextStep();
|
|
1319
|
-
} else {
|
|
1320
|
-
console.log('⚠️ Função nextStep não encontrada');
|
|
1321
|
-
}
|
|
1322
|
-
}, delay);
|
|
1323
|
-
break;
|
|
1324
|
-
|
|
1325
|
-
case 'specific_section':
|
|
1326
|
-
if (option.targetSection) {
|
|
1327
|
-
console.log(`🎯 Programando redirecionamento para: ${option.targetSection}`);
|
|
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');
|
|
1328
1730
|
setTimeout(() => {
|
|
1329
|
-
if (typeof
|
|
1330
|
-
|
|
1731
|
+
if (typeof nextStep === 'function') {
|
|
1732
|
+
nextStep();
|
|
1331
1733
|
} else {
|
|
1332
|
-
console.log('⚠️ Função
|
|
1734
|
+
console.log('⚠️ Função nextStep não encontrada');
|
|
1333
1735
|
}
|
|
1334
1736
|
}, delay);
|
|
1335
|
-
|
|
1336
|
-
|
|
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}`);
|
|
1337
1775
|
|
|
1338
|
-
case 'skip_to_end':
|
|
1339
|
-
console.log('⏭️ Programando finalização');
|
|
1340
1776
|
setTimeout(() => {
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
showConditionalFields(config.fieldId, value);
|
|
1348
|
-
break;
|
|
1777
|
+
messageEl.scrollIntoView({
|
|
1778
|
+
behavior: 'smooth',
|
|
1779
|
+
block: 'center'
|
|
1780
|
+
});
|
|
1781
|
+
}, 100);
|
|
1782
|
+
}
|
|
1349
1783
|
}
|
|
1350
|
-
}
|
|
1351
1784
|
|
|
1352
|
-
// MOSTRAR
|
|
1353
|
-
function
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
const messageEl = document.getElementById(`redirect_message_${blockId}_${optionIndex}`);
|
|
1357
|
-
|
|
1358
|
-
if (messageEl) {
|
|
1359
|
-
messageEl.style.display = 'block';
|
|
1360
|
-
console.log(`💬 Mensagem mostrada para opção: ${option.value}`);
|
|
1785
|
+
// MOSTRAR CAMPOS CONDICIONAIS
|
|
1786
|
+
function showConditionalFields(fieldId, value) {
|
|
1787
|
+
// Primeiro esconder todos os campos condicionais deste campo
|
|
1788
|
+
hideAllConditionalFields(fieldId);
|
|
1361
1789
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
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
|
+
}
|
|
1368
1806
|
}
|
|
1369
|
-
}
|
|
1370
1807
|
|
|
1371
|
-
//
|
|
1372
|
-
function
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
// Mostrar apenas o campo correspondente ao valor selecionado
|
|
1377
|
-
const conditionalField = document.querySelector(
|
|
1378
|
-
`[data-parent-field="${fieldId}"][data-option-value="${value}"]`
|
|
1379
|
-
);
|
|
1380
|
-
|
|
1381
|
-
if (conditionalField) {
|
|
1382
|
-
conditionalField.style.display = 'block';
|
|
1383
|
-
console.log(`👁️ Campos condicionais mostrados para: ${value}`);
|
|
1808
|
+
// OCULTAR TODAS AS MENSAGENS
|
|
1809
|
+
function hideAllMessages(fieldId) {
|
|
1810
|
+
const blockId = fieldId.split('_').pop();
|
|
1811
|
+
const messages = document.querySelectorAll(`[id^="redirect_message_${blockId}_"]`);
|
|
1384
1812
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
block: 'center'
|
|
1389
|
-
});
|
|
1390
|
-
}, 200);
|
|
1813
|
+
messages.forEach(message => {
|
|
1814
|
+
message.style.display = 'none';
|
|
1815
|
+
});
|
|
1391
1816
|
}
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
// OCULTAR TODAS AS MENSAGENS
|
|
1395
|
-
function hideAllMessages(fieldId) {
|
|
1396
|
-
const blockId = fieldId.split('_').pop();
|
|
1397
|
-
const messages = document.querySelectorAll(`[id^="redirect_message_${blockId}_"]`);
|
|
1398
|
-
|
|
1399
|
-
messages.forEach(message => {
|
|
1400
|
-
message.style.display = 'none';
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
1817
|
|
|
1404
|
-
// OCULTAR TODOS OS CAMPOS CONDICIONAIS
|
|
1405
|
-
function hideAllConditionalFields(fieldId) {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
}
|
|
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
|
+
}
|
|
1412
1826
|
|
|
1413
|
-
// LIMPAR AÇÕES ANTERIORES
|
|
1414
|
-
function clearPreviousActions(fieldId) {
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
}
|
|
1827
|
+
// LIMPAR AÇÕES ANTERIORES
|
|
1828
|
+
function clearPreviousActions(fieldId) {
|
|
1829
|
+
pendingActions.delete(fieldId);
|
|
1830
|
+
hideAllMessages(fieldId);
|
|
1831
|
+
}
|
|
1418
1832
|
|
|
1419
|
-
// PULAR PARA ETAPA FINAL
|
|
1420
|
-
function skipToFinalStep() {
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
// Adicionar campo hidden indicando redirecionamento
|
|
1424
|
-
const form = document.getElementById('wagtailForm');
|
|
1425
|
-
if (form) {
|
|
1426
|
-
let skipField = form.querySelector('input[name="form_redirected"]');
|
|
1427
|
-
if (!skipField) {
|
|
1428
|
-
skipField = document.createElement('input');
|
|
1429
|
-
skipField.type = 'hidden';
|
|
1430
|
-
skipField.name = 'form_redirected';
|
|
1431
|
-
form.appendChild(skipField);
|
|
1432
|
-
}
|
|
1433
|
-
skipField.value = 'true';
|
|
1833
|
+
// PULAR PARA ETAPA FINAL
|
|
1834
|
+
function skipToFinalStep() {
|
|
1835
|
+
console.log(`⏭️ Executando pulo para final`);
|
|
1434
1836
|
|
|
1435
|
-
|
|
1436
|
-
form.
|
|
1437
|
-
|
|
1438
|
-
|
|
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
|
+
}
|
|
1439
1854
|
}
|
|
1440
|
-
}
|
|
1441
1855
|
|
|
1442
|
-
// FUNÇÃO PARA REDIRECIONAR PARA SEÇÃO ESPECÍFICA (caso não exista)
|
|
1443
|
-
if (typeof redirectToSpecificSection === 'undefined') {
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
// Procurar divisores com título correspondente
|
|
1448
|
-
const dividers = document.querySelectorAll('.divider-title');
|
|
1449
|
-
|
|
1450
|
-
for (const divider of dividers) {
|
|
1451
|
-
const dividerTitle = divider.textContent?.trim() || '';
|
|
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}"`);
|
|
1452
1860
|
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
// Scroll para o divisor
|
|
1459
|
-
setTimeout(() => {
|
|
1460
|
-
divider.scrollIntoView({
|
|
1461
|
-
behavior: 'smooth',
|
|
1462
|
-
block: 'center'
|
|
1463
|
-
});
|
|
1464
|
-
}, 100);
|
|
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() || '';
|
|
1465
1866
|
|
|
1466
|
-
|
|
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
|
+
}
|
|
1467
1882
|
}
|
|
1883
|
+
|
|
1884
|
+
console.log(`❌ Seção "${sectionTitle}" não encontrada`);
|
|
1885
|
+
return false;
|
|
1468
1886
|
}
|
|
1469
|
-
|
|
1470
|
-
console.log(`❌ Seção "${sectionTitle}" não encontrada`);
|
|
1471
|
-
return false;
|
|
1472
1887
|
}
|
|
1473
|
-
}
|
|
1474
1888
|
|
|
1475
|
-
// INICIALIZAÇÃO QUANDO DOM CARREGAR
|
|
1476
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
// DEBUGGING
|
|
1484
|
-
window.debugMultiRedirect = {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
};
|
|
1491
|
-
|
|
1492
|
-
console.log('🔀 Sistema Multi-Redirecionamento carregado');
|
|
1493
|
-
console.log('🔧 Debug: window.debugMultiRedirect');
|
|
1494
|
-
|
|
1495
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
1496
|
-
|
|
1497
|
-
});
|
|
1498
|
-
|
|
1499
|
-
function initializeMultiRedirectField(fieldId) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
if (optionValue === selectedValue) {
|
|
1512
|
-
// Mostrar campos desta opção
|
|
1513
|
-
conditionalField.style.display = 'block';
|
|
1514
|
-
conditionalField.style.animation = 'fadeIn 0.3s ease-in-out';
|
|
1515
|
-
|
|
1516
|
-
// Marcar campos como obrigatórios se necessário
|
|
1517
|
-
const nestedInputs = conditionalField.querySelectorAll('input[data-originally-required], select[data-originally-required], textarea[data-originally-required]');
|
|
1518
|
-
nestedInputs.forEach(input => {
|
|
1519
|
-
input.required = true;
|
|
1520
|
-
});
|
|
1521
|
-
} else {
|
|
1522
|
-
// Ocultar campos de outras opções
|
|
1523
|
-
conditionalField.style.display = 'none';
|
|
1889
|
+
// INICIALIZAÇÃO QUANDO DOM CARREGAR
|
|
1890
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1891
|
+
// Aguardar um pouco para garantir que tudo carregou
|
|
1892
|
+
setTimeout(() => {
|
|
1893
|
+
initializeMultiRedirectFields();
|
|
1894
|
+
}, 500);
|
|
1895
|
+
});
|
|
1896
|
+
|
|
1897
|
+
// DEBUGGING
|
|
1898
|
+
window.debugMultiRedirect = {
|
|
1899
|
+
fields: () => multiRedirectFields,
|
|
1900
|
+
pending: () => pendingActions,
|
|
1901
|
+
testSection: (name) => redirectToSpecificSection(name),
|
|
1902
|
+
skipToEnd: () => skipToFinalStep(),
|
|
1903
|
+
init: () => initializeMultiRedirectFields()
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
console.log('🔀 Sistema Multi-Redirecionamento carregado');
|
|
1907
|
+
console.log('🔧 Debug: window.debugMultiRedirect');
|
|
1908
|
+
|
|
1909
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1910
|
+
initializeMultiRedirectField('{{ block.block_type }}_{{ block.id }}');
|
|
1911
|
+
});
|
|
1912
|
+
|
|
1913
|
+
function initializeMultiRedirectField(fieldId) {
|
|
1914
|
+
const fieldGroup = document.querySelector(`[data-field-id="${fieldId}"]`);
|
|
1915
|
+
if (!fieldGroup) return;
|
|
1916
|
+
|
|
1917
|
+
const inputs = fieldGroup.querySelectorAll('.multi-redirect-input');
|
|
1918
|
+
const conditionalFields = fieldGroup.querySelectorAll('.multi-redirect-fields');
|
|
1919
|
+
|
|
1920
|
+
// Função para mostrar/ocultar campos condicionais
|
|
1921
|
+
function toggleConditionalFields(selectedValue) {
|
|
1922
|
+
conditionalFields.forEach(conditionalField => {
|
|
1923
|
+
const optionValue = conditionalField.getAttribute('data-option-value');
|
|
1524
1924
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
input
|
|
1925
|
+
if (optionValue === selectedValue) {
|
|
1926
|
+
// Mostrar campos desta opção
|
|
1927
|
+
conditionalField.style.display = 'block';
|
|
1928
|
+
conditionalField.style.animation = 'fadeIn 0.3s ease-in-out';
|
|
1929
|
+
|
|
1930
|
+
// Marcar campos como obrigatórios se necessário
|
|
1931
|
+
const nestedInputs = conditionalField.querySelectorAll('input[data-originally-required], select[data-originally-required], textarea[data-originally-required]');
|
|
1932
|
+
nestedInputs.forEach(input => {
|
|
1933
|
+
input.required = true;
|
|
1934
|
+
});
|
|
1935
|
+
} else {
|
|
1936
|
+
// Ocultar campos de outras opções
|
|
1937
|
+
conditionalField.style.display = 'none';
|
|
1532
1938
|
|
|
1533
|
-
//
|
|
1534
|
-
|
|
1535
|
-
|
|
1939
|
+
// Remover obrigatoriedade dos campos ocultos
|
|
1940
|
+
const nestedInputs = conditionalField.querySelectorAll('input, select, textarea');
|
|
1941
|
+
nestedInputs.forEach(input => {
|
|
1942
|
+
if (!input.getAttribute('data-originally-required')) {
|
|
1943
|
+
input.setAttribute('data-originally-required', input.required ? 'true' : 'false');
|
|
1944
|
+
}
|
|
1945
|
+
input.required = false;
|
|
1946
|
+
|
|
1947
|
+
// Limpar valores dos campos ocultos
|
|
1948
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
1949
|
+
input.checked = false;
|
|
1950
|
+
} else {
|
|
1951
|
+
input.value = '';
|
|
1952
|
+
}
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
// Event listeners para diferentes tipos de input
|
|
1959
|
+
inputs.forEach(input => {
|
|
1960
|
+
if (input.type === 'checkbox') {
|
|
1961
|
+
input.addEventListener('change', function() {
|
|
1962
|
+
if (this.checked) {
|
|
1963
|
+
toggleConditionalFields(this.value);
|
|
1536
1964
|
} else {
|
|
1537
|
-
|
|
1965
|
+
toggleConditionalFields('');
|
|
1966
|
+
}
|
|
1967
|
+
});
|
|
1968
|
+
|
|
1969
|
+
} else if (input.type === 'radio') {
|
|
1970
|
+
input.addEventListener('change', function() {
|
|
1971
|
+
if (this.checked) {
|
|
1972
|
+
toggleConditionalFields(this.value);
|
|
1538
1973
|
}
|
|
1539
1974
|
});
|
|
1975
|
+
|
|
1976
|
+
} else if (input.tagName === 'SELECT') {
|
|
1977
|
+
input.addEventListener('change', function() {
|
|
1978
|
+
toggleConditionalFields(this.value);
|
|
1979
|
+
});
|
|
1540
1980
|
}
|
|
1541
1981
|
});
|
|
1982
|
+
|
|
1983
|
+
console.log(`✅ Multi-redirect field ${fieldId} inicializado com ${conditionalFields.length} campos condicionais`);
|
|
1542
1984
|
}
|
|
1543
1985
|
|
|
1544
|
-
// Event listeners para diferentes tipos de input
|
|
1545
|
-
inputs.forEach(input => {
|
|
1546
|
-
if (input.type === 'checkbox') {
|
|
1547
|
-
input.addEventListener('change', function() {
|
|
1548
|
-
if (this.checked) {
|
|
1549
|
-
toggleConditionalFields(this.value);
|
|
1550
|
-
} else {
|
|
1551
|
-
toggleConditionalFields('');
|
|
1552
|
-
}
|
|
1553
|
-
});
|
|
1554
|
-
|
|
1555
|
-
} else if (input.type === 'radio') {
|
|
1556
|
-
input.addEventListener('change', function() {
|
|
1557
|
-
if (this.checked) {
|
|
1558
|
-
toggleConditionalFields(this.value);
|
|
1559
|
-
}
|
|
1560
|
-
});
|
|
1561
|
-
|
|
1562
|
-
} else if (input.tagName === 'SELECT') {
|
|
1563
|
-
input.addEventListener('change', function() {
|
|
1564
|
-
toggleConditionalFields(this.value);
|
|
1565
|
-
});
|
|
1566
|
-
}
|
|
1567
|
-
});
|
|
1568
1986
|
|
|
1569
|
-
console.log(`✅ Multi-redirect field ${fieldId} inicializado com ${conditionalFields.length} campos condicionais`);
|
|
1570
|
-
}
|
|
1571
1987
|
|
|
1572
1988
|
// document.addEventListener('DOMContentLoaded', function() {
|
|
1573
1989
|
// // Dados dos estados passados pelo Django
|