1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 23:39:37 +02:00

Merge pull request #147 from seanmorley15/development

Development
This commit is contained in:
Sean Morley 2024-07-29 22:15:07 -04:00 committed by GitHub
commit bef9eb199f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 5184 additions and 15 deletions

View file

@ -113,3 +113,4 @@ AdventureLog is licensed under the GNU General Public License v3.0.
- [Mexico GEOJSON](https://cartographyvectors.com/map/784-mexico-with-states)
- [Japan GEOJSON](https://cartographyvectors.com/map/361-japan)
- [Ireland GEOJSON](https://cartographyvectors.com/map/1399-ireland-provinces)

File diff suppressed because it is too large Load diff

View file

@ -56,10 +56,16 @@
let id = data[1];
let user_id = data[2];
console.log(newCollection);
dispatch('create', newCollection);
addToast('success', 'Collection created successfully!');
close();
if (id !== undefined && user_id !== undefined) {
newCollection.id = id;
newCollection.user_id = user_id;
console.log(newCollection);
dispatch('create', newCollection);
addToast('success', 'Collection created successfully!');
close();
} else {
addToast('error', 'Error creating collection');
}
}
}
}

View file

@ -7,7 +7,7 @@
import FileDocumentEdit from '~icons/mdi/file-document-edit';
import { goto } from '$app/navigation';
import type { Collection, Transportation } from '$lib/types';
import type { Collection, Transportation, User } from '$lib/types';
import { addToast } from '$lib/toasts';
import Plus from '~icons/mdi/plus';
@ -15,6 +15,7 @@
const dispatch = createEventDispatcher();
export let transportation: Transportation;
export let user: User | null = null;
function editTransportation() {
dispatch('edit', transportation);
@ -51,13 +52,15 @@
{#if transportation.date}
{new Date(transportation.date).toLocaleString()}
{/if}
<div class="card-actions justify-end">
<button on:click={deleteTransportation} class="btn btn-secondary"
><TrashCanOutline class="w-5 h-5 mr-1" /></button
>
<button class="btn btn-primary" on:click={editTransportation}>
<FileDocumentEdit class="w-6 h-6" />
</button>
</div>
{#if user}
<div class="card-actions justify-end">
<button on:click={deleteTransportation} class="btn btn-secondary"
><TrashCanOutline class="w-5 h-5 mr-1" /></button
>
<button class="btn btn-primary" on:click={editTransportation}>
<FileDocumentEdit class="w-6 h-6" />
</button>
</div>
{/if}
</div>
</div>

View file

@ -109,7 +109,13 @@ export const actions: Actions = {
formDataToSend.append('description', description || '');
formDataToSend.append('latitude', latitude || '');
formDataToSend.append('longitude', longitude || '');
formDataToSend.append('collection', collection || '');
if (!isNaN(Number(collection))) {
if (collection !== null) {
formDataToSend.append('collection', collection);
}
}
if (activity_types) {
// Filter out empty and duplicate activity types, then trim each activity type
const cleanedActivityTypes = Array.from(
@ -129,6 +135,11 @@ export const actions: Actions = {
formDataToSend.append('link', link || '');
formDataToSend.append('image', image);
// log each key-value pair in the FormData
for (let pair of formDataToSend.entries()) {
console.log(pair[0] + ', ' + pair[1]);
}
let auth = event.cookies.get('auth');
if (!auth) {

View file

@ -374,6 +374,7 @@
{#each transportations as transportation}
<TransportationCard
{transportation}
user={data?.user}
on:delete={(event) => {
transportations = transportations.filter((t) => t.id != event.detail);
}}
@ -430,6 +431,7 @@
{#each dayTransportations as transportation}
<TransportationCard
{transportation}
user={data?.user}
on:delete={(event) => {
transportations = transportations.filter((t) => t.id != event.detail);
}}

View file

@ -33,7 +33,8 @@ export const load = (async (event) => {
return {
lngLat: [adventure.longitude, adventure.latitude] as [number, number],
name: adventure.name,
type: adventure.type
type: adventure.type,
collection: adventure.collection
};
});

View file

@ -19,6 +19,7 @@
let showVisited = true;
let showPlanned = true;
let showCollectionAdventures = false;
$: {
if (!showVisited) {
@ -33,6 +34,12 @@
const plannedMarkers = data.props.markers.filter((marker) => marker.type === 'planned');
markers = [...markers, ...plannedMarkers];
}
if (!showCollectionAdventures) {
markers = markers.filter((marker) => marker.collection === null);
} else {
const collectionMarkers = data.props.markers.filter((marker) => marker.collection !== null);
markers = [...markers, ...collectionMarkers];
}
}
let newMarker = [];
@ -117,6 +124,14 @@
<span class="label-text">Planned</span>
<input type="checkbox" bind:checked={showPlanned} class="checkbox checkbox-primary" />
</label>
<label class="label cursor-pointer">
<span class="label-text">Collection Adventures</span>
<input
type="checkbox"
bind:checked={showCollectionAdventures}
class="checkbox checkbox-primary"
/>
</label>
{#if newMarker.length > 0}
<button type="button" class="btn btn-primary mb-2" on:click={() => (createModalOpen = true)}