1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-20 13:29:37 +02:00

Fix max url length, adds line breaks to display, truncates long urls. Remove old seed command.

This commit is contained in:
Sean Morley 2024-09-17 10:34:31 -04:00
parent 0fd9e04599
commit 78f56a3a5f
5 changed files with 46 additions and 4228 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 5.0.8 on 2024-09-17 14:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adventures', '0005_collection_shared_with'),
]
operations = [
migrations.AlterField(
model_name='adventure',
name='link',
field=models.URLField(blank=True, max_length=2083, null=True),
),
]

View file

@ -43,7 +43,7 @@ class Adventure(models.Model):
max_length=100), blank=True, null=True) max_length=100), blank=True, null=True)
description = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True)
rating = models.FloatField(blank=True, null=True) rating = models.FloatField(blank=True, null=True)
link = models.URLField(blank=True, null=True) link = models.URLField(blank=True, null=True, max_length=2083)
image = ResizedImageField(force_format="WEBP", quality=75, null=True, blank=True, upload_to='images/') image = ResizedImageField(force_format="WEBP", quality=75, null=True, blank=True, upload_to='images/')
date = models.DateField(blank=True, null=True) date = models.DateField(blank=True, null=True)
end_date = models.DateField(blank=True, null=True) end_date = models.DateField(blank=True, null=True)

View file

@ -17,6 +17,7 @@
let query: string = ''; let query: string = '';
let places: OpenStreetMapPlace[] = []; let places: OpenStreetMapPlace[] = [];
let images: { id: string; image: string }[] = []; let images: { id: string; image: string }[] = [];
let warningMessage: string = '';
import Earth from '~icons/mdi/earth'; import Earth from '~icons/mdi/earth';
import ActivityComplete from './ActivityComplete.svelte'; import ActivityComplete from './ActivityComplete.svelte';
@ -393,8 +394,10 @@
if (data.id) { if (data.id) {
adventure = data as Adventure; adventure = data as Adventure;
isDetails = false; isDetails = false;
warningMessage = '';
addToast('success', 'Adventure created'); addToast('success', 'Adventure created');
} else { } else {
warningMessage = Object.values(data)[0] as string;
addToast('error', 'Failed to create adventure'); addToast('error', 'Failed to create adventure');
} }
} else { } else {
@ -409,8 +412,10 @@
if (data.id) { if (data.id) {
adventure = data as Adventure; adventure = data as Adventure;
isDetails = false; isDetails = false;
warningMessage = '';
addToast('success', 'Adventure updated'); addToast('success', 'Adventure updated');
} else { } else {
warningMessage = Object.values(data)[0] as string;
addToast('error', 'Failed to update adventure'); addToast('error', 'Failed to update adventure');
} }
} }
@ -726,6 +731,24 @@ it would also work to just use on:click on the MapLibre component itself. -->
{/if} {/if}
<div class="mt-4"> <div class="mt-4">
{#if warningMessage != ''}
<div role="alert" class="alert alert-warning mb-2">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
fill="none"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
<span>Warning: {warningMessage}</span>
</div>
{/if}
<button type="submit" class="btn btn-primary">Save & Next</button> <button type="submit" class="btn btn-primary">Save & Next</button>
<button type="button" class="btn" on:click={close}>Close</button> <button type="button" class="btn" on:click={close}>Close</button>
</div> </div>

View file

@ -281,14 +281,16 @@
class="text-sm text-muted-foreground hover:underline" class="text-sm text-muted-foreground hover:underline"
target="_blank" target="_blank"
> >
{adventure.link} {adventure.link.length > 45
? `${adventure.link.slice(0, 45)}...`
: adventure.link}
</a> </a>
</div> </div>
{/if} {/if}
</div> </div>
{#if adventure.description} {#if adventure.description}
<div class="grid gap-2"> <div class="grid gap-2">
<p class="text-sm text-muted-foreground"> <p class="text-sm text-muted-foreground whitespace-pre-line">
{adventure.description} {adventure.description}
</p> </p>
</div> </div>