diff --git a/backend/server/adventures/migrations/0018_note_links.py b/backend/server/adventures/migrations/0018_note_links.py new file mode 100644 index 0000000..6366306 --- /dev/null +++ b/backend/server/adventures/migrations/0018_note_links.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.7 on 2024-08-04 13:19 + +import django.contrib.postgres.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('adventures', '0017_alter_note_date'), + ] + + operations = [ + migrations.AddField( + model_name='note', + name='links', + field=django.contrib.postgres.fields.ArrayField(base_field=models.URLField(), blank=True, null=True, size=None), + ), + ] diff --git a/backend/server/adventures/models.py b/backend/server/adventures/models.py index c38cb80..d169c4a 100644 --- a/backend/server/adventures/models.py +++ b/backend/server/adventures/models.py @@ -116,6 +116,7 @@ class Note(models.Model): User, on_delete=models.CASCADE, default=default_user_id) name = models.CharField(max_length=200) content = models.TextField(blank=True, null=True) + links = ArrayField(models.URLField(), blank=True, null=True) date = models.DateField(blank=True, null=True) is_public = models.BooleanField(default=False) collection = models.ForeignKey('Collection', on_delete=models.CASCADE, blank=True, null=True) diff --git a/frontend/src/lib/components/NoteCard.svelte b/frontend/src/lib/components/NoteCard.svelte index a2e3fd9..02e6af6 100644 --- a/frontend/src/lib/components/NoteCard.svelte +++ b/frontend/src/lib/components/NoteCard.svelte @@ -21,11 +21,11 @@

{note.name}

-
diff --git a/frontend/src/lib/components/NoteModal.svelte b/frontend/src/lib/components/NoteModal.svelte index e165632..7d38701 100644 --- a/frontend/src/lib/components/NoteModal.svelte +++ b/frontend/src/lib/components/NoteModal.svelte @@ -1,15 +1,31 @@ @@ -36,8 +85,8 @@
@@ -58,18 +107,26 @@ name="date" min={startDate || ''} max={endDate || ''} - bind:value={note.date} + bind:value={newNote.date} class="input input-bordered w-full max-w-xs mt-1" />
-
- - + {#if collection.is_public} +

+ This note will be public because it is in a public collection. +

+ {/if} +
diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 064442c..f3aafe8 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -110,9 +110,10 @@ export type Note = { user_id: number; name: string; content: string | null; + links: string[] | null; date: string | null; // ISO 8601 date string is_public: boolean; - collection: Collection | null; + collection: number | null; created_at: string; // ISO 8601 date string updated_at: string; // ISO 8601 date string }; diff --git a/frontend/src/routes/collections/[id]/+page.svelte b/frontend/src/routes/collections/[id]/+page.svelte index 4623ebe..dd47c05 100644 --- a/frontend/src/routes/collections/[id]/+page.svelte +++ b/frontend/src/routes/collections/[id]/+page.svelte @@ -249,6 +249,17 @@ on:close={() => (isNoteModalOpen = false)} startDate={collection.start_date} endDate={collection.end_date} + {collection} + on:save={(event) => { + notes = notes.map((note) => { + if (note.id === event.detail.id) { + return event.detail; + } + return note; + }); + isNoteModalOpen = false; + }} + on:close={() => (isNoteModalOpen = false)} /> {/if} @@ -371,6 +382,15 @@ > Transportation +