1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-19 12:59:36 +02:00

feat: update localization files and add adventure creation messages; refine adventure filtering logic

This commit is contained in:
Sean Morley 2025-01-16 21:15:22 -05:00
parent 62efa2478e
commit 2b78021155
12 changed files with 117 additions and 30 deletions

View file

@ -1409,13 +1409,10 @@ class OverpassViewSet(viewsets.ViewSet):
# "tags": tags, # Include all raw tags for future use
}
# Filter out adventures with no meaningful data
if any([
adventure["name"],
adventure["latitude"],
adventure["longitude"],
]
) or all:
# Filter out adventures with no name, latitude, or longitude
if (adventure["name"] and
adventure["latitude"] is not None and -90 <= adventure["latitude"] <= 90 and
adventure["longitude"] is not None and -180 <= adventure["longitude"] <= 180) or all:
adventures.append(adventure)
return adventures

View file

@ -11,4 +11,4 @@
"prettier": "^3.3.3",
"vue": "^3.5.13"
}
}
}

View file

@ -15,7 +15,6 @@ export type User = {
export type Adventure = {
id: string;
user_id: string | null;
type: string;
name: string;
location?: string | null;
activity_types?: string[] | null;

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Sind Sie sicher, dass Sie diesen Transport löschen möchten? \nDiese Aktion kann nicht rückgängig gemacht werden.",
"show_map": "Karte anzeigen",
"will_be_marked": "wird als besucht markiert, sobald das Abenteuer gespeichert ist.",
"cities_updated": "Städte aktualisiert"
"cities_updated": "Städte aktualisiert",
"create_adventure": "Erstelle Abenteuer",
"no_adventures_to_recommendations": "Keine Abenteuer gefunden. \nFügen Sie mindestens ein Abenteuer hinzu, um Empfehlungen zu erhalten."
},
"home": {
"desc_1": "Entdecken, planen und erkunden Sie mit Leichtigkeit",

View file

@ -185,12 +185,14 @@
"no_description_found": "No description found",
"adventure_created": "Adventure created",
"adventure_create_error": "Failed to create adventure",
"create_adventure": "Create Adventure",
"adventure_updated": "Adventure updated",
"adventure_update_error": "Failed to update adventure",
"set_to_pin": "Set to Pin",
"category_fetch_error": "Error fetching categories",
"new_adventure": "New Adventure",
"basic_information": "Basic Information",
"no_adventures_to_recommendations": "No adventures found. Add at leat one adventure to get recommendations.",
"adventure_not_found": "There are no adventures to display. Add some using the plus button at the bottom right or try changing filters!",
"no_adventures_found": "No adventures found",
"mark_region_as_visited": "Mark region {region}, {country} as visited?",

View file

@ -265,7 +265,9 @@
"transportation_delete_confirm": "¿Está seguro de que desea eliminar este transporte? \nEsta acción no se puede deshacer.",
"show_map": "Mostrar mapa",
"will_be_marked": "se marcará como visitado una vez guardada la aventura.",
"cities_updated": "ciudades actualizadas"
"cities_updated": "ciudades actualizadas",
"create_adventure": "Crear aventura",
"no_adventures_to_recommendations": "No se encontraron aventuras. \nAñade al menos una aventura para obtener recomendaciones."
},
"worldtravel": {
"all": "Todo",

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Etes-vous sûr de vouloir supprimer ce transport ? \nCette action ne peut pas être annulée.",
"show_map": "Afficher la carte",
"will_be_marked": "sera marqué comme visité une fois laventure sauvegardée.",
"cities_updated": "villes mises à jour"
"cities_updated": "villes mises à jour",
"create_adventure": "Créer une aventure",
"no_adventures_to_recommendations": "Aucune aventure trouvée. \nAjoutez au moins une aventure pour obtenir des recommandations."
},
"home": {
"desc_1": "Découvrez, planifiez et explorez en toute simplicité",

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Sei sicuro di voler eliminare questo trasporto? \nQuesta azione non può essere annullata.",
"show_map": "Mostra mappa",
"will_be_marked": "verrà contrassegnato come visitato una volta salvata l'avventura.",
"cities_updated": "città aggiornate"
"cities_updated": "città aggiornate",
"create_adventure": "Crea Avventura",
"no_adventures_to_recommendations": "Nessuna avventura trovata. \nAggiungi almeno un'avventura per ricevere consigli."
},
"home": {
"desc_1": "Scopri, pianifica ed esplora con facilità",

View file

@ -218,7 +218,9 @@
"ending_airport": "Einde luchthaven",
"show_map": "Toon kaart",
"will_be_marked": "wordt gemarkeerd als bezocht zodra het avontuur is opgeslagen.",
"cities_updated": "steden bijgewerkt"
"cities_updated": "steden bijgewerkt",
"create_adventure": "Creëer avontuur",
"no_adventures_to_recommendations": "Geen avonturen gevonden. \nVoeg ten minste één avontuur toe om aanbevelingen te krijgen."
},
"home": {
"desc_1": "Ontdek, plan en verken met gemak",

View file

@ -265,7 +265,9 @@
"transportation_delete_confirm": "Czy na pewno chcesz usunąć ten transport? \nTej akcji nie można cofnąć.",
"show_map": "Pokaż mapę",
"will_be_marked": "zostanie oznaczona jako odwiedzona po zapisaniu przygody.",
"cities_updated": "miasta zaktualizowane"
"cities_updated": "miasta zaktualizowane",
"create_adventure": "Stwórz przygodę",
"no_adventures_to_recommendations": "Nie znaleziono żadnych przygód. \nDodaj co najmniej jedną przygodę, aby uzyskać rekomendacje."
},
"worldtravel": {
"country_list": "Lista krajów",

View file

@ -218,7 +218,9 @@
"transportation_delete_confirm": "Är du säker på att du vill ta bort denna transport? \nDenna åtgärd kan inte ångras.",
"show_map": "Visa karta",
"will_be_marked": "kommer att markeras som besökt när äventyret har sparats.",
"cities_updated": "städer uppdaterade"
"cities_updated": "städer uppdaterade",
"create_adventure": "Skapa äventyr",
"no_adventures_to_recommendations": "Inga äventyr hittades. \nLägg till minst ett äventyr för att få rekommendationer."
},
"home": {
"desc_1": "Upptäck, planera och utforska med lätthet",

View file

@ -208,6 +208,30 @@
}
}
function recomendationToAdventure(recomendation: any) {
adventureToEdit = {
id: '',
user_id: null,
name: recomendation.name,
latitude: recomendation.latitude,
longitude: recomendation.longitude,
images: [],
is_visited: false,
is_public: false,
visits: [],
category: {
display_name: recomendation.tag
.replace(/_/g, ' ')
.replace(/\b\w/g, (char: string) => char.toUpperCase()),
icon: osmTagToEmoji(recomendation.tag),
id: '',
name: recomendation.tag,
user_id: ''
}
};
isAdventureModalOpen = true;
}
let adventureToEdit: Adventure | null = null;
let transportationToEdit: Transportation | null = null;
let isAdventureModalOpen: boolean = false;
@ -251,11 +275,24 @@
let loadingRecomendations: boolean = false;
let recomendationsRange: number = 1600;
let recomendationType: string = 'tourism';
let recomendationTags: string[] = [];
let recomendationTags: { name: string; display_name: string }[] = [];
let selectedRecomendationTag: string = '';
let filteredRecomendations: any[] = [];
$: {
if (recomendationsData && selectedRecomendationTag) {
filteredRecomendations = recomendationsData.filter(
(r: any) => r.tag === selectedRecomendationTag
);
} else {
filteredRecomendations = recomendationsData;
}
console.log(filteredRecomendations);
console.log(selectedRecomendationTag);
}
async function getRecomendations(adventure: Adventure) {
recomendationsData = null;
selectedRecomendationTag = '';
loadingRecomendations = true;
let res = await fetch(
`/api/overpass/query/?lat=${adventure.latitude}&lon=${adventure.longitude}&radius=${recomendationsRange}&category=${recomendationType}`
@ -267,11 +304,28 @@
let data = await res.json();
recomendationsData = data;
console.log(data);
if (recomendationsData) {
recomendationTags = [
...new Set(recomendationsData.map((r: any) => r.tag).filter(Boolean))
] as string[];
if (recomendationsData && recomendationsData.some((r: any) => r.longitude && r.latitude)) {
const tagMap = new Map();
recomendationsData.forEach((r: any) => {
const tag = formatTag(r.tag);
if (tag) {
tagMap.set(r.tag, { name: r.tag, display_name: tag });
}
});
recomendationTags = Array.from(tagMap.values());
function formatTag(tag: string): string {
if (tag) {
return (
tag
.split('_')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ') + osmTagToEmoji(tag)
);
} else {
return '';
}
}
}
loadingRecomendations = false;
console.log(recomendationTags);
@ -850,10 +904,17 @@
<div class="card-body">
<h2 class="card-title text-3xl justify-center mb-4">Adventure Recommendations</h2>
{#each adventures as adventure}
<button on:click={() => getRecomendations(adventure)} class="btn btn-neutral"
>{adventure.name}</button
>
{#if adventure.longitude && adventure.latitude}
<button on:click={() => getRecomendations(adventure)} class="btn btn-neutral"
>{adventure.name}</button
>
{/if}
{/each}
{#if adventures.length == 0}
<div class="alert alert-info">
<p class="text-center text-lg">{$t('adventures.no_adventures_to_recommendations')}</p>
</div>
{/if}
<div class="mt-4">
<input
type="range"
@ -898,10 +959,13 @@
/>
</div>
{#if recomendationTags.length > 0}
<select class="select select-bordered w-full max-w-xs">
<option disabled selected>Select a tag</option>
<select
class="select select-bordered w-full max-w-xs"
bind:value={selectedRecomendationTag}
>
<option value="">All</option>
{#each recomendationTags as tag}
<option on:click={() => (selectedRecomendationTag = tag)}>{tag}</option>
<option value={tag.name}>{tag.display_name}</option>
{/each}
</select>
{/if}
@ -916,7 +980,7 @@
center={{ lng: recomendationsData[0].longitude, lat: recomendationsData[0].latitude }}
zoom={12}
>
{#each recomendationsData as recomendation}
{#each filteredRecomendations as recomendation}
{#if recomendation.longitude && recomendation.latitude && recomendation.name}
<Marker
lngLat={[recomendation.longitude, recomendation.latitude]}
@ -942,13 +1006,18 @@
'_blank'
)}>{$t('map.view_details')}</button
>
<button
class="btn btn-neutral btn-wide btn-sm mt-4"
on:click={() => recomendationToAdventure(recomendation)}
>{$t('adventures.create_adventure')}</button
>
</Popup>
{/if}
</Marker>
{/if}
{/each}
</MapLibre>
{#each recomendationsData as recomendation}
{#each filteredRecomendations as recomendation}
{#if recomendation.name && recomendation.longitude && recomendation.latitude}
<div class="card bg-base-100 shadow-xl my-4 w-full">
<div class="card-body">
@ -984,6 +1053,12 @@
{/if}
</p>
{/if}
<button
class="btn btn-primary"
on:click={() => recomendationToAdventure(recomendation)}
>
{$t('adventures.create_adventure')}
</button>
</div>
</div>
{/if}