wagtail-enap-designsystem 1.2.1.131__py3-none-any.whl → 1.2.1.132__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 +81 -49
- 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/templates/enap_designsystem/form_templates/formulario_page.html +456 -109
- enap_designsystem/templates/enap_designsystem/includes/form_field.html +108 -443
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.132.dist-info}/METADATA +1 -1
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.132.dist-info}/RECORD +13 -8
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.132.dist-info}/WHEEL +0 -0
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.132.dist-info}/licenses/LICENSE +0 -0
- {wagtail_enap_designsystem-1.2.1.131.dist-info → wagtail_enap_designsystem-1.2.1.132.dist-info}/top_level.txt +0 -0
|
@@ -1336,7 +1336,7 @@
|
|
|
1336
1336
|
</div>
|
|
1337
1337
|
|
|
1338
1338
|
<!-- FORMULÁRIO -->
|
|
1339
|
-
<form method="post" id="wagtailForm" enctype="multipart/form-data">
|
|
1339
|
+
<form method="post" id="wagtailForm" enctype="multipart/form-data" novalidate>
|
|
1340
1340
|
{% csrf_token %}
|
|
1341
1341
|
|
|
1342
1342
|
<!-- STEPS DINÂMICOS -->
|
|
@@ -1420,6 +1420,10 @@
|
|
|
1420
1420
|
</div>
|
|
1421
1421
|
|
|
1422
1422
|
<script>
|
|
1423
|
+
window.FormularioSystem = window.FormularioSystem || {
|
|
1424
|
+
multiRedirectFields: new Map(),
|
|
1425
|
+
initialized: false
|
|
1426
|
+
};
|
|
1423
1427
|
// VARIÁVEIS GLOBAIS
|
|
1424
1428
|
let currentStep = 0;
|
|
1425
1429
|
let currentActiveWizardIndex = 0;
|
|
@@ -1561,33 +1565,30 @@
|
|
|
1561
1565
|
const currentStepElement = document.getElementById('step' + currentStep);
|
|
1562
1566
|
if (!currentStepElement) return true;
|
|
1563
1567
|
|
|
1568
|
+
console.log(`Validando step ${currentStep}`);
|
|
1569
|
+
|
|
1564
1570
|
let isValid = true;
|
|
1565
1571
|
const requiredInputs = currentStepElement.querySelectorAll('input[required], select[required], textarea[required]');
|
|
1566
1572
|
|
|
1567
1573
|
for (let i = 0; i < requiredInputs.length; i++) {
|
|
1568
1574
|
const input = requiredInputs[i];
|
|
1569
1575
|
|
|
1570
|
-
//
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1576
|
+
// VERIFICAÇÃO MELHORADA - pular campos ocultos
|
|
1577
|
+
const isHidden = (
|
|
1578
|
+
input.style.display === 'none' ||
|
|
1579
|
+
input.offsetParent === null ||
|
|
1580
|
+
input.closest('[style*="display: none"]') ||
|
|
1581
|
+
input.closest('.conditional-fields[style*="display: none"]') ||
|
|
1582
|
+
input.closest('.conditional-condicional-fields[style*="display: none"]')
|
|
1583
|
+
);
|
|
1584
|
+
|
|
1585
|
+
if (isHidden) {
|
|
1586
|
+
console.log(`Pulando campo oculto: ${input.name}`);
|
|
1587
|
+
// REMOVER temporariamente o required de campos ocultos
|
|
1588
|
+
input.required = false;
|
|
1573
1589
|
continue;
|
|
1574
1590
|
}
|
|
1575
1591
|
|
|
1576
|
-
// Pular campos em seções ocultas
|
|
1577
|
-
const sectionElement = input.closest('[data-section-name]');
|
|
1578
|
-
if (sectionElement) {
|
|
1579
|
-
const sectionName = sectionElement.dataset.sectionName;
|
|
1580
|
-
if (hiddenSections.has(sectionName)) {
|
|
1581
|
-
continue;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// Limpar erros anteriores
|
|
1586
|
-
const errorDiv = input.parentNode.querySelector('.error-message');
|
|
1587
|
-
if (errorDiv) {
|
|
1588
|
-
errorDiv.style.display = 'none';
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
1592
|
let hasValue = false;
|
|
1592
1593
|
|
|
1593
1594
|
if (input.type === 'checkbox') {
|
|
@@ -1998,6 +1999,9 @@
|
|
|
1998
1999
|
|
|
1999
2000
|
// Inicializar sistemas
|
|
2000
2001
|
initializeSmartNavigation();
|
|
2002
|
+
|
|
2003
|
+
initializeConditionalFields();
|
|
2004
|
+
initializeMultiRedirectFields();
|
|
2001
2005
|
|
|
2002
2006
|
// Verificar success na URL primeiro
|
|
2003
2007
|
if (!checkForSuccess()) {
|
|
@@ -2151,123 +2155,466 @@ function hideChildrenQuestions() {
|
|
|
2151
2155
|
});
|
|
2152
2156
|
}
|
|
2153
2157
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2158
|
+
function handleSmartNavigation(element) {
|
|
2159
|
+
const fieldContainer = element.closest('[data-field-type="smart_navigation_field"], [data-field-type="checkbox_multi_redirect_field"]');
|
|
2160
|
+
if (!fieldContainer) return;
|
|
2161
|
+
|
|
2162
|
+
const fieldId = fieldContainer.dataset.fieldId;
|
|
2163
|
+
const selectedValue = getSelectedValue(element);
|
|
2164
|
+
|
|
2165
|
+
console.log(`Smart navigation: ${fieldId} = ${selectedValue}`);
|
|
2166
|
+
|
|
2167
|
+
if (!selectedValue) return;
|
|
2168
|
+
|
|
2169
|
+
// Para multi-redirect fields
|
|
2170
|
+
if (fieldContainer.dataset.fieldType === 'checkbox_multi_redirect_field') {
|
|
2171
|
+
const configData = fieldContainer.dataset.fieldConfig;
|
|
2172
|
+
if (configData) {
|
|
2173
|
+
try {
|
|
2174
|
+
const config = JSON.parse(configData);
|
|
2175
|
+
const option = config.options.find(opt => opt.value === selectedValue);
|
|
2176
|
+
|
|
2177
|
+
if (option) {
|
|
2178
|
+
console.log(`Ação encontrada: ${option.action} para ${selectedValue}`);
|
|
2179
|
+
|
|
2180
|
+
// Limpar campos condicionais primeiro
|
|
2181
|
+
hideAllConditionalFields(fieldId);
|
|
2182
|
+
|
|
2183
|
+
switch(option.action) {
|
|
2184
|
+
case 'show_fields':
|
|
2185
|
+
showConditionalFields(fieldId, selectedValue);
|
|
2186
|
+
break;
|
|
2187
|
+
case 'skip_to_end':
|
|
2188
|
+
setTimeout(() => {
|
|
2189
|
+
const form = document.getElementById('wagtailForm');
|
|
2190
|
+
if (form) form.submit();
|
|
2191
|
+
}, (option.delay || 1) * 1000);
|
|
2192
|
+
break;
|
|
2193
|
+
case 'continue':
|
|
2194
|
+
console.log('Continuando normalmente');
|
|
2195
|
+
break;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
} catch(e) {
|
|
2199
|
+
console.error('Erro config multi-redirect:', e);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2166
2202
|
return;
|
|
2167
2203
|
}
|
|
2168
2204
|
|
|
2205
|
+
// Para smart navigation normal
|
|
2206
|
+
if (!navigationData[fieldId]) return;
|
|
2169
2207
|
const actionData = navigationData[fieldId][selectedValue];
|
|
2170
|
-
if (!actionData)
|
|
2171
|
-
return;
|
|
2172
|
-
}
|
|
2208
|
+
if (!actionData) return;
|
|
2173
2209
|
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2210
|
+
switch (actionData.action_type) {
|
|
2211
|
+
case 'jump_to_section':
|
|
2212
|
+
handleJumpToSection(actionData.target_section);
|
|
2213
|
+
break;
|
|
2214
|
+
case 'finish_form':
|
|
2215
|
+
handleFinishForm();
|
|
2216
|
+
break;
|
|
2217
|
+
}
|
|
2177
2218
|
}
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2219
|
+
|
|
2220
|
+
function showConditionalFields(fieldId, value) {
|
|
2221
|
+
console.log(`Mostrando campos condicionais para ${fieldId} = ${value}`);
|
|
2222
|
+
|
|
2223
|
+
// Primeiro: esconder TODOS os campos condicionais deste campo
|
|
2224
|
+
hideAllConditionalFields(fieldId);
|
|
2225
|
+
|
|
2226
|
+
// Segundo: mostrar apenas o campo específico para este valor
|
|
2227
|
+
const specificField = document.querySelector(
|
|
2228
|
+
`[data-parent-field="${fieldId}"][data-option-value="${value}"]`
|
|
2229
|
+
);
|
|
2230
|
+
|
|
2231
|
+
if (specificField) {
|
|
2232
|
+
specificField.style.display = 'block';
|
|
2233
|
+
|
|
2234
|
+
// Animação suave
|
|
2235
|
+
specificField.style.opacity = '0';
|
|
2236
|
+
specificField.style.transform = 'translateY(-10px)';
|
|
2237
|
+
|
|
2238
|
+
setTimeout(() => {
|
|
2239
|
+
specificField.style.transition = 'all 0.3s ease';
|
|
2240
|
+
specificField.style.opacity = '1';
|
|
2241
|
+
specificField.style.transform = 'translateY(0)';
|
|
2242
|
+
}, 10);
|
|
2243
|
+
|
|
2244
|
+
console.log(`✅ Campo condicional mostrado para valor: ${value}`);
|
|
2245
|
+
|
|
2246
|
+
// Scroll suave para o campo que apareceu
|
|
2247
|
+
setTimeout(() => {
|
|
2248
|
+
specificField.scrollIntoView({
|
|
2249
|
+
behavior: 'smooth',
|
|
2250
|
+
block: 'nearest'
|
|
2251
|
+
});
|
|
2252
|
+
}, 200);
|
|
2253
|
+
} else {
|
|
2254
|
+
console.log(`⚠️ Nenhum campo condicional encontrado para valor: ${value}`);
|
|
2255
|
+
}
|
|
2182
2256
|
}
|
|
2183
2257
|
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2258
|
+
function hideAllConditionalFields(fieldId) {
|
|
2259
|
+
// Esconder apenas os campos condicionais DESTE campo específico
|
|
2260
|
+
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
2261
|
+
|
|
2262
|
+
conditionalFields.forEach(field => {
|
|
2263
|
+
field.style.display = 'none';
|
|
2264
|
+
|
|
2265
|
+
// Limpar valores dos campos ocultos
|
|
2266
|
+
const inputs = field.querySelectorAll('input, select, textarea');
|
|
2267
|
+
inputs.forEach(input => {
|
|
2268
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2269
|
+
input.checked = false;
|
|
2270
|
+
} else {
|
|
2271
|
+
input.value = '';
|
|
2272
|
+
}
|
|
2273
|
+
input.required = false;
|
|
2274
|
+
});
|
|
2275
|
+
});
|
|
2276
|
+
|
|
2277
|
+
console.log(`Campos condicionais ocultos para: ${fieldId}`);
|
|
2187
2278
|
}
|
|
2279
|
+
|
|
2280
|
+
// SUBSTITUA as funções de campos condicionais por estas:
|
|
2281
|
+
|
|
2282
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
2283
|
+
console.log('DOM carregado - inicializando campos condicionais');
|
|
2284
|
+
|
|
2285
|
+
// Aguardar um pouco para garantir que tudo carregou
|
|
2286
|
+
setTimeout(() => {
|
|
2287
|
+
initializeAllConditionalFields();
|
|
2288
|
+
}, 500);
|
|
2289
|
+
});
|
|
2290
|
+
|
|
2291
|
+
function initializeAllConditionalFields() {
|
|
2292
|
+
// Campos conditional_field_condicional
|
|
2293
|
+
const triggers = document.querySelectorAll('select[data-field-id*="conditional_field_condicional"]');
|
|
2294
|
+
console.log(`Triggers encontrados: ${triggers.length}`);
|
|
2188
2295
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
break;
|
|
2296
|
+
triggers.forEach(trigger => {
|
|
2297
|
+
console.log(`Configurando trigger: ${trigger.id}`);
|
|
2298
|
+
|
|
2299
|
+
trigger.addEventListener('change', function() {
|
|
2300
|
+
const fieldId = this.dataset.fieldId;
|
|
2301
|
+
const selectedValue = this.value;
|
|
2196
2302
|
|
|
2197
|
-
|
|
2198
|
-
handleJumpToSection(actionData.target_section);
|
|
2199
|
-
break;
|
|
2303
|
+
console.log(`Mudança detectada: ${fieldId} = "${selectedValue}"`);
|
|
2200
2304
|
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2305
|
+
// Encontrar containers condicionais
|
|
2306
|
+
const containers = document.querySelectorAll(`[data-parent-field="${fieldId}"]`);
|
|
2307
|
+
console.log(`Containers encontrados: ${containers.length}`);
|
|
2308
|
+
|
|
2309
|
+
// Esconder todos primeiro
|
|
2310
|
+
containers.forEach(container => {
|
|
2311
|
+
container.style.display = 'none';
|
|
2312
|
+
console.log(`Ocultando container com triggerValue: ${container.dataset.triggerValue}`);
|
|
2313
|
+
});
|
|
2204
2314
|
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2315
|
+
// Mostrar apenas o correto
|
|
2316
|
+
if (selectedValue) {
|
|
2317
|
+
const targetContainer = document.querySelector(`[data-parent-field="${fieldId}"][data-trigger-value="${selectedValue}"]`);
|
|
2318
|
+
if (targetContainer) {
|
|
2319
|
+
targetContainer.style.display = 'block';
|
|
2320
|
+
console.log(`Mostrando container para: ${selectedValue}`);
|
|
2321
|
+
} else {
|
|
2322
|
+
console.log(`Container não encontrado para valor: ${selectedValue}`);
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2326
|
+
});
|
|
2327
|
+
|
|
2328
|
+
// Multi-redirect fields
|
|
2329
|
+
const multiRedirectGroups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
2330
|
+
console.log(`Multi-redirect groups: ${multiRedirectGroups.length}`);
|
|
2331
|
+
|
|
2332
|
+
multiRedirectGroups.forEach(group => {
|
|
2333
|
+
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
2334
|
+
const fieldId = group.dataset.fieldId;
|
|
2335
|
+
|
|
2336
|
+
inputs.forEach(input => {
|
|
2337
|
+
input.addEventListener('change', function() {
|
|
2338
|
+
const selectedValue = this.value;
|
|
2339
|
+
const configData = group.dataset.fieldConfig;
|
|
2340
|
+
|
|
2341
|
+
console.log(`Multi-redirect mudou: ${fieldId} = "${selectedValue}"`);
|
|
2342
|
+
|
|
2343
|
+
if (configData) {
|
|
2344
|
+
try {
|
|
2345
|
+
const config = JSON.parse(configData);
|
|
2346
|
+
const option = config.options.find(opt => opt.value === selectedValue);
|
|
2347
|
+
|
|
2348
|
+
if (option) {
|
|
2349
|
+
console.log(`Ação: ${option.action} para ${selectedValue}`);
|
|
2350
|
+
|
|
2351
|
+
// Mostrar mensagem se configurada
|
|
2352
|
+
if (option.message) {
|
|
2353
|
+
showRedirectMessage(fieldId, option, config.options.indexOf(option));
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
if (option.action === 'skip_to_end') {
|
|
2357
|
+
console.log('Finalizando formulário...');
|
|
2358
|
+
|
|
2359
|
+
// Mostrar mensagem por X segundos antes de finalizar
|
|
2360
|
+
const delay = (option.delay || 1) * 1000;
|
|
2361
|
+
|
|
2362
|
+
setTimeout(() => {
|
|
2363
|
+
const form = document.getElementById('wagtailForm');
|
|
2364
|
+
if (form) {
|
|
2365
|
+
form.submit();
|
|
2366
|
+
} else {
|
|
2367
|
+
console.log('Formulário não encontrado!');
|
|
2368
|
+
}
|
|
2369
|
+
}, delay);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
} catch(e) {
|
|
2373
|
+
console.error('Erro ao processar config:', e);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
});
|
|
2377
|
+
});
|
|
2378
|
+
});
|
|
2208
2379
|
}
|
|
2209
|
-
}
|
|
2210
2380
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2381
|
+
function showRedirectMessage(fieldId, option, optionIndex) {
|
|
2382
|
+
const blockId = fieldId.split('_').pop();
|
|
2383
|
+
const messageEl = document.getElementById(`redirect_message_${blockId}_${optionIndex}`);
|
|
2384
|
+
|
|
2385
|
+
if (messageEl) {
|
|
2386
|
+
messageEl.style.display = 'block';
|
|
2387
|
+
console.log(`Mensagem mostrada: ${option.message}`);
|
|
2388
|
+
|
|
2389
|
+
// Scroll para a mensagem
|
|
2390
|
+
setTimeout(() => {
|
|
2391
|
+
messageEl.scrollIntoView({
|
|
2392
|
+
behavior: 'smooth',
|
|
2393
|
+
block: 'center'
|
|
2394
|
+
});
|
|
2395
|
+
}, 100);
|
|
2396
|
+
} else {
|
|
2397
|
+
console.log(`Elemento de mensagem não encontrado: redirect_message_${blockId}_${optionIndex}`);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2222
2400
|
|
|
2223
|
-
|
|
2224
|
-
const
|
|
2401
|
+
function handleConditionalFieldFixed(triggerElement) {
|
|
2402
|
+
const fieldId = triggerElement.dataset.fieldId;
|
|
2403
|
+
const selectedValue = triggerElement.value;
|
|
2404
|
+
|
|
2405
|
+
console.log(`🎯 Campo condicional: ${fieldId} = "${selectedValue}"`);
|
|
2406
|
+
|
|
2407
|
+
// Encontrar APENAS os divs condicionais diretos
|
|
2408
|
+
const conditionalContainers = document.querySelectorAll(`div[data-parent-field="${fieldId}"]`);
|
|
2225
2409
|
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2410
|
+
console.log(`Containers encontrados: ${conditionalContainers.length}`);
|
|
2411
|
+
|
|
2412
|
+
conditionalContainers.forEach((container, index) => {
|
|
2413
|
+
const triggerValue = container.dataset.triggerValue;
|
|
2414
|
+
console.log(`Container ${index}: triggerValue="${triggerValue}", selectedValue="${selectedValue}"`);
|
|
2229
2415
|
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
sectionTitle.toLowerCase().includes(elementText.toLowerCase())) {
|
|
2416
|
+
if (selectedValue === triggerValue) {
|
|
2417
|
+
console.log(`✅ Mostrando container para valor: ${triggerValue}`);
|
|
2418
|
+
container.style.display = 'block';
|
|
2234
2419
|
|
|
2235
|
-
|
|
2420
|
+
// Reativar campos dentro do container
|
|
2421
|
+
const inputs = container.querySelectorAll('input, select, textarea');
|
|
2422
|
+
inputs.forEach(input => {
|
|
2423
|
+
if (input.dataset.wasRequired === 'true') {
|
|
2424
|
+
input.required = true;
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2427
|
+
} else {
|
|
2428
|
+
console.log(`❌ Ocultando container para valor: ${triggerValue}`);
|
|
2429
|
+
container.style.display = 'none';
|
|
2236
2430
|
|
|
2237
|
-
//
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
if (
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2431
|
+
// Desativar campos dentro do container
|
|
2432
|
+
const inputs = container.querySelectorAll('input, select, textarea');
|
|
2433
|
+
inputs.forEach(input => {
|
|
2434
|
+
if (!input.dataset.wasRequired) {
|
|
2435
|
+
input.dataset.wasRequired = input.required ? 'true' : 'false';
|
|
2436
|
+
}
|
|
2437
|
+
input.required = false;
|
|
2438
|
+
|
|
2439
|
+
// Limpar valores
|
|
2440
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2441
|
+
input.checked = false;
|
|
2442
|
+
} else {
|
|
2443
|
+
input.value = '';
|
|
2444
|
+
}
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
function initializeMultiRedirectFields() {
|
|
2451
|
+
const groups = document.querySelectorAll('.checkbox-multi-redirect-group');
|
|
2452
|
+
|
|
2453
|
+
groups.forEach(group => {
|
|
2454
|
+
const fieldId = group.dataset.fieldId;
|
|
2455
|
+
const inputs = group.querySelectorAll('.multi-redirect-input');
|
|
2456
|
+
|
|
2457
|
+
inputs.forEach(input => {
|
|
2458
|
+
input.addEventListener('change', function() {
|
|
2459
|
+
const selectedValue = this.value;
|
|
2460
|
+
|
|
2461
|
+
console.log(`Multi-redirect mudou: ${fieldId} = ${selectedValue}`);
|
|
2462
|
+
|
|
2463
|
+
// Limpar todos os campos condicionais deste grupo primeiro
|
|
2464
|
+
hideAllConditionalFields(fieldId);
|
|
2465
|
+
|
|
2466
|
+
// Se tem valor selecionado, mostrar campos específicos
|
|
2467
|
+
if (this.checked || (this.tagName === 'SELECT' && selectedValue)) {
|
|
2468
|
+
// Verificar se tem campos condicionais para esta opção
|
|
2469
|
+
const conditionalField = document.querySelector(
|
|
2470
|
+
`[data-parent-field="${fieldId}"][data-option-value="${selectedValue}"]`
|
|
2471
|
+
);
|
|
2255
2472
|
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2473
|
+
if (conditionalField) {
|
|
2474
|
+
conditionalField.style.display = 'block';
|
|
2475
|
+
console.log(`Mostrando campos condicionais para: ${selectedValue}`);
|
|
2476
|
+
|
|
2477
|
+
// Animação suave
|
|
2478
|
+
setTimeout(() => {
|
|
2479
|
+
conditionalField.scrollIntoView({
|
|
2480
|
+
behavior: 'smooth',
|
|
2481
|
+
block: 'nearest'
|
|
2482
|
+
});
|
|
2483
|
+
}, 200);
|
|
2484
|
+
} else {
|
|
2485
|
+
console.log(`Nenhum campo condicional configurado para: ${selectedValue}`);
|
|
2486
|
+
}
|
|
2260
2487
|
}
|
|
2261
|
-
}
|
|
2488
|
+
});
|
|
2489
|
+
});
|
|
2490
|
+
|
|
2491
|
+
console.log(`Multi-redirect configurado: ${fieldId}`);
|
|
2492
|
+
});
|
|
2493
|
+
|
|
2494
|
+
console.log(`Multi-redirect fields inicializados: ${groups.length}`);
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
function hideAllConditionalFields(fieldId) {
|
|
2498
|
+
// Esconder apenas os campos condicionais DESTE campo específico
|
|
2499
|
+
const conditionalFields = document.querySelectorAll(`[data-parent-field="${fieldId}"].multi-redirect-fields`);
|
|
2500
|
+
|
|
2501
|
+
conditionalFields.forEach(field => {
|
|
2502
|
+
field.style.display = 'none';
|
|
2503
|
+
|
|
2504
|
+
// Limpar valores dos campos ocultos
|
|
2505
|
+
const inputs = field.querySelectorAll('input, select, textarea');
|
|
2506
|
+
inputs.forEach(input => {
|
|
2507
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
2508
|
+
input.checked = false;
|
|
2509
|
+
} else {
|
|
2510
|
+
input.value = '';
|
|
2511
|
+
}
|
|
2512
|
+
input.required = false;
|
|
2513
|
+
});
|
|
2514
|
+
});
|
|
2515
|
+
|
|
2516
|
+
console.log(`Campos condicionais multi-redirect ocultos para: ${fieldId}`);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
// Função melhorada para redirecionar para seção específica
|
|
2520
|
+
function redirectToSpecificSection(sectionTitle) {
|
|
2521
|
+
console.log(`Procurando seção: "${sectionTitle}"`);
|
|
2522
|
+
|
|
2523
|
+
// Procurar por diferentes tipos de elementos que podem conter o título da seção
|
|
2524
|
+
const selectors = [
|
|
2525
|
+
'.divider-title',
|
|
2526
|
+
'.section-title',
|
|
2527
|
+
'[data-section-title]',
|
|
2528
|
+
'h2', 'h3', 'h4'
|
|
2529
|
+
];
|
|
2530
|
+
|
|
2531
|
+
for (let selector of selectors) {
|
|
2532
|
+
const elements = document.querySelectorAll(selector);
|
|
2533
|
+
|
|
2534
|
+
for (let element of elements) {
|
|
2535
|
+
const elementText = element.textContent?.trim() || '';
|
|
2536
|
+
const dataTitle = element.dataset.sectionTitle || '';
|
|
2262
2537
|
|
|
2263
|
-
|
|
2538
|
+
// Verificar se o texto corresponde (ignorando case e espaços extras)
|
|
2539
|
+
if (elementText.toLowerCase().includes(sectionTitle.toLowerCase()) ||
|
|
2540
|
+
dataTitle.toLowerCase().includes(sectionTitle.toLowerCase()) ||
|
|
2541
|
+
sectionTitle.toLowerCase().includes(elementText.toLowerCase())) {
|
|
2542
|
+
|
|
2543
|
+
console.log(`Seção encontrada: "${elementText}"`);
|
|
2544
|
+
|
|
2545
|
+
// Scroll suave para a seção
|
|
2546
|
+
setTimeout(() => {
|
|
2547
|
+
const formContent = document.getElementById('formContent');
|
|
2548
|
+
if (formContent) {
|
|
2549
|
+
const offset = 120;
|
|
2550
|
+
const elementPosition = element.getBoundingClientRect().top +
|
|
2551
|
+
formContent.scrollTop - offset;
|
|
2552
|
+
|
|
2553
|
+
formContent.scrollTo({
|
|
2554
|
+
top: elementPosition,
|
|
2555
|
+
behavior: 'smooth'
|
|
2556
|
+
});
|
|
2557
|
+
|
|
2558
|
+
// Destacar temporariamente a seção
|
|
2559
|
+
element.style.background = 'rgba(42, 94, 44, 0.1)';
|
|
2560
|
+
element.style.padding = '1rem';
|
|
2561
|
+
element.style.borderRadius = '8px';
|
|
2562
|
+
element.style.transition = 'all 0.3s ease';
|
|
2563
|
+
|
|
2564
|
+
setTimeout(() => {
|
|
2565
|
+
element.style.background = '';
|
|
2566
|
+
element.style.padding = '';
|
|
2567
|
+
}, 2000);
|
|
2568
|
+
}
|
|
2569
|
+
}, 100);
|
|
2570
|
+
|
|
2571
|
+
return true;
|
|
2572
|
+
}
|
|
2264
2573
|
}
|
|
2265
2574
|
}
|
|
2575
|
+
|
|
2576
|
+
console.log(`Seção "${sectionTitle}" não encontrada`);
|
|
2577
|
+
return false;
|
|
2266
2578
|
}
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
// ADICIONE esta função para debug
|
|
2585
|
+
window.testConditional = function() {
|
|
2586
|
+
console.log('=== TESTE MANUAL ===');
|
|
2587
|
+
|
|
2588
|
+
// Listar todos os selects
|
|
2589
|
+
const selects = document.querySelectorAll('select');
|
|
2590
|
+
console.log(`Total de selects: ${selects.length}`);
|
|
2591
|
+
|
|
2592
|
+
selects.forEach((select, i) => {
|
|
2593
|
+
console.log(`Select ${i}:`, {
|
|
2594
|
+
id: select.id,
|
|
2595
|
+
name: select.name,
|
|
2596
|
+
fieldId: select.dataset.fieldId,
|
|
2597
|
+
classes: select.className
|
|
2598
|
+
});
|
|
2599
|
+
});
|
|
2267
2600
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
}
|
|
2601
|
+
// Listar containers condicionais
|
|
2602
|
+
const containers = document.querySelectorAll('[data-parent-field]');
|
|
2603
|
+
console.log(`Containers condicionais: ${containers.length}`);
|
|
2604
|
+
|
|
2605
|
+
containers.forEach((container, i) => {
|
|
2606
|
+
console.log(`Container ${i}:`, {
|
|
2607
|
+
parentField: container.dataset.parentField,
|
|
2608
|
+
triggerValue: container.dataset.triggerValue,
|
|
2609
|
+
display: container.style.display
|
|
2610
|
+
});
|
|
2611
|
+
});
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
|
|
2615
|
+
|
|
2616
|
+
|
|
2617
|
+
|
|
2271
2618
|
</script>
|
|
2272
2619
|
|
|
2273
2620
|
|