@golstats/gsc-timeline-reports 1.0.9 → 1.0.11

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.
@@ -364,19 +364,29 @@ async function fetchGameData() {
364
364
  .map((minute) => {
365
365
  if (!minute.event) return minute
366
366
 
367
- // Filtrar eventos según las props
367
+ // Filtrar eventos según las props de manera simple
368
368
  const filteredEvents = minute.event.filter((event) => {
369
- // Crear un objeto temporal con la estructura que espera shouldShowEvent
370
- const tempEvent = {
371
- event_type_id: getEventTypeFromIcon(event.icon),
372
- category_id: getCategoryFromIcon(event.icon),
373
- minute: event.minute,
374
- match_lapse: event.match_lapse,
375
- team_id: event.team === 'local' ? props.homeTeam : props.awayTeam,
376
- comments: '',
369
+ // Goles
370
+ if (event.icon === 'icon-goal' && !props.goals) {
371
+ return false
377
372
  }
378
373
 
379
- return shouldShowEvent(tempEvent)
374
+ // Tarjetas amarillas
375
+ if (event.icon === 'icon-yellow-card' && !props.yellowCards) {
376
+ return false
377
+ }
378
+
379
+ // Tarjetas rojas
380
+ if (event.icon === 'icon-red-card' && !props.redCards) {
381
+ return false
382
+ }
383
+
384
+ // Cambios
385
+ if (event.icon === 'icon-change' && !props.substitutions) {
386
+ return false
387
+ }
388
+
389
+ return true
380
390
  })
381
391
 
382
392
  return {
@@ -399,8 +409,9 @@ async function fetchGameData() {
399
409
  rightHandlePosition.value = filteredDummyEvents.length - 1
400
410
  secondHalfEndMinute.value = filteredDummyEvents[filteredDummyEvents.length - 1].minute
401
411
  minTotal.value = filteredDummyEvents[filteredDummyEvents.length - 1].minute
412
+ updateRangeWidth()
402
413
  }
403
- updateRangeWidth()
414
+
404
415
  return
405
416
  }
406
417
  try {
@@ -575,28 +586,6 @@ async function fetchGameData() {
575
586
  }
576
587
  }
577
588
 
578
- // Función para obtener el tipo de evento desde el ícono (para datos dummy)
579
- function getEventTypeFromIcon(icon) {
580
- const iconToEventType = {
581
- 'icon-goal': 1,
582
- 'icon-yellow-card': 2,
583
- 'icon-red-card': 9,
584
- 'icon-change': 10,
585
- }
586
- return iconToEventType[icon] || 1
587
- }
588
-
589
- // Función para obtener la categoría desde el ícono (para datos dummy)
590
- function getCategoryFromIcon(icon) {
591
- const iconToCategory = {
592
- 'icon-goal': 3,
593
- 'icon-yellow-card': 9,
594
- 'icon-red-card': 9,
595
- 'icon-change': 10,
596
- }
597
- return iconToCategory[icon] || 3
598
- }
599
-
600
589
  // Función para determinar el icono según el tipo de evento
601
590
  function getEventIcon(eventTypeId, event) {
602
591
  const iconMap = {
@@ -627,18 +616,9 @@ function getEventIcon(eventTypeId, event) {
627
616
 
628
617
  // Función para filtrar eventos según las props de visibilidad
629
618
  function shouldShowEvent(event) {
630
- // Debug: mostrar las props actuales
631
- console.log('Props actuales:', {
632
- goals: props.goals,
633
- yellowCards: props.yellowCards,
634
- redCards: props.redCards,
635
- substitutions: props.substitutions,
636
- })
637
-
638
619
  // Goles: event_type_id === 1 o category_id === 3 o category_id === 13
639
620
  if (event.event_type_id === 1 || event.category_id === 3 || event.category_id === 13) {
640
621
  if (!props.goals) {
641
- console.log('Filtrando gol:', event)
642
622
  return false
643
623
  }
644
624
  return true
@@ -647,7 +627,6 @@ function shouldShowEvent(event) {
647
627
  // Tarjetas amarillas: event_type_id === 2 o category_id === 9 (pero no rojas)
648
628
  if (event.event_type_id === 2 || (event.category_id === 9 && !event.comments?.includes('roja'))) {
649
629
  if (!props.yellowCards) {
650
- console.log('Filtrando tarjeta amarilla:', event)
651
630
  return false
652
631
  }
653
632
  return true
@@ -656,7 +635,6 @@ function shouldShowEvent(event) {
656
635
  // Tarjetas rojas: category_id === 9 con comentario que incluya "roja"
657
636
  if (event.category_id === 9 && event.comments?.includes('roja')) {
658
637
  if (!props.redCards) {
659
- console.log('Filtrando tarjeta roja:', event)
660
638
  return false
661
639
  }
662
640
  return true
@@ -665,7 +643,6 @@ function shouldShowEvent(event) {
665
643
  // Cambios: category_id === 10
666
644
  if (event.category_id === 10) {
667
645
  if (!props.substitutions) {
668
- console.log('Filtrando cambio:', event)
669
646
  return false
670
647
  }
671
648
  return true
@@ -677,14 +654,6 @@ function shouldShowEvent(event) {
677
654
 
678
655
  // Observar cambios en el tamaño de la ventana
679
656
  onMounted(() => {
680
- // Debug: verificar que las props estén llegando
681
- console.log('gsc-timeline.vue - Props recibidas:', {
682
- goals: props.goals,
683
- yellowCards: props.yellowCards,
684
- redCards: props.redCards,
685
- substitutions: props.substitutions,
686
- })
687
-
688
657
  calculateMaxMinute()
689
658
  updateContainerWidth()
690
659
  fetchGameData()
@@ -1070,6 +1039,30 @@ function getPositionByIndex(index) {
1070
1039
  return `${position}px`
1071
1040
  }
1072
1041
 
1042
+ // Función para calcular el ancho de la línea basado en el último evento
1043
+ function getLineWidth() {
1044
+ const totalPositions = timelineMinutes.value.length
1045
+ if (totalPositions === 0) return '0px'
1046
+ if (totalPositions === 1) return '0px'
1047
+
1048
+ // Encontrar el último evento real (el que tiene contenido)
1049
+ let lastEventIndex = totalPositions - 1
1050
+ for (let i = totalPositions - 1; i >= 0; i--) {
1051
+ if (timelineMinutes.value[i] && timelineMinutes.value[i].event) {
1052
+ lastEventIndex = i
1053
+ break
1054
+ }
1055
+ }
1056
+
1057
+ // Calcular la posición exacta del último evento en píxeles
1058
+ const lastEventPosition = (lastEventIndex / (totalPositions - 1)) * (props.timelineWidth - 40)
1059
+
1060
+ // Ajustar para que la línea termine exactamente en el centro del último evento
1061
+ const adjustedWidth = lastEventPosition + 10 // 10px para centrar en el evento
1062
+
1063
+ return `${adjustedWidth}px`
1064
+ }
1065
+
1073
1066
  // Inicia el arrastre de los handles
1074
1067
  function startDrag(handle, event) {
1075
1068
  event.preventDefault() // Previene selección de texto
@@ -1780,7 +1773,7 @@ function incrementMinStart() {
1780
1773
 
1781
1774
  <!-- Línea de tiempo única -->
1782
1775
  <div class="timeline-line">
1783
- <div class="line"></div>
1776
+ <div class="line" :style="{ width: getLineWidth() }"></div>
1784
1777
 
1785
1778
  <!-- Marcador inicial fijo (minuto 0) -->
1786
1779
  <span
@@ -2516,11 +2509,10 @@ function incrementMinStart() {
2516
2509
  .line {
2517
2510
  position: absolute;
2518
2511
  top: 50%;
2519
- left: 48%;
2520
- width: 98%;
2512
+ left: 0;
2521
2513
  height: 2px;
2522
2514
  background: #3a6081;
2523
- transform: translate(-50%, -50%);
2515
+ transform: translateY(-50%);
2524
2516
  border-radius: 2px;
2525
2517
  }
2526
2518
  .event {
@@ -2655,17 +2647,17 @@ function incrementMinStart() {
2655
2647
  }
2656
2648
  .minute-ball-edge {
2657
2649
  z-index: 4;
2658
- border: none;
2650
+ border: 1px solid #cbee6b;
2659
2651
  }
2660
2652
  .minute-ball-initial {
2661
2653
  z-index: 2;
2662
- border: 1px solid #4b80ae;
2654
+ border: 1px solid #cbee6b;
2663
2655
  background-color: #0d1d29;
2664
2656
  color: #fff;
2665
2657
  font-weight: bold;
2666
2658
  font-size: 10px;
2667
2659
  }
2668
- .minute-ball:not(.minute-ball-edge) {
2660
+ .minute-ball:not(.minute-ball-edge):not(.minute-ball-initial) {
2669
2661
  border: solid 1px #4b80ae;
2670
2662
  }
2671
2663
  .range-dot {