refactor: Add additional attributions to AboutModal and filter adventures based on user ID in +page.svelte
This commit is contained in:
@@ -64,6 +64,7 @@
|
|||||||
class="text-primary-500 underline"
|
class="text-primary-500 underline"
|
||||||
href="https://operations.osmfoundation.org/policies/nominatim/">OpenStreepMap</a
|
href="https://operations.osmfoundation.org/policies/nominatim/">OpenStreepMap</a
|
||||||
>. Their data is liscensed under the ODbL liscense.
|
>. Their data is liscensed under the ODbL liscense.
|
||||||
|
<br /> Additional attributions can be found in the README file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<button class="btn btn-primary" on:click={close}>Close</button>
|
<button class="btn btn-primary" on:click={close}>Close</button>
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
function deleteAdventure(event: CustomEvent<number>) {
|
function deleteAdventure(event: CustomEvent<number>) {
|
||||||
adventures = adventures.filter((adventure) => adventure.id !== event.detail);
|
myAdventures = myAdventures.filter((adventure) => adventure.id !== event.detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
let osmResults: OpenStreetMapPlace[] = [];
|
let osmResults: OpenStreetMapPlace[] = [];
|
||||||
let adventures: Adventure[] = [];
|
let myAdventures: Adventure[] = [];
|
||||||
|
let publicAdventures: Adventure[] = [];
|
||||||
|
|
||||||
let query: string | null = '';
|
let query: string | null = '';
|
||||||
|
|
||||||
@@ -48,7 +49,16 @@
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.props) {
|
if (data.props) {
|
||||||
adventures = data.props.adventures;
|
myAdventures = data.props.adventures;
|
||||||
|
publicAdventures = data.props.adventures;
|
||||||
|
|
||||||
|
if (data.user?.pk != null) {
|
||||||
|
myAdventures = myAdventures.filter((adventure) => adventure.user_id === data.user?.pk ?? -1);
|
||||||
|
} else {
|
||||||
|
myAdventures = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
publicAdventures = publicAdventures.filter((adventure) => adventure.user_id !== data.user?.pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
let adventureToEdit: Adventure;
|
let adventureToEdit: Adventure;
|
||||||
@@ -61,7 +71,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveEdit(event: CustomEvent<Adventure>) {
|
function saveEdit(event: CustomEvent<Adventure>) {
|
||||||
adventures = adventures.map((adventure) => {
|
myAdventures = myAdventures.map((adventure) => {
|
||||||
if (adventure.id === event.detail.id) {
|
if (adventure.id === event.detail.id) {
|
||||||
return event.detail;
|
return event.detail;
|
||||||
}
|
}
|
||||||
@@ -79,14 +89,18 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if adventures.length === 0 && osmResults.length === 0}
|
{#if myAdventures.length === 0 && osmResults.length === 0}
|
||||||
<NotFound error={data.error} />
|
<NotFound error={data.error} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if adventures.length > 0}
|
{#if myAdventures.length !== 0 && publicAdventures.length !== 0}
|
||||||
<h2 class="text-center font-bold text-2xl mb-4">AdventureLog Results</h2>
|
<h2 class="text-center font-bold text-2xl mb-4">AdventureLog Results</h2>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if myAdventures.length > 0}
|
||||||
|
<h2 class="text-center font-bold text-2xl mb-4">My Adventures</h2>
|
||||||
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
||||||
{#each adventures as adventure}
|
{#each myAdventures as adventure}
|
||||||
<AdventureCard
|
<AdventureCard
|
||||||
user={data.user}
|
user={data.user}
|
||||||
type={adventure.type}
|
type={adventure.type}
|
||||||
@@ -97,7 +111,22 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if adventures.length > 0 && osmResults.length > 0}
|
|
||||||
|
{#if publicAdventures.length > 0}
|
||||||
|
<h2 class="text-center font-bold text-2xl mb-4">Public Adventures</h2>
|
||||||
|
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
||||||
|
{#each publicAdventures as adventure}
|
||||||
|
<AdventureCard
|
||||||
|
user={null}
|
||||||
|
type={adventure.type}
|
||||||
|
{adventure}
|
||||||
|
on:delete={deleteAdventure}
|
||||||
|
on:edit={editAdventure}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if myAdventures.length > 0 && osmResults.length > 0 && publicAdventures.length > 0}
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if osmResults.length > 0}
|
{#if osmResults.length > 0}
|
||||||
|
|||||||
Reference in New Issue
Block a user