wagtail-enap-designsystem 1.2.1.120__py3-none-any.whl → 1.2.1.122__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.

@@ -7045,48 +7045,6 @@ class CarouselResponsivoSnippetBlock(SnippetChooserBlock):
7045
7045
 
7046
7046
 
7047
7047
 
7048
- class Error404Block(StructBlock):
7049
- """Componente para página de erro 404"""
7050
-
7051
- titulo = CharBlock(
7052
- max_length=100,
7053
- default="Ops! Página não encontrada",
7054
- help_text="Título principal da página 404"
7055
- )
7056
-
7057
- subtitulo = CharBlock(
7058
- max_length=200,
7059
- default="A página que você está procurando não existe ou foi movida.",
7060
- help_text="Descrição do erro"
7061
- )
7062
-
7063
- mensagem_adicional = RichTextBlock(
7064
- required=False,
7065
- help_text="Texto adicional (opcional)"
7066
- )
7067
-
7068
- mostrar_busca = BooleanBlock(
7069
- default=True,
7070
- required=False,
7071
- help_text="Mostrar campo de busca"
7072
- )
7073
-
7074
- mostrar_links_uteis = BooleanBlock(
7075
- default=True,
7076
- required=False,
7077
- help_text="Mostrar links para páginas importantes"
7078
- )
7079
-
7080
- class Meta:
7081
- template = "enap_designsystem/blocks/error_404_block.html"
7082
- icon = "warning"
7083
- label = "Erro 404"
7084
- help_text = "Componente para página de erro 404"
7085
-
7086
-
7087
-
7088
-
7089
-
7090
7048
 
7091
7049
 
7092
7050
  class TimelineEtapaBlock(blocks.StructBlock):
@@ -4061,33 +4061,6 @@ class LiaPage(Page):
4061
4061
 
4062
4062
 
4063
4063
 
4064
- original_serve = Page.serve
4065
-
4066
- def custom_serve(self, request, *args, **kwargs):
4067
- """Override que captura TODOS os 404s do Wagtail"""
4068
- try:
4069
- return original_serve(self, request, *args, **kwargs)
4070
- except Http404:
4071
- print(f"🚨 404 capturado no models.py: {request.path}")
4072
-
4073
- context = {
4074
- 'request': request,
4075
- 'page_title': 'Página não encontrada - ENAP',
4076
- 'requested_path': request.path,
4077
- 'site': getattr(request, 'site', None)
4078
- }
4079
-
4080
- # 👇 AQUI VOCÊ ESCOLHE O TEMPLATE EXATO
4081
- template_name = 'errors/404.html'
4082
-
4083
- return render(request, template_name, context, status=404)
4084
-
4085
- # Substitui o método serve de TODAS as páginas Wagtail
4086
- Page.serve = custom_serve
4087
-
4088
- print("✅ Override de 404 ativado com template customizado!")
4089
-
4090
-
4091
4064
 
4092
4065
 
4093
4066
 
@@ -1187,8 +1187,9 @@
1187
1187
  <!-- CSRF Token -->
1188
1188
  <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
1189
1189
 
1190
+ // JavaScript corrigido - substituir no template HTML
1191
+
1190
1192
  <script>
1191
- // Sistema de Votação - Versão Corrigida e Otimizada
1192
1193
  const SistemaVotacao = {
1193
1194
  // Estado da aplicação
1194
1195
  votosCategoria: new Set(),
@@ -1198,31 +1199,23 @@ const SistemaVotacao = {
1198
1199
  configuracao: {
1199
1200
  votacaoAtiva: {% if votacao_ativa %}true{% else %}false{% endif %},
1200
1201
  totalCategorias: {{ total_categorias|default:0 }},
1201
- permitirMultiplosVotos: {% if page.permitir_multiplos_votos %}true{% else %}false{% endif %}
1202
+ permitirMultiplosVotos: {% if page.permitir_multiplos_votos %}true{% else %}false{% endif %},
1203
+ // URL corrigida - usar path absoluto
1204
+ urlVotar: '/votar/'
1202
1205
  },
1203
1206
 
1204
1207
  // Inicialização
1205
1208
  init() {
1206
1209
  console.log('🚀 Inicializando Sistema de Votação...');
1207
1210
 
1208
- // Cache dos elementos DOM
1209
1211
  this.cacheElementos();
1210
-
1211
- // Configurar tabs
1212
1212
  this.configurarTabs();
1213
-
1214
- // Configurar categorias
1215
1213
  this.configurarCategorias();
1216
-
1217
- // Configurar eventos dos modais
1218
1214
  this.configurarModais();
1219
-
1220
- // Configurar CSRF
1221
1215
  this.configurarCSRF();
1222
1216
 
1223
- console.log('✅ Sistema inicializado com sucesso');
1217
+ console.log('✅ Sistema inicializado');
1224
1218
  console.log('📊 Configuração:', this.configuracao);
1225
- console.log('🏷️ Categorias encontradas:', this.categoriasOrdem.length);
1226
1219
  },
1227
1220
 
1228
1221
  // Cache de elementos DOM
@@ -1233,7 +1226,6 @@ const SistemaVotacao = {
1233
1226
  progressoFill: document.getElementById('progresso-fill'),
1234
1227
  progressoStatus: document.getElementById('progresso-status'),
1235
1228
  progressoText: document.querySelector('.sistema-progresso-text'),
1236
- // Elementos do progresso no modal
1237
1229
  progressoFillModal: document.getElementById('progresso-fill-modal'),
1238
1230
  progressoStatusModal: document.getElementById('progresso-status-modal'),
1239
1231
  progressoTextModal: document.getElementById('progresso-text-modal'),
@@ -1242,19 +1234,16 @@ const SistemaVotacao = {
1242
1234
  previewProxima: document.getElementById('preview-proxima-categoria'),
1243
1235
  feedbackMessage: document.getElementById('feedback-message')
1244
1236
  };
1237
+
1238
+ console.log('DOM Elements cached:', Object.keys(this.elementos).length);
1245
1239
  },
1246
1240
 
1247
1241
  // Configurar sistema de tabs
1248
1242
  configurarTabs() {
1249
- console.log('🎯 Configurando tabs...');
1250
-
1251
1243
  this.elementos.tabButtons.forEach((button, index) => {
1252
1244
  const targetId = button.getAttribute('data-tab-target');
1253
1245
  const categoriaId = button.getAttribute('data-categoria-id');
1254
1246
 
1255
- console.log(`Tab ${index}: ${targetId} (categoria: ${categoriaId})`);
1256
-
1257
- // Adicionar event listener
1258
1247
  button.addEventListener('click', (e) => {
1259
1248
  e.preventDefault();
1260
1249
  this.trocarTab(targetId, button);
@@ -1264,8 +1253,6 @@ const SistemaVotacao = {
1264
1253
 
1265
1254
  // Trocar tab ativa
1266
1255
  trocarTab(targetId, clickedButton) {
1267
- console.log('🔄 Trocando tab para:', targetId);
1268
-
1269
1256
  const targetContent = document.getElementById(targetId);
1270
1257
 
1271
1258
  if (!targetContent) {
@@ -1302,13 +1289,10 @@ const SistemaVotacao = {
1302
1289
  icone: iconElement ? iconElement.className : 'fas fa-folder'
1303
1290
  });
1304
1291
  });
1305
-
1306
- console.log('🏷️ Categorias configuradas:', this.categoriasOrdem);
1307
1292
  },
1308
1293
 
1309
1294
  // Configurar modais
1310
1295
  configurarModais() {
1311
- // Fechar modal ao clicar fora
1312
1296
  if (this.elementos.modalPosVoto) {
1313
1297
  this.elementos.modalPosVoto.addEventListener('click', (e) => {
1314
1298
  if (e.target === this.elementos.modalPosVoto) {
@@ -1330,93 +1314,153 @@ const SistemaVotacao = {
1330
1314
  configurarCSRF() {
1331
1315
  const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]');
1332
1316
  if (!csrfToken) {
1333
- console.warn('⚠️ CSRF token não encontrado, criando...');
1334
- const token = document.createElement('input');
1335
- token.type = 'hidden';
1336
- token.name = 'csrfmiddlewaretoken';
1337
- token.value = '{{ csrf_token }}';
1338
- document.body.appendChild(token);
1317
+ console.warn('⚠️ CSRF token não encontrado');
1339
1318
  }
1340
1319
  },
1341
1320
 
1342
- // Função principal de votação
1321
+ // FUNÇÃO PRINCIPAL DE VOTAÇÃO - CORRIGIDA
1343
1322
  async votar(projetoId, categoriaId, button) {
1344
- console.log('🗳️ Votando...', { projetoId, categoriaId });
1323
+ console.log('🗳️ Iniciando votação...', { projetoId, categoriaId });
1345
1324
 
1346
1325
  if (!this.configuracao.votacaoAtiva) {
1347
1326
  this.showFeedback('Votação não está ativa no momento.', 'error');
1348
1327
  return;
1349
1328
  }
1350
1329
 
1330
+ // Verificar se botão já foi usado
1331
+ if (button.classList.contains('votado') || button.disabled) {
1332
+ this.showFeedback('Você já votou neste projeto.', 'warning');
1333
+ return;
1334
+ }
1335
+
1351
1336
  // Estado de loading
1352
1337
  this.setLoadingState(button, true);
1353
1338
 
1354
1339
  try {
1355
- const response = await fetch('{% url "votar_projeto" %}', {
1340
+ // Preparar dados
1341
+ const dados = {
1342
+ projeto_id: parseInt(projetoId),
1343
+ categoria_id: parseInt(categoriaId)
1344
+ };
1345
+
1346
+ console.log('📤 Enviando dados:', dados);
1347
+
1348
+ // Headers da requisição
1349
+ const headers = {
1350
+ 'Content-Type': 'application/json',
1351
+ };
1352
+
1353
+ // Adicionar CSRF token se disponível
1354
+ const csrfToken = this.getCsrfToken();
1355
+ if (csrfToken) {
1356
+ headers['X-CSRFToken'] = csrfToken;
1357
+ }
1358
+
1359
+ // Fazer requisição
1360
+ const response = await fetch(this.configuracao.urlVotar, {
1356
1361
  method: 'POST',
1357
- headers: {
1358
- 'Content-Type': 'application/json',
1359
- 'X-CSRFToken': this.getCsrfToken()
1360
- },
1361
- body: JSON.stringify({
1362
- projeto_id: projetoId,
1363
- categoria_id: categoriaId
1364
- })
1362
+ headers: headers,
1363
+ body: JSON.stringify(dados),
1364
+ credentials: 'same-origin'
1365
1365
  });
1366
1366
 
1367
- const data = await response.json();
1367
+ console.log('📥 Response status:', response.status);
1368
+
1369
+ // Verificar se response é válido
1370
+ if (!response.ok) {
1371
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
1372
+ }
1373
+
1374
+ // Parse do JSON
1375
+ let data;
1376
+ try {
1377
+ data = await response.json();
1378
+ console.log('📊 Response data:', data);
1379
+ } catch (parseError) {
1380
+ console.error('❌ Erro ao fazer parse do JSON:', parseError);
1381
+ throw new Error('Resposta inválida do servidor');
1382
+ }
1368
1383
 
1369
1384
  if (data.success) {
1370
1385
  this.processarVotoSucesso(projetoId, categoriaId, button, data);
1371
1386
  } else {
1372
- throw new Error(data.message || 'Erro ao registrar voto');
1387
+ throw new Error(data.message || 'Erro desconhecido ao registrar voto');
1373
1388
  }
1374
1389
 
1375
1390
  } catch (error) {
1376
- console.error('❌ Erro ao votar:', error);
1377
- this.showFeedback(error.message || 'Erro ao registrar voto. Tente novamente.', 'error');
1391
+ console.error('❌ Erro completo:', error);
1392
+ this.showFeedback(`Erro: ${error.message}`, 'error');
1378
1393
  this.setLoadingState(button, false);
1379
1394
  }
1380
1395
  },
1381
1396
 
1382
1397
  // Processar voto bem-sucedido
1383
1398
  processarVotoSucesso(projetoId, categoriaId, button, data) {
1384
- console.log('✅ Voto registrado com sucesso');
1399
+ console.log('✅ Voto processado com sucesso:', data);
1385
1400
 
1386
- // Atualizar contador se existir
1387
- const contador = document.getElementById(`votos-${projetoId}`);
1388
- if (contador) {
1389
- contador.textContent = data.total_votos || 0;
1390
- }
1391
-
1392
- // Marcar como votado
1401
+ // Atualizar visual do botão
1393
1402
  button.classList.add('votado');
1394
- button.textContent = 'Obrigado pelo seu voto!';
1403
+ button.innerHTML = `
1404
+ <i class="fas fa-check-circle"></i>
1405
+ Voto registrado!
1406
+ `;
1407
+ button.disabled = true;
1408
+
1409
+ // Atualizar contador se existir
1410
+ this.atualizarContador(projetoId, data.total_votos);
1395
1411
 
1396
- // Adicionar categoria aos votados
1397
- this.votosCategoria.add(categoriaId);
1412
+ // Marcar categoria como votada
1413
+ this.votosCategoria.add(parseInt(categoriaId));
1398
1414
  this.atualizarProgresso();
1399
1415
 
1400
- // Desabilitar outros botões se necessário
1416
+ // Desabilitar outros botões da categoria se necessário
1401
1417
  if (!this.configuracao.permitirMultiplosVotos) {
1402
1418
  this.desabilitarOutrosBotoes(categoriaId, button);
1403
1419
  }
1404
1420
 
1421
+ // Mostrar feedback
1422
+ this.showFeedback(`Voto registrado em "${data.projeto_titulo || 'projeto'}"!`, 'success');
1423
+
1405
1424
  // Mostrar próximo passo após delay
1406
1425
  setTimeout(() => {
1407
1426
  this.mostrarModalPosVoto(categoriaId);
1408
- }, 1500);
1427
+ }, 2000);
1428
+ },
1429
+
1430
+ // Atualizar contador de votos
1431
+ atualizarContador(projetoId, totalVotos) {
1432
+ const contadorElement = document.getElementById(`votos-${projetoId}`);
1433
+ if (contadorElement) {
1434
+ const novoTotal = totalVotos || 1;
1435
+ contadorElement.textContent = novoTotal;
1436
+
1437
+ // Animação
1438
+ contadorElement.style.transform = 'scale(1.2)';
1439
+ contadorElement.style.color = '#28a745';
1440
+
1441
+ setTimeout(() => {
1442
+ contadorElement.style.transform = 'scale(1)';
1443
+ contadorElement.style.color = '';
1444
+ }, 500);
1445
+ }
1409
1446
  },
1410
1447
 
1411
1448
  // Desabilitar outros botões da categoria
1412
1449
  desabilitarOutrosBotoes(categoriaId, buttonAtivo) {
1413
- const categoryButtons = document.querySelectorAll(`[data-categoria-id="${categoriaId}"] .sistema-btn-votar`);
1414
- categoryButtons.forEach(btn => {
1415
- if (btn !== buttonAtivo) {
1416
- btn.disabled = true;
1417
- btn.textContent = 'Você votou nesta categoria';
1418
- }
1419
- });
1450
+ const categorySection = document.getElementById(`categoria-${categoriaId}`);
1451
+ if (categorySection) {
1452
+ const outrosBotoes = categorySection.querySelectorAll('.sistema-btn-votar');
1453
+ outrosBotoes.forEach(btn => {
1454
+ if (btn !== buttonAtivo && !btn.classList.contains('votado')) {
1455
+ btn.disabled = true;
1456
+ btn.classList.add('disabled');
1457
+ btn.innerHTML = `
1458
+ <i class="fas fa-ban"></i>
1459
+ Você já votou nesta categoria
1460
+ `;
1461
+ }
1462
+ });
1463
+ }
1420
1464
  },
1421
1465
 
1422
1466
  // Estado de loading do botão
@@ -1424,11 +1468,14 @@ const SistemaVotacao = {
1424
1468
  if (loading) {
1425
1469
  button.classList.add('loading');
1426
1470
  button.disabled = true;
1427
- button.textContent = 'Votando...';
1428
- } else {
1471
+ button.innerHTML = `
1472
+ <i class="fas fa-spinner fa-spin"></i>
1473
+ Votando...
1474
+ `;
1475
+ } else if (!button.classList.contains('votado')) {
1429
1476
  button.classList.remove('loading');
1430
1477
  button.disabled = false;
1431
- button.textContent = 'Votar neste Projeto';
1478
+ button.innerHTML = 'Votar neste Projeto';
1432
1479
  }
1433
1480
  },
1434
1481
 
@@ -1440,13 +1487,16 @@ const SistemaVotacao = {
1440
1487
  if (proximoIndice < this.categoriasOrdem.length) {
1441
1488
  this.proximaCategoriaData = this.categoriasOrdem[proximoIndice];
1442
1489
  this.gerarPreviewProximaCategoria(this.proximaCategoriaData.id);
1443
- this.elementos.modalPosVoto.classList.add('show');
1490
+
1491
+ if (this.elementos.modalPosVoto) {
1492
+ this.elementos.modalPosVoto.classList.add('show');
1493
+ }
1444
1494
  } else {
1445
1495
  this.mostrarModalConclusao();
1446
1496
  }
1447
1497
  },
1448
1498
 
1449
- // Gerar preview da próxima categoria - VERSÃO SEM LIMITE
1499
+ // Gerar preview da próxima categoria
1450
1500
  gerarPreviewProximaCategoria(proximaCategoriaId) {
1451
1501
  const proximaCategoria = document.getElementById(`categoria-${proximaCategoriaId}`);
1452
1502
  const projetos = proximaCategoria ? proximaCategoria.querySelectorAll('.sistema-projeto-card') : [];
@@ -1466,7 +1516,6 @@ const SistemaVotacao = {
1466
1516
  <div class="sistema-preview-projetos">
1467
1517
  `;
1468
1518
 
1469
- // Mostrar TODOS os projetos (sem limite)
1470
1519
  projetos.forEach(projeto => {
1471
1520
  const titulo = projeto.querySelector('.sistema-projeto-title')?.textContent || 'Projeto';
1472
1521
  const equipe = projeto.querySelector('.sistema-equipe-nome')?.textContent || 'Equipe';
@@ -1480,18 +1529,6 @@ const SistemaVotacao = {
1480
1529
  });
1481
1530
 
1482
1531
  previewHTML += `</div>`;
1483
- } else {
1484
- previewHTML = `
1485
- <div class="sistema-preview-header">
1486
- <div class="sistema-preview-icon">
1487
- <i class="fas fa-info-circle"></i>
1488
- </div>
1489
- <h4 class="sistema-preview-title">Próxima categoria disponível</h4>
1490
- </div>
1491
- <p style="text-align: center; color: var(--votacao-text-muted); margin: 1rem 0;">
1492
- Explore mais projetos na próxima categoria!
1493
- </p>
1494
- `;
1495
1532
  }
1496
1533
 
1497
1534
  if (this.elementos.previewProxima) {
@@ -1501,48 +1538,38 @@ const SistemaVotacao = {
1501
1538
 
1502
1539
  // Continuar votação
1503
1540
  continuarVotacao() {
1504
- this.elementos.modalPosVoto.classList.remove('show');
1541
+ if (this.elementos.modalPosVoto) {
1542
+ this.elementos.modalPosVoto.classList.remove('show');
1543
+ }
1505
1544
 
1506
1545
  if (this.proximaCategoriaData) {
1507
1546
  const proximaTab = document.querySelector(`[data-categoria-id="${this.proximaCategoriaData.id}"]`);
1508
1547
  if (proximaTab) {
1509
1548
  proximaTab.click();
1510
-
1511
- setTimeout(() => {
1512
- const categoriaHeader = document.querySelector('.sistema-categoria-header');
1513
- if (categoriaHeader) {
1514
- categoriaHeader.scrollIntoView({
1515
- behavior: 'smooth',
1516
- block: 'start'
1517
- });
1518
- }
1519
- }, 100);
1520
1549
  }
1521
1550
  }
1522
1551
  },
1523
1552
 
1524
1553
  // Parar votação
1525
1554
  pararVotacao() {
1526
- this.elementos.modalPosVoto.classList.remove('show');
1527
- this.showFeedback('Obrigado pela sua participação na votação!', 'success');
1555
+ if (this.elementos.modalPosVoto) {
1556
+ this.elementos.modalPosVoto.classList.remove('show');
1557
+ }
1558
+ this.showFeedback('Obrigado pela sua participação!', 'success');
1528
1559
  },
1529
1560
 
1530
1561
  // Mostrar modal de conclusão
1531
1562
  mostrarModalConclusao() {
1532
- const totalProjetos = document.querySelectorAll('.sistema-projeto-card').length;
1533
- const projetosElement = document.getElementById('total-projetos-visualizados');
1534
- if (projetosElement) {
1535
- projetosElement.textContent = totalProjetos;
1563
+ if (this.elementos.modalConclusao) {
1564
+ this.elementos.modalConclusao.classList.add('show');
1536
1565
  }
1537
-
1538
- this.elementos.modalConclusao.classList.add('show');
1539
1566
  },
1540
1567
 
1541
1568
  // Reiniciar votação
1542
1569
  reiniciarVotacao() {
1543
- console.log('🔄 Reiniciando votação...');
1544
-
1545
- this.elementos.modalConclusao.classList.remove('show');
1570
+ if (this.elementos.modalConclusao) {
1571
+ this.elementos.modalConclusao.classList.remove('show');
1572
+ }
1546
1573
 
1547
1574
  // Reset estado
1548
1575
  this.votosCategoria.clear();
@@ -1551,34 +1578,33 @@ const SistemaVotacao = {
1551
1578
  // Reset botões
1552
1579
  const botoesVotar = document.querySelectorAll('.sistema-btn-votar');
1553
1580
  botoesVotar.forEach(botao => {
1554
- botao.classList.remove('votado', 'loading');
1581
+ botao.classList.remove('votado', 'loading', 'disabled');
1555
1582
  botao.disabled = false;
1556
1583
  botao.textContent = 'Votar neste Projeto';
1557
1584
  });
1558
1585
 
1559
- // Reset progresso
1560
1586
  this.atualizarProgresso();
1561
1587
 
1562
- // Voltar primeira tab
1563
1588
  const primeiraTab = document.querySelector('.sistema-tab-button');
1564
1589
  if (primeiraTab) {
1565
1590
  primeiraTab.click();
1566
1591
  }
1567
1592
 
1568
- window.scrollTo({ top: 0, behavior: 'smooth' });
1569
- this.showFeedback('Nova votação iniciada! Vote novamente.', 'success');
1593
+ this.showFeedback('Nova votação iniciada!', 'success');
1570
1594
  },
1571
1595
 
1572
1596
  // Encerrar definitivo
1573
1597
  encerrarDefinitivo() {
1574
- this.elementos.modalConclusao.classList.remove('show');
1575
- this.showFeedback('Obrigado pela sua participação na votação!', 'success');
1598
+ if (this.elementos.modalConclusao) {
1599
+ this.elementos.modalConclusao.classList.remove('show');
1600
+ }
1601
+ this.showFeedback('Obrigado pela sua participação!', 'success');
1576
1602
  },
1577
1603
 
1578
1604
  // Finalizar votação
1579
1605
  finalizarVotacao() {
1580
1606
  if (this.votosCategoria.size === 0) {
1581
- this.showFeedback('Você ainda não votou em nenhuma categoria.', 'error');
1607
+ this.showFeedback('Você ainda não votou em nenhuma categoria.', 'warning');
1582
1608
  return;
1583
1609
  }
1584
1610
 
@@ -1586,18 +1612,12 @@ const SistemaVotacao = {
1586
1612
 
1587
1613
  let mensagem = 'Tem certeza que deseja finalizar sua votação?';
1588
1614
  if (categoriasRestantes > 0) {
1589
- mensagem += `\n\nAinda há ${categoriasRestantes} categoria${categoriasRestantes > 1 ? 's' : ''} para conhecer.`;
1615
+ mensagem += `\n\nAinda há ${categoriasRestantes} categoria${categoriasRestantes > 1 ? 's' : ''} disponíveis.`;
1590
1616
  }
1591
- mensagem += '\n\nA página será recarregada para iniciar uma nova votação.';
1592
1617
 
1593
1618
  if (confirm(mensagem)) {
1594
- // Mostrar feedback antes de recarregar
1595
- this.showFeedback('Obrigado pela sua participação! Recarregando...', 'success');
1596
-
1597
- // Recarregar a página após um pequeno delay
1598
- setTimeout(() => {
1599
- window.location.reload();
1600
- }, 1500);
1619
+ this.showFeedback('Obrigado pela participação! Recarregando...', 'success');
1620
+ setTimeout(() => window.location.reload(), 1500);
1601
1621
  }
1602
1622
  },
1603
1623
 
@@ -1606,40 +1626,32 @@ const SistemaVotacao = {
1606
1626
  const votadas = this.votosCategoria.size;
1607
1627
  const percentual = Math.round((votadas / this.configuracao.totalCategorias) * 100);
1608
1628
 
1609
- // Atualizar barra principal
1610
- if (this.elementos.progressoFill) {
1611
- this.elementos.progressoFill.style.width = `${percentual}%`;
1612
- }
1613
- if (this.elementos.progressoStatus) {
1614
- this.elementos.progressoStatus.textContent = `${votadas} de ${this.configuracao.totalCategorias} categorias`;
1615
- }
1616
- if (this.elementos.progressoText) {
1617
- this.elementos.progressoText.textContent = `${percentual}% concluído`;
1618
- }
1619
-
1620
- // Atualizar barra do modal
1621
- if (this.elementos.progressoFillModal) {
1622
- this.elementos.progressoFillModal.style.width = `${percentual}%`;
1623
- }
1624
- if (this.elementos.progressoStatusModal) {
1625
- this.elementos.progressoStatusModal.textContent = `${votadas} de ${this.configuracao.totalCategorias} categorias`;
1626
- }
1627
- if (this.elementos.progressoTextModal) {
1628
- this.elementos.progressoTextModal.textContent = `${percentual}% concluído`;
1629
- }
1629
+ // Atualizar elementos de progresso
1630
+ const elementos = [
1631
+ { fill: this.elementos.progressoFill, status: this.elementos.progressoStatus, text: this.elementos.progressoText },
1632
+ { fill: this.elementos.progressoFillModal, status: this.elementos.progressoStatusModal, text: this.elementos.progressoTextModal }
1633
+ ];
1634
+
1635
+ elementos.forEach(({ fill, status, text }) => {
1636
+ if (fill) fill.style.width = `${percentual}%`;
1637
+ if (status) status.textContent = `${votadas} de ${this.configuracao.totalCategorias} categorias`;
1638
+ if (text) text.textContent = `${percentual}% concluído`;
1639
+ });
1630
1640
  },
1631
1641
 
1632
1642
  // Mostrar feedback
1633
1643
  showFeedback(message, type = 'success') {
1634
- if (!this.elementos.feedbackMessage) return;
1644
+ if (!this.elementos.feedbackMessage) {
1645
+ console.log(`Feedback: ${message} (${type})`);
1646
+ return;
1647
+ }
1635
1648
 
1636
1649
  this.elementos.feedbackMessage.textContent = message;
1637
- this.elementos.feedbackMessage.className = `sistema-feedback-message ${type}`;
1638
- this.elementos.feedbackMessage.classList.add('show');
1650
+ this.elementos.feedbackMessage.className = `sistema-feedback-message ${type} show`;
1639
1651
 
1640
1652
  setTimeout(() => {
1641
1653
  this.elementos.feedbackMessage.classList.remove('show');
1642
- }, 3000);
1654
+ }, 4000);
1643
1655
  },
1644
1656
 
1645
1657
  // Obter CSRF token
@@ -1658,50 +1670,18 @@ const SistemaVotacao = {
1658
1670
  }
1659
1671
  }
1660
1672
 
1673
+ console.warn('⚠️ CSRF token não encontrado');
1661
1674
  return '';
1662
- },
1663
-
1664
- // Debug - testar funcionalidades
1665
- debug: {
1666
- testarTab(categoriaId) {
1667
- const button = document.querySelector(`[data-categoria-id="${categoriaId}"]`);
1668
- if (button) {
1669
- console.log('🧪 Testando clique na categoria:', categoriaId);
1670
- button.click();
1671
- } else {
1672
- console.error('❌ Botão não encontrado para categoria:', categoriaId);
1673
- }
1674
- },
1675
-
1676
- infoTabs() {
1677
- console.log('=== DEBUG TABS ===');
1678
- console.log('Botões:', document.querySelectorAll('.sistema-tab-button').length);
1679
- console.log('Conteúdos:', document.querySelectorAll('.sistema-tab-content').length);
1680
-
1681
- document.querySelectorAll('.sistema-tab-button').forEach((btn, i) => {
1682
- console.log(`Botão ${i}:`, {
1683
- target: btn.getAttribute('data-tab-target'),
1684
- categoriaId: btn.getAttribute('data-categoria-id'),
1685
- ativo: btn.classList.contains('active')
1686
- });
1687
- });
1688
- },
1689
-
1690
- infoEstado() {
1691
- console.log('=== ESTADO ATUAL ===');
1692
- console.log('Votos por categoria:', Array.from(SistemaVotacao.votosCategoria));
1693
- console.log('Configuração:', SistemaVotacao.configuracao);
1694
- console.log('Categorias:', SistemaVotacao.categoriasOrdem);
1695
- }
1696
1675
  }
1697
1676
  };
1698
1677
 
1699
- // Inicialização quando DOM carregar
1678
+ // Inicialização
1700
1679
  document.addEventListener('DOMContentLoaded', function() {
1680
+ console.log('📄 DOM carregado, inicializando sistema...');
1701
1681
  SistemaVotacao.init();
1702
1682
  });
1703
1683
 
1704
- // Expor funções globalmente para compatibilidade
1684
+ // Expor globalmente
1705
1685
  window.SistemaVotacao = SistemaVotacao;
1706
1686
  </script>
1707
1687
  {% endblock %}