-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Deploying ocial-app with
|
Latest commit: |
4bd6584
|
Status: | ✅ Deploy successful! |
Preview URL: | https://9100cd01.ocial-app.pages.dev |
Branch Preview URL: | https://feat-77-event-popup.ocial-app.pages.dev |
bc16d05
to
bb38934
Compare
src/components/LMap.vue
Outdated
const { t } = useI18n(); | ||
const { data: eventList } = await useEvent(EventApi, 'eventListList')(); | ||
|
||
console.log(eventList.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(eventList.value); |
src/components/LMap.vue
Outdated
throw new Error(`Categoría desconocida: ${categoryName}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto quizás mejor usar console.error
para que no pete el componente entero (o manejar la excepción en alguna otra parte de forma elegantemente
)
src/components/LMap.vue
Outdated
const categoryIconMap: { [key in CategoryEnum]: string } = { | ||
[CategoryEnum.NUMBER_0]: Azul, | ||
[CategoryEnum.NUMBER_1]: Verde, | ||
[CategoryEnum.NUMBER_2]: Rojo, | ||
[CategoryEnum.NUMBER_3]: Morado, | ||
[CategoryEnum.NUMBER_4]: Amarillo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Para que lo sepas, no bloqueante) Ahora mismo en back está arreglado ya (necesito que se mergee ispp-2324-ocial/backend#56 para que sea 100% automático)
Cuando se actualice, CategoryEnum tendrá las categorías reales y no NUMBER_X
src/components/LMap.vue
Outdated
@@ -62,18 +100,29 @@ onBeforeUnmount(() => { | |||
*/ | |||
function setMarkers(): void { | |||
if (mapInstance.value) { | |||
for (const mapMarker of props.markers) { | |||
for (const event of eventList.value) { | |||
const category = event.category === undefined ? CategoryEnum.NUMBER_0 : getCategoryEnum(event.category.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aquí igual en vez de tener esto, puedes hacer que el parámetro categoryName
sea opcional (categoryName?: string)
y en default devuelves el CategoryEnum.NUMBER_O.
src/components/LMap.vue
Outdated
const popupContent = ` | ||
<div> | ||
<strong>${t('Evento')}:</strong> ${event.name}<br> | ||
<strong>${t('Lugar')}:</strong> ${event.place}<br> | ||
<strong>${t('Fecha')}:</strong> ${event.date}<br> | ||
<strong>${t('Hora')}:</strong> ${eventHour}<br> | ||
<strong>${t('Capacidad')}:</strong> ${event.capacity}<br> | ||
<a href="/detalles/${event.id}">${t('Ver detalles')}</a> | ||
</div> | ||
`; | ||
|
||
marker([event.latitude, event.longitude], { icon: customIcon }) | ||
.addTo(mapInstance.value) | ||
.bindPopup(popupContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto no hay alguna otra forma en Leaflet de saberlo mediante una clase o algo?
Podríamos envolver todo esto con Teleport:
https://vuejs.org/guide/built-ins/teleport.html#teleport
Y cuando un usuario abra un popup, activar el Teleport al elemento del popup que sea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He añadido he importado ahora un Popup del propio leaflet que se puede añadir y cambiar cuando añadamos las valoraciones se me ocurre
src/components/LMap.vue
Outdated
const { t } = useI18n(); | ||
const { data: eventList } = await useEvent(EventApi, 'eventListList')(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si ya hacemos el fetch de los datos en el componente padre, por qué es necesario repetirlo aquí?
src/components/LMap.vue
Outdated
const popupContent = document.createElement('div'); | ||
|
||
popupContent.innerHTML = ` | ||
<strong>${t('Evento')}:</strong> ${event.name}<br> | ||
<strong>${t('Lugar')}:</strong> ${event.place}<br> | ||
<strong>${t('Fecha')}:</strong> ${event.date}<br> | ||
<strong>${t('Hora')}:</strong> ${eventHour}<br> | ||
<strong>${t('Capacidad')}:</strong> ${event.capacity}<br> | ||
<a href="/detalles/${event.id}">${t('Ver detalles')}</a> | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo esto debe de estar gestionado por Vue, no manual. Hay que extraer la lógica de los popups, de forma que solo pueda haber un marcador activo en todo el mapa y no ilimitados.
- Guarda en un array todos los marcadores que tenga el mapa y si están activos o inactivos
- Haz un computed que te derive si uno de los marcadores está activo
- Haz que el div en el template se monte (
v-if
) si dicho computed devuelve verdadero - Usa template refs para acceder al elemento: https://vuejs.org/guide/essentials/template-refs.html#template-refs
- Crea un watcher que trackee dicho ref (de esta forma sabes si está montado/desmontado correctamente)
- Cuando dicho watcher sea verdadero, el ref lo aplicas al popup, cuando sea falso, lo eliminas y ya tienes toda la lógica del popup extraída
Como te puse en los otros comentarios, otra opcion es usar Teleport.
Aunque este hilo no tiene solución (porque el que lo publicó no sabía que el montaje/desmontaje de los componentes de Vue es asíncrono y por eso necesitas un watcher), aquí tienes más idea: https://stackoverflow.com/questions/72548373/using-a-vue3-component-as-a-leaflet-popup
0d92b5d
to
c40570f
Compare
c40570f
to
0d92b5d
Compare
0d92b5d
to
9d248ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AitorRD Lo mergeo ya pero falta:
- Adaptar nuevos cambios en la API (concretamente lo de la fecha)
- Hacer referencia a la ruta final correcta de la página de detalles de eventos
- Extraer la lógica de obtener la ubicación a una store, haré un issue sobre eso más tarde.
- Añadir mejores estilos al popup
9d248ac
to
d9ec330
Compare
Also removed unnecessary console.log from login middleware Signed-off-by: GitHub <[email protected]>
d9ec330
to
4bd6584
Compare
|
Añadidio: