Skip to content

Commit

Permalink
🐛 Graficar listas de colectivos
Browse files Browse the repository at this point in the history
  • Loading branch information
anattolia committed Oct 22, 2024
1 parent ecb47f7 commit bf1dc2f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
15 changes: 8 additions & 7 deletions aplicaciones/www/src/components/VistaGraficas.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script setup lang="ts">
import { onMounted, ref, watch, type Ref } from 'vue';
import { convertirEscala } from '@enflujo/alquimia';
import type { ElementoLista, Listas, ListasColectivos } from '../../../../tipos/compartidos';
import type { ElementoLista, ListasPublicaciones, ListasColectivos } from '../../../../tipos/compartidos';
import { usarCerebro } from '@/utilidades/cerebro';
import { storeToRefs } from 'pinia';
/* defineProps<{
id: keyof Listas | ListasColectivos;
lista: ElementoLista[];
}>(); */
// Pasarle como prop en qué vista estamos (colectivos o publicaciones) para que cargue los datos de las listas correspondientes
const { vista } = defineProps<{
vista: String;
}>();
let listas: { [llave: string]: ElementoLista[] } = {};
const cerebro = usarCerebro();
Expand All @@ -31,9 +31,10 @@ watch(listaElegida, (llaveLista) => {
});
onMounted(async () => {
// POR HACER: Arreglar para que funcione con listas colectivos también
try {
const datosListas = await fetch('datos/listas.json').then((res) => res.json());
const datosListas: ListasPublicaciones | ListasColectivos = await fetch(`datos/${vista}.json`).then((res) =>
res.json()
);
if (datosListas) {
// Lista que se muestra al cargar el componente
listaVisible.value = datosListas.años;
Expand Down
2 changes: 1 addition & 1 deletion aplicaciones/www/src/views/VistaColectivos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function elegirVista(vistaElegida: string) {
<ListasColectivos />

<div v-if="vista === 'grafica'">
<VistaGraficas />
<VistaGraficas vista="listasColectivos" />
</div>

<div v-else="vista === 'mapa'">
Expand Down
2 changes: 1 addition & 1 deletion aplicaciones/www/src/views/VistaPublicaciones.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function elegirVista(vistaElegida: string) {
<ListasPublicaciones />

<div v-if="vista === 'grafica'">
<VistaGraficas />
<VistaGraficas vista="listas" />
</div>

<div v-else="vista === 'mapa'">
Expand Down
9 changes: 6 additions & 3 deletions tipos/compartidos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface Subindicador {
export type DefinicionSimple = { nombre: string; slug: string };
export type Año = { año: number; valor: string };

export type ListasColectivos = {
/* export type ListasColectivos = {
años: ElementoLista[];
estados: ElementoLista[];
tipos: ElementoLista[];
Expand All @@ -44,7 +44,7 @@ export type ListasColectivos = {
modalidades: ElementoLista[];
indicadores: ElementoListaIndicadores[];
subindicadores: ElementoLista[];
};
}; */

export type LlavesPA = 'autores' | 'años' | 'tipos' | 'dependencias' | 'indicadores' | 'subindicadores';

Expand All @@ -53,7 +53,6 @@ export type ListasPublicaciones = {
};

export type LlavesColectivos =
| 'responsables'
| 'tipos'
| 'años'
| 'sedes'
Expand All @@ -62,6 +61,10 @@ export type LlavesColectivos =
| 'indicadores'
| 'subindicadores';

export type ListasColectivos = {
[llave in LlavesColectivos]: ElementoLista[];
};

export type CamposPA = { llave: LlavesPA; indice: number }[];
export type CamposColectivos = { llave: LlavesColectivos; indice: number }[];

Expand Down

0 comments on commit bf1dc2f

Please sign in to comment.