wagtail-enap-designsystem 1.2.1.121__py3-none-any.whl → 1.2.1.123__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/__init__.py +4 -0
- enap_designsystem/blocks/form.py +101 -6
- enap_designsystem/blocks/html_blocks.py +199 -52
- enap_designsystem/blocks/semana_inovacao.py +7 -1
- enap_designsystem/middleware/aluno_sso.py +16 -0
- enap_designsystem/migrations/0382_alter_areaaluno_body_alter_cursoeadpage_curso_and_more.py +51080 -0
- enap_designsystem/migrations/0383_alter_areaaluno_body_alter_enapcomponentes_body_and_more.py +50922 -0
- enap_designsystem/migrations/0384_alter_areaaluno_body_alter_enapcomponentes_body_and_more.py +51606 -0
- enap_designsystem/migrations/0385_alter_areaaluno_body_alter_enapcomponentes_body_and_more.py +51947 -0
- enap_designsystem/migrations/0386_alter_areaaluno_body_alter_enapcomponentes_body_and_more.py +51809 -0
- enap_designsystem/models.py +0 -27
- enap_designsystem/templates/custom_404.html +1 -1
- enap_designsystem/templates/enap_designsystem/blocks/apresentacao_block.html +116 -0
- enap_designsystem/templates/enap_designsystem/blocks/apresentacao_simple_block.html +236 -0
- enap_designsystem/templates/enap_designsystem/form_templates/formulario_page.html +490 -13
- enap_designsystem/templates/enap_designsystem/includes/form_field.html +661 -4
- enap_designsystem/templates/enap_designsystem/pages/mba_especializacao.html +10 -0
- enap_designsystem/templates/enap_designsystem/sistema_votacao_page.html +194 -202
- enap_designsystem/urls.py +6 -3
- enap_designsystem/views.py +118 -153
- enap_designsystem/wagtail_hooks.py +235 -77
- {wagtail_enap_designsystem-1.2.1.121.dist-info → wagtail_enap_designsystem-1.2.1.123.dist-info}/METADATA +1 -1
- {wagtail_enap_designsystem-1.2.1.121.dist-info → wagtail_enap_designsystem-1.2.1.123.dist-info}/RECORD +26 -18
- {wagtail_enap_designsystem-1.2.1.121.dist-info → wagtail_enap_designsystem-1.2.1.123.dist-info}/WHEEL +0 -0
- {wagtail_enap_designsystem-1.2.1.121.dist-info → wagtail_enap_designsystem-1.2.1.123.dist-info}/licenses/LICENSE +0 -0
- {wagtail_enap_designsystem-1.2.1.121.dist-info → wagtail_enap_designsystem-1.2.1.123.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,189 @@
|
|
|
1
1
|
<!-- home/templates/home/includes/form_field.html -->
|
|
2
2
|
{% load wagtailcore_tags %}
|
|
3
3
|
{% load wagtailimages_tags %}
|
|
4
|
-
|
|
4
|
+
<style>
|
|
5
|
+
.conditional-fields {
|
|
6
|
+
border-left: 4px solid var(--primary-color);
|
|
7
|
+
background: #f8f9fa;
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.conditional-header h4 {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 0.5rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.checkbox-multi-redirect-group {
|
|
19
|
+
position: relative;
|
|
20
|
+
margin-bottom: 2rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.multi-redirect-item {
|
|
24
|
+
border: 2px solid #e1e5e9;
|
|
25
|
+
border-radius: 12px;
|
|
26
|
+
padding: 1.2rem;
|
|
27
|
+
margin-bottom: 0.75rem;
|
|
28
|
+
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
29
|
+
transition: all 0.3s ease;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.multi-redirect-item:hover {
|
|
36
|
+
border-color: var(--primary-color, #2A5E2C);
|
|
37
|
+
background: linear-gradient(135deg, rgba(42, 94, 44, 0.02) 0%, #ffffff 100%);
|
|
38
|
+
transform: translateY(-1px);
|
|
39
|
+
box-shadow: 0 4px 15px rgba(42, 94, 44, 0.1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.multi-redirect-item.selected {
|
|
43
|
+
border-color: var(--primary-color, #2A5E2C);
|
|
44
|
+
background: linear-gradient(135deg, rgba(42, 94, 44, 0.05) 0%, #ffffff 100%);
|
|
45
|
+
box-shadow: 0 4px 15px rgba(42, 94, 44, 0.15);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.multi-redirect-input[type="checkbox"],
|
|
49
|
+
.multi-redirect-input[type="radio"] {
|
|
50
|
+
width: 20px !important;
|
|
51
|
+
height: 20px !important;
|
|
52
|
+
margin-right: 1rem;
|
|
53
|
+
accent-color: var(--primary-color, #2A5E2C);
|
|
54
|
+
transform: scale(1.2);
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.checkbox-label,
|
|
59
|
+
.radio-label {
|
|
60
|
+
font-size: 1.1rem;
|
|
61
|
+
font-weight: 500;
|
|
62
|
+
color: #434A54;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
margin: 0 !important;
|
|
65
|
+
flex: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.multi-redirect-radio-group {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
gap: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Dropdown especial */
|
|
75
|
+
.multi-redirect-input.form-control {
|
|
76
|
+
border: 2px solid #e1e5e9;
|
|
77
|
+
border-radius: 12px;
|
|
78
|
+
padding: 1rem;
|
|
79
|
+
font-size: 1.1rem;
|
|
80
|
+
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
81
|
+
transition: all 0.3s ease;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.multi-redirect-input.form-control:focus {
|
|
85
|
+
border-color: var(--primary-color, #2A5E2C);
|
|
86
|
+
background: white;
|
|
87
|
+
box-shadow: 0 0 0 3px rgba(42, 94, 44, 0.1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Mensagens de redirecionamento */
|
|
91
|
+
.multi-redirect-message {
|
|
92
|
+
animation: slideDown 0.5s ease-out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.multi-redirect-message .redirect-message-content {
|
|
96
|
+
padding: 0.5rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Campos condicionais */
|
|
100
|
+
.multi-redirect-fields {
|
|
101
|
+
animation: expandDown 0.4s ease-out;
|
|
102
|
+
border-left: 4px solid var(--primary-color, #2A5E2C) !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.conditional-header {
|
|
106
|
+
border-bottom: 1px solid rgba(42, 94, 44, 0.1);
|
|
107
|
+
padding-bottom: 0.75rem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Indicador de ação pendente */
|
|
111
|
+
.checkbox-multi-redirect-group.action-pending {
|
|
112
|
+
position: relative;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.checkbox-multi-redirect-group.action-pending::after {
|
|
116
|
+
content: attr(data-pending-action);
|
|
117
|
+
position: absolute;
|
|
118
|
+
top: -10px;
|
|
119
|
+
right: 10px;
|
|
120
|
+
background: var(--primary-color, #2A5E2C);
|
|
121
|
+
color: white;
|
|
122
|
+
padding: 0.25rem 0.75rem;
|
|
123
|
+
border-radius: 15px;
|
|
124
|
+
font-size: 0.75rem;
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
z-index: 10;
|
|
127
|
+
animation: pulse 2s infinite;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Animações */
|
|
131
|
+
@keyframes slideDown {
|
|
132
|
+
from {
|
|
133
|
+
opacity: 0;
|
|
134
|
+
max-height: 0;
|
|
135
|
+
transform: translateY(-10px);
|
|
136
|
+
}
|
|
137
|
+
to {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
max-height: 300px;
|
|
140
|
+
transform: translateY(0);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@keyframes expandDown {
|
|
145
|
+
from {
|
|
146
|
+
opacity: 0;
|
|
147
|
+
max-height: 0;
|
|
148
|
+
transform: scaleY(0.8);
|
|
149
|
+
}
|
|
150
|
+
to {
|
|
151
|
+
opacity: 1;
|
|
152
|
+
max-height: 1000px;
|
|
153
|
+
transform: scaleY(1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@keyframes pulse {
|
|
158
|
+
0% { opacity: 0.8; transform: scale(1); }
|
|
159
|
+
50% { opacity: 1; transform: scale(1.05); }
|
|
160
|
+
100% { opacity: 0.8; transform: scale(1); }
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Responsivo */
|
|
164
|
+
@media (max-width: 768px) {
|
|
165
|
+
.multi-redirect-item {
|
|
166
|
+
padding: 1rem;
|
|
167
|
+
flex-direction: row;
|
|
168
|
+
align-items: flex-start;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.multi-redirect-input[type="checkbox"],
|
|
172
|
+
.multi-redirect-input[type="radio"] {
|
|
173
|
+
transform: scale(1.1);
|
|
174
|
+
margin-top: 0.2rem;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.checkbox-label,
|
|
178
|
+
.radio-label {
|
|
179
|
+
font-size: 1rem;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.multi-redirect-fields {
|
|
183
|
+
padding: 1rem;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
</style>
|
|
5
187
|
|
|
6
188
|
|
|
7
189
|
{% if block.block_type == 'section_header' %}
|
|
@@ -572,9 +754,140 @@
|
|
|
572
754
|
</div>
|
|
573
755
|
</div>
|
|
574
756
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
757
|
+
{% elif block.block_type == 'checkbox_multi_redirect_field' %}
|
|
758
|
+
<div class="form-group checkbox-multi-redirect-group"
|
|
759
|
+
data-field-type="checkbox_multi_redirect_field"
|
|
760
|
+
data-field-id="{{ block.block_type }}_{{ block.id }}"
|
|
761
|
+
data-field-config='{
|
|
762
|
+
"fieldId": "{{ block.block_type }}_{{ block.id }}",
|
|
763
|
+
"fieldType": "{{ block.value.field_type }}",
|
|
764
|
+
"options": [
|
|
765
|
+
{% for option_block in block.value.redirect_options %}
|
|
766
|
+
{
|
|
767
|
+
"value": "{{ option_block.value.value|escapejs }}",
|
|
768
|
+
"action": "{{ option_block.value.action }}",
|
|
769
|
+
"targetSection": "{{ option_block.value.target_section_title|default:''|escapejs }}",
|
|
770
|
+
"message": "{{ option_block.value.redirect_message|striptags|default:''|escapejs }}",
|
|
771
|
+
"delay": {{ option_block.value.delay_seconds|default:1 }}
|
|
772
|
+
}{% if not forloop.last %},{% endif %}
|
|
773
|
+
{% endfor %}
|
|
774
|
+
]
|
|
775
|
+
}'>
|
|
776
|
+
|
|
777
|
+
<!-- Label principal -->
|
|
778
|
+
<label class="form-label">
|
|
779
|
+
{{ block.value.label }}
|
|
780
|
+
{% if block.value.required %}<span class="required">*</span>{% endif %}
|
|
781
|
+
</label>
|
|
782
|
+
|
|
783
|
+
<!-- Texto de ajuda -->
|
|
784
|
+
{% if block.value.help_text %}
|
|
785
|
+
<div class="help-text">{{ block.value.help_text }}</div>
|
|
786
|
+
{% endif %}
|
|
787
|
+
|
|
788
|
+
<!-- Renderizar campo baseado no tipo -->
|
|
789
|
+
{% if block.value.field_type == 'checkbox' %}
|
|
790
|
+
<!-- Checkbox único (primeira opção) -->
|
|
791
|
+
{% for option_block in block.value.redirect_options|slice:":1" %}
|
|
792
|
+
<div class="checkbox-item multi-redirect-item" data-option-value="{{ option_block.value.value }}">
|
|
793
|
+
<input
|
|
794
|
+
type="checkbox"
|
|
795
|
+
id="{{ block.block_type }}_{{ block.id }}"
|
|
796
|
+
name="{{ block.block_type }}_{{ block.id }}"
|
|
797
|
+
value="{{ option_block.value.value }}"
|
|
798
|
+
{% if block.value.required %}required{% endif %}
|
|
799
|
+
class="multi-redirect-input"
|
|
800
|
+
data-option-index="0"
|
|
801
|
+
>
|
|
802
|
+
<label for="{{ block.block_type }}_{{ block.id }}" class="checkbox-label">
|
|
803
|
+
{{ option_block.value.value }}
|
|
804
|
+
</label>
|
|
805
|
+
</div>
|
|
806
|
+
{% endfor %}
|
|
807
|
+
|
|
808
|
+
{% elif block.value.field_type == 'radio' %}
|
|
809
|
+
<!-- Múltiplos radio buttons -->
|
|
810
|
+
<div class="radio-group multi-redirect-radio-group">
|
|
811
|
+
{% for option_block in block.value.redirect_options %}
|
|
812
|
+
<div class="radio-item multi-redirect-item" data-option-value="{{ option_block.value.value }}">
|
|
813
|
+
<input
|
|
814
|
+
type="radio"
|
|
815
|
+
id="{{ block.block_type }}_{{ block.id }}_{{ forloop.counter }}"
|
|
816
|
+
name="{{ block.block_type }}_{{ block.id }}"
|
|
817
|
+
value="{{ option_block.value.value }}"
|
|
818
|
+
{% if block.value.required %}required{% endif %}
|
|
819
|
+
class="multi-redirect-input"
|
|
820
|
+
data-option-index="{{ forloop.counter0 }}"
|
|
821
|
+
>
|
|
822
|
+
<label for="{{ block.block_type }}_{{ block.id }}_{{ forloop.counter }}" class="radio-label">
|
|
823
|
+
{{ option_block.value.value }}
|
|
824
|
+
</label>
|
|
825
|
+
</div>
|
|
826
|
+
{% endfor %}
|
|
827
|
+
</div>
|
|
828
|
+
|
|
829
|
+
{% else %}
|
|
830
|
+
<!-- Dropdown -->
|
|
831
|
+
<select
|
|
832
|
+
id="{{ block.block_type }}_{{ block.id }}"
|
|
833
|
+
name="{{ block.block_type }}_{{ block.id }}"
|
|
834
|
+
class="form-control multi-redirect-input"
|
|
835
|
+
{% if block.value.required %}required{% endif %}
|
|
836
|
+
>
|
|
837
|
+
<option value="">Selecione uma opção...</option>
|
|
838
|
+
{% for option_block in block.value.redirect_options %}
|
|
839
|
+
<option value="{{ option_block.value.value }}" data-option-index="{{ forloop.counter0 }}">
|
|
840
|
+
{{ option_block.value.value }}
|
|
841
|
+
</option>
|
|
842
|
+
{% endfor %}
|
|
843
|
+
</select>
|
|
844
|
+
{% endif %}
|
|
845
|
+
|
|
846
|
+
<!-- Mensagens de redirecionamento para cada opção -->
|
|
847
|
+
{% for option_block in block.value.redirect_options %}
|
|
848
|
+
{% if option_block.value.redirect_message %}
|
|
849
|
+
<div class="redirect-message multi-redirect-message"
|
|
850
|
+
id="redirect_message_{{ block.id }}_{{ forloop.counter0 }}"
|
|
851
|
+
style="display: none; margin-top: 1rem;">
|
|
852
|
+
<div class="info-block info-info">
|
|
853
|
+
<div class="redirect-message-content">
|
|
854
|
+
<strong>
|
|
855
|
+
{% if option_block.value.action == 'next_step' %}⏩ Avançando...
|
|
856
|
+
{% elif option_block.value.action == 'specific_section' %}🎯 Redirecionando...
|
|
857
|
+
{% elif option_block.value.action == 'skip_to_end' %}⏭️ Finalizando...
|
|
858
|
+
{% else %}ℹ️ Informação:
|
|
859
|
+
{% endif %}
|
|
860
|
+
</strong>
|
|
861
|
+
{{ option_block.value.redirect_message|richtext }}
|
|
862
|
+
</div>
|
|
863
|
+
</div>
|
|
864
|
+
</div>
|
|
865
|
+
{% endif %}
|
|
866
|
+
{% endfor %}
|
|
867
|
+
|
|
868
|
+
<!-- 🎯 CAMPOS CONDICIONAIS PARA CADA OPÇÃO -->
|
|
869
|
+
{% for option_block in block.value.redirect_options %}
|
|
870
|
+
{% if option_block.value.action == 'show_fields' and option_block.value.fields_to_show %}
|
|
871
|
+
<div class="conditional-fields multi-redirect-fields"
|
|
872
|
+
data-option-value="{{ option_block.value.value }}"
|
|
873
|
+
data-parent-field="{{ block.block_type }}_{{ block.id }}"
|
|
874
|
+
style="display: none; margin-top: 1.5rem; padding: 1.5rem; border: 2px solid var(--primary-color, #2A5E2C); border-radius: 12px; background: linear-gradient(135deg, rgba(42, 94, 44, 0.02) 0%, #ffffff 100%);">
|
|
875
|
+
|
|
876
|
+
<div class="conditional-header" style="margin-bottom: 1rem;">
|
|
877
|
+
|
|
878
|
+
</div>
|
|
879
|
+
|
|
880
|
+
<!-- 🚀 RENDERIZAR CAMPOS CONDICIONAIS -->
|
|
881
|
+
{% for field_block in option_block.value.fields_to_show %}
|
|
882
|
+
{% include 'enap_designsystem/includes/form_field.html' with block=field_block %}
|
|
883
|
+
{% endfor %}
|
|
884
|
+
</div>
|
|
885
|
+
{% endif %}
|
|
886
|
+
{% endfor %}
|
|
887
|
+
|
|
888
|
+
<!-- Campo de erro -->
|
|
889
|
+
<div class="error-message" style="display: none;"></div>
|
|
890
|
+
</div>
|
|
578
891
|
|
|
579
892
|
<!-- {% elif block.block_type == 'estado_cidade_field' %}
|
|
580
893
|
<div class="form-group estado-cidade-group" data-layout="{{ block.value.layout }}">
|
|
@@ -687,6 +1000,8 @@
|
|
|
687
1000
|
{% endif %}
|
|
688
1001
|
</div>
|
|
689
1002
|
|
|
1003
|
+
|
|
1004
|
+
|
|
690
1005
|
{% endif %}
|
|
691
1006
|
|
|
692
1007
|
<script>
|
|
@@ -910,7 +1225,349 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
910
1225
|
});
|
|
911
1226
|
|
|
912
1227
|
|
|
1228
|
+
// ADICIONE ESTE CÓDIGO AO FINAL DO SEU <script> NO form_field.html
|
|
1229
|
+
|
|
1230
|
+
// ========================================
|
|
1231
|
+
// SISTEMA MULTI-REDIRECIONAMENTO
|
|
1232
|
+
// ========================================
|
|
1233
|
+
|
|
1234
|
+
// Variáveis de controle
|
|
1235
|
+
let multiRedirectFields = new Map();
|
|
1236
|
+
let pendingActions = new Map();
|
|
1237
|
+
|
|
1238
|
+
// INICIALIZAÇÃO DOS CAMPOS MULTI-REDIRECT
|
|
1239
|
+
function initializeMultiRedirectFields() {
|
|
1240
|
+
console.log('🔀 Inicializando multi-redirecionamento...');
|
|
1241
|
+
|
|
1242
|
+
const groups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
1243
|
+
console.log(`🔍 Encontrados ${groups.length} grupos multi-redirect`);
|
|
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);
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
console.log(`🔀 ${multiRedirectFields.size} campos multi-redirect ativos`);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// GERENCIAR MUDANÇA NO CAMPO
|
|
1274
|
+
function handleMultiRedirectChange(config, input) {
|
|
1275
|
+
const value = input.value;
|
|
1276
|
+
const isSelected = input.checked || (input.tagName === 'SELECT' && value);
|
|
1277
|
+
|
|
1278
|
+
console.log(`🎯 Campo ${config.fieldId}: valor="${value}", selecionado=${isSelected}`);
|
|
1279
|
+
|
|
1280
|
+
// Para radio e select, sempre processar se tem valor
|
|
1281
|
+
// Para checkbox, só processar se estiver marcado
|
|
1282
|
+
const shouldProcess = (config.fieldType === 'checkbox') ? input.checked : Boolean(value);
|
|
1283
|
+
|
|
1284
|
+
if (!shouldProcess) {
|
|
1285
|
+
hideAllMessages(config.fieldId);
|
|
1286
|
+
hideAllConditionalFields(config.fieldId);
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
const option = config.options.find(opt => opt.value === value);
|
|
1291
|
+
if (!option) {
|
|
1292
|
+
console.log(`⚠️ Opção não encontrada para valor: ${value}`);
|
|
1293
|
+
return;
|
|
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}`);
|
|
1328
|
+
setTimeout(() => {
|
|
1329
|
+
if (typeof redirectToSpecificSection === 'function') {
|
|
1330
|
+
redirectToSpecificSection(option.targetSection);
|
|
1331
|
+
} else {
|
|
1332
|
+
console.log('⚠️ Função redirectToSpecificSection não encontrada');
|
|
1333
|
+
}
|
|
1334
|
+
}, delay);
|
|
1335
|
+
}
|
|
1336
|
+
break;
|
|
1337
|
+
|
|
1338
|
+
case 'skip_to_end':
|
|
1339
|
+
console.log('⏭️ Programando finalização');
|
|
1340
|
+
setTimeout(() => {
|
|
1341
|
+
skipToFinalStep();
|
|
1342
|
+
}, delay);
|
|
1343
|
+
break;
|
|
1344
|
+
|
|
1345
|
+
case 'show_fields':
|
|
1346
|
+
console.log(`👁️ Mostrando campos condicionais para: ${value}`);
|
|
1347
|
+
showConditionalFields(config.fieldId, value);
|
|
1348
|
+
break;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// MOSTRAR MENSAGEM DE REDIRECIONAMENTO
|
|
1353
|
+
function showMultiRedirectMessage(fieldId, option) {
|
|
1354
|
+
const blockId = fieldId.split('_').pop();
|
|
1355
|
+
const optionIndex = multiRedirectFields.get(fieldId).options.findIndex(opt => opt.value === option.value);
|
|
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}`);
|
|
1361
|
+
|
|
1362
|
+
setTimeout(() => {
|
|
1363
|
+
messageEl.scrollIntoView({
|
|
1364
|
+
behavior: 'smooth',
|
|
1365
|
+
block: 'center'
|
|
1366
|
+
});
|
|
1367
|
+
}, 100);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
// MOSTRAR CAMPOS CONDICIONAIS
|
|
1372
|
+
function showConditionalFields(fieldId, value) {
|
|
1373
|
+
// Primeiro esconder todos os campos condicionais deste campo
|
|
1374
|
+
hideAllConditionalFields(fieldId);
|
|
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}`);
|
|
1384
|
+
|
|
1385
|
+
setTimeout(() => {
|
|
1386
|
+
conditionalField.scrollIntoView({
|
|
1387
|
+
behavior: 'smooth',
|
|
1388
|
+
block: 'center'
|
|
1389
|
+
});
|
|
1390
|
+
}, 200);
|
|
1391
|
+
}
|
|
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
|
+
|
|
1404
|
+
// OCULTAR TODOS OS CAMPOS CONDICIONAIS
|
|
1405
|
+
function hideAllConditionalFields(fieldId) {
|
|
1406
|
+
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
1407
|
+
|
|
1408
|
+
conditionalFields.forEach(field => {
|
|
1409
|
+
field.style.display = 'none';
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// LIMPAR AÇÕES ANTERIORES
|
|
1414
|
+
function clearPreviousActions(fieldId) {
|
|
1415
|
+
pendingActions.delete(fieldId);
|
|
1416
|
+
hideAllMessages(fieldId);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
// PULAR PARA ETAPA FINAL
|
|
1420
|
+
function skipToFinalStep() {
|
|
1421
|
+
console.log(`⏭️ Executando pulo para final`);
|
|
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';
|
|
1434
|
+
|
|
1435
|
+
console.log('📨 Submetendo formulário...');
|
|
1436
|
+
form.submit();
|
|
1437
|
+
} else {
|
|
1438
|
+
console.log('⚠️ Formulário não encontrado');
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
// FUNÇÃO PARA REDIRECIONAR PARA SEÇÃO ESPECÍFICA (caso não exista)
|
|
1443
|
+
if (typeof redirectToSpecificSection === 'undefined') {
|
|
1444
|
+
function redirectToSpecificSection(sectionTitle) {
|
|
1445
|
+
console.log(`🎯 Procurando seção: "${sectionTitle}"`);
|
|
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() || '';
|
|
1452
|
+
|
|
1453
|
+
if (dividerTitle.toLowerCase().includes(sectionTitle.toLowerCase()) ||
|
|
1454
|
+
sectionTitle.toLowerCase().includes(dividerTitle.toLowerCase())) {
|
|
1455
|
+
|
|
1456
|
+
console.log(`✅ Seção encontrada: "${dividerTitle}"`);
|
|
1457
|
+
|
|
1458
|
+
// Scroll para o divisor
|
|
1459
|
+
setTimeout(() => {
|
|
1460
|
+
divider.scrollIntoView({
|
|
1461
|
+
behavior: 'smooth',
|
|
1462
|
+
block: 'center'
|
|
1463
|
+
});
|
|
1464
|
+
}, 100);
|
|
1465
|
+
|
|
1466
|
+
return true;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
console.log(`❌ Seção "${sectionTitle}" não encontrada`);
|
|
1471
|
+
return false;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
// INICIALIZAÇÃO QUANDO DOM CARREGAR
|
|
1476
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1477
|
+
// Aguardar um pouco para garantir que tudo carregou
|
|
1478
|
+
setTimeout(() => {
|
|
1479
|
+
initializeMultiRedirectFields();
|
|
1480
|
+
}, 500);
|
|
1481
|
+
});
|
|
1482
|
+
|
|
1483
|
+
// DEBUGGING
|
|
1484
|
+
window.debugMultiRedirect = {
|
|
1485
|
+
fields: () => multiRedirectFields,
|
|
1486
|
+
pending: () => pendingActions,
|
|
1487
|
+
testSection: (name) => redirectToSpecificSection(name),
|
|
1488
|
+
skipToEnd: () => skipToFinalStep(),
|
|
1489
|
+
init: () => initializeMultiRedirectFields()
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
console.log('🔀 Sistema Multi-Redirecionamento carregado');
|
|
1493
|
+
console.log('🔧 Debug: window.debugMultiRedirect');
|
|
1494
|
+
|
|
1495
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1496
|
+
initializeMultiRedirectField('{{ block.block_type }}_{{ block.id }}');
|
|
1497
|
+
});
|
|
1498
|
+
|
|
1499
|
+
function initializeMultiRedirectField(fieldId) {
|
|
1500
|
+
const fieldGroup = document.querySelector(`[data-field-id="${fieldId}"]`);
|
|
1501
|
+
if (!fieldGroup) return;
|
|
1502
|
+
|
|
1503
|
+
const inputs = fieldGroup.querySelectorAll('.multi-redirect-input');
|
|
1504
|
+
const conditionalFields = fieldGroup.querySelectorAll('.multi-redirect-fields');
|
|
1505
|
+
|
|
1506
|
+
// Função para mostrar/ocultar campos condicionais
|
|
1507
|
+
function toggleConditionalFields(selectedValue) {
|
|
1508
|
+
conditionalFields.forEach(conditionalField => {
|
|
1509
|
+
const optionValue = conditionalField.getAttribute('data-option-value');
|
|
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';
|
|
1524
|
+
|
|
1525
|
+
// Remover obrigatoriedade dos campos ocultos
|
|
1526
|
+
const nestedInputs = conditionalField.querySelectorAll('input, select, textarea');
|
|
1527
|
+
nestedInputs.forEach(input => {
|
|
1528
|
+
if (!input.getAttribute('data-originally-required')) {
|
|
1529
|
+
input.setAttribute('data-originally-required', input.required ? 'true' : 'false');
|
|
1530
|
+
}
|
|
1531
|
+
input.required = false;
|
|
1532
|
+
|
|
1533
|
+
// Limpar valores dos campos ocultos
|
|
1534
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
1535
|
+
input.checked = false;
|
|
1536
|
+
} else {
|
|
1537
|
+
input.value = '';
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
|
|
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
|
+
});
|
|
913
1568
|
|
|
1569
|
+
console.log(`✅ Multi-redirect field ${fieldId} inicializado com ${conditionalFields.length} campos condicionais`);
|
|
1570
|
+
}
|
|
914
1571
|
|
|
915
1572
|
// document.addEventListener('DOMContentLoaded', function() {
|
|
916
1573
|
// // Dados dos estados passados pelo Django
|