From febbdfa252c4c50e9be664fbcf61c95813b86458 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 15 Dec 2024 17:15:18 +0000 Subject: [PATCH 01/14] Bump the npm_and_yarn group across 2 directories with 2 updates Bumps the npm_and_yarn group with 1 update in the /documentation directory: [nanoid](https://github.com/ai/nanoid). Bumps the npm_and_yarn group with 2 updates in the /frontend directory: [nanoid](https://github.com/ai/nanoid) and [cross-spawn](https://github.com/moxystudio/node-cross-spawn). Updates `nanoid` from 3.3.7 to 3.3.8 - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8) Updates `nanoid` from 3.3.7 to 3.3.8 - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8) Updates `cross-spawn` from 7.0.3 to 7.0.6 - [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md) - [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6) --- updated-dependencies: - dependency-name: nanoid dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: nanoid dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: cross-spawn dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] --- documentation/pnpm-lock.yaml | 8 ++++---- frontend/pnpm-lock.yaml | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/documentation/pnpm-lock.yaml b/documentation/pnpm-lock.yaml index 0371b16..109ad48 100644 --- a/documentation/pnpm-lock.yaml +++ b/documentation/pnpm-lock.yaml @@ -612,8 +612,8 @@ packages: mitt@3.0.1: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} - nanoid@3.3.7: - resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + nanoid@3.3.8: + resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -1352,7 +1352,7 @@ snapshots: mitt@3.0.1: {} - nanoid@3.3.7: {} + nanoid@3.3.8: {} oniguruma-to-es@0.4.1: dependencies: @@ -1366,7 +1366,7 @@ snapshots: postcss@8.4.49: dependencies: - nanoid: 3.3.7 + nanoid: 3.3.8 picocolors: 1.1.1 source-map-js: 1.2.1 diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 702ef84..e7ca501 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -899,8 +899,8 @@ packages: resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} - cross-spawn@7.0.3: - resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} css-selector-tokenizer@0.8.0: @@ -1432,8 +1432,8 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} - nanoid@3.3.7: - resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + nanoid@3.3.8: + resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -2358,7 +2358,7 @@ snapshots: '@jsdevtools/ez-spawn@3.0.4': dependencies: call-me-maybe: 1.0.2 - cross-spawn: 7.0.3 + cross-spawn: 7.0.6 string-argv: 0.3.2 type-detect: 4.0.8 @@ -2819,7 +2819,7 @@ snapshots: cookie@0.6.0: {} - cross-spawn@7.0.3: + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 shebang-command: 2.0.0 @@ -3000,7 +3000,7 @@ snapshots: execa@5.1.1: dependencies: - cross-spawn: 7.0.3 + cross-spawn: 7.0.6 get-stream: 6.0.1 human-signals: 2.1.0 is-stream: 2.0.1 @@ -3057,7 +3057,7 @@ snapshots: foreground-child@3.2.1: dependencies: - cross-spawn: 7.0.3 + cross-spawn: 7.0.6 signal-exit: 4.1.0 fraction.js@4.3.7: {} @@ -3394,7 +3394,7 @@ snapshots: object-assign: 4.1.1 thenify-all: 1.6.0 - nanoid@3.3.7: {} + nanoid@3.3.8: {} next-tick@1.1.0: {} @@ -3548,13 +3548,13 @@ snapshots: postcss@8.4.38: dependencies: - nanoid: 3.3.7 + nanoid: 3.3.8 picocolors: 1.0.1 source-map-js: 1.2.0 postcss@8.4.47: dependencies: - nanoid: 3.3.7 + nanoid: 3.3.8 picocolors: 1.1.0 source-map-js: 1.2.1 From dd08a6fe2451044b2aee42a5883e7452e399cb5d Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Tue, 17 Dec 2024 18:58:38 -0500 Subject: [PATCH 02/14] Add Markdown editor component and integrate it into AdventureModal --- frontend/package.json | 1 + frontend/pnpm-lock.yaml | 10 +++ .../src/lib/components/AdventureModal.svelte | 10 +-- .../src/lib/components/MarkdownEditor.svelte | 80 +++++++++++++++++++ frontend/src/locales/de.json | 4 +- frontend/src/locales/en.json | 2 + frontend/src/locales/es.json | 4 +- frontend/src/locales/fr.json | 4 +- frontend/src/locales/it.json | 4 +- frontend/src/locales/nl.json | 4 +- frontend/src/locales/pl.json | 4 +- frontend/src/locales/sv.json | 4 +- frontend/src/locales/zh.json | 4 +- .../src/routes/adventures/[id]/+page.svelte | 16 ++-- 14 files changed, 131 insertions(+), 20 deletions(-) create mode 100644 frontend/src/lib/components/MarkdownEditor.svelte diff --git a/frontend/package.json b/frontend/package.json index da9ceec..e2b9a26 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -41,6 +41,7 @@ "dependencies": { "@lukulent/svelte-umami": "^0.0.3", "emoji-picker-element": "^1.26.0", + "marked": "^15.0.4", "qrcode": "^1.5.4", "svelte-i18n": "^4.0.1", "svelte-maplibre": "^0.9.8" diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 702ef84..221178b 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: emoji-picker-element: specifier: ^1.26.0 version: 1.26.0 + marked: + specifier: ^15.0.4 + version: 15.0.4 qrcode: specifier: ^1.5.4 version: 1.5.4 @@ -1351,6 +1354,11 @@ packages: resolution: {integrity: sha512-qOS1hn4d/pn2i0uva4S5Oz+fACzTkgBKq+NpwT/Tqzi4MSyzcWNtDELzLUSgWqHfNIkGCl5CZ/w7dtis+t4RCw==} engines: {node: '>=16.14.0', npm: '>=8.1.0'} + marked@15.0.4: + resolution: {integrity: sha512-TCHvDqmb3ZJ4PWG7VEGVgtefA5/euFmsIhxtD0XsBxI39gUSKL81mIRFdt0AiNQozUahd4ke98ZdirExd/vSEw==} + engines: {node: '>= 18'} + hasBin: true + mdn-data@2.0.30: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} @@ -3318,6 +3326,8 @@ snapshots: tinyqueue: 2.0.3 vt-pbf: 3.1.3 + marked@15.0.4: {} + mdn-data@2.0.30: {} memoizee@0.4.17: diff --git a/frontend/src/lib/components/AdventureModal.svelte b/frontend/src/lib/components/AdventureModal.svelte index c0dc277..88e3d0c 100644 --- a/frontend/src/lib/components/AdventureModal.svelte +++ b/frontend/src/lib/components/AdventureModal.svelte @@ -32,6 +32,7 @@ import { appVersion } from '$lib/config'; import CategoryDropdown from './CategoryDropdown.svelte'; import { findFirstValue } from '$lib'; + import MarkdownEditor from './MarkdownEditor.svelte'; let wikiError: string = ''; @@ -577,15 +578,10 @@

- +
-
diff --git a/frontend/src/lib/components/MarkdownEditor.svelte b/frontend/src/lib/components/MarkdownEditor.svelte new file mode 100644 index 0000000..6ed5914 --- /dev/null +++ b/frontend/src/lib/components/MarkdownEditor.svelte @@ -0,0 +1,80 @@ + + +
+ + +
+ +
+ + {#if !is_preview} + + {/if} + + + {#if is_preview} +
+ {@html renderMarkdown(text || '')} +
+ {/if} +
+ + diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 25e2b41..0cb54b1 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -195,7 +195,9 @@ "emoji_picker": "Emoji-Picker", "hide": "Verstecken", "show": "Zeigen", - "download_calendar": "Kalender herunterladen" + "download_calendar": "Kalender herunterladen", + "md_instructions": "Schreiben Sie hier Ihren Abschlag...", + "preview": "Vorschau" }, "home": { "desc_1": "Entdecken, planen und erkunden Sie mit Leichtigkeit", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index cd9b824..54dc04f 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -218,6 +218,8 @@ "hide": "Hide", "emoji_picker": "Emoji Picker", "download_calendar": "Download Calendar", + "preview": "Preview", + "md_instructions": "Write your markdown here...", "days": "days", "activities": { "general": "General 🌍", diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index 42da49e..164351f 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -242,7 +242,9 @@ "emoji_picker": "Selector de emojis", "hide": "Esconder", "show": "Espectáculo", - "download_calendar": "Descargar Calendario" + "download_calendar": "Descargar Calendario", + "md_instructions": "Escriba su descuento aquí...", + "preview": "Avance" }, "worldtravel": { "all": "Todo", diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index 9a532de..af1583a 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -195,7 +195,9 @@ "emoji_picker": "Sélecteur d'émoticônes", "hide": "Cacher", "show": "Montrer", - "download_calendar": "Télécharger le calendrier" + "download_calendar": "Télécharger le calendrier", + "md_instructions": "Écrivez votre démarque ici...", + "preview": "Aperçu" }, "home": { "desc_1": "Découvrez, planifiez et explorez en toute simplicité", diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.json index fa0b1fb..605a57d 100644 --- a/frontend/src/locales/it.json +++ b/frontend/src/locales/it.json @@ -195,7 +195,9 @@ "emoji_picker": "Selettore di emoji", "hide": "Nascondere", "show": "Spettacolo", - "download_calendar": "Scarica Calendario" + "download_calendar": "Scarica Calendario", + "md_instructions": "Scrivi qui il tuo ribasso...", + "preview": "Anteprima" }, "home": { "desc_1": "Scopri, pianifica ed esplora con facilità", diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json index 90ac331..8cc4780 100644 --- a/frontend/src/locales/nl.json +++ b/frontend/src/locales/nl.json @@ -195,7 +195,9 @@ "emoji_picker": "Emoji-kiezer", "hide": "Verbergen", "show": "Show", - "download_calendar": "Agenda downloaden" + "download_calendar": "Agenda downloaden", + "md_instructions": "Schrijf hier uw korting...", + "preview": "Voorbeeld" }, "home": { "desc_1": "Ontdek, plan en verken met gemak", diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.json index db3e758..bdab4b2 100644 --- a/frontend/src/locales/pl.json +++ b/frontend/src/locales/pl.json @@ -242,7 +242,9 @@ "emoji_picker": "Wybór emoji", "hide": "Ukrywać", "show": "Pokazywać", - "download_calendar": "Pobierz Kalendarz" + "download_calendar": "Pobierz Kalendarz", + "md_instructions": "Napisz tutaj swoją przecenę...", + "preview": "Zapowiedź" }, "worldtravel": { "country_list": "Lista krajów", diff --git a/frontend/src/locales/sv.json b/frontend/src/locales/sv.json index aae55d5..1059469 100644 --- a/frontend/src/locales/sv.json +++ b/frontend/src/locales/sv.json @@ -195,7 +195,9 @@ "emoji_picker": "Emoji-väljare", "hide": "Dölja", "show": "Visa", - "download_calendar": "Ladda ner kalender" + "download_calendar": "Ladda ner kalender", + "md_instructions": "Skriv din avskrivning här...", + "preview": "Förhandsvisning" }, "home": { "desc_1": "Upptäck, planera och utforska med lätthet", diff --git a/frontend/src/locales/zh.json b/frontend/src/locales/zh.json index 56cf01f..cc3735a 100644 --- a/frontend/src/locales/zh.json +++ b/frontend/src/locales/zh.json @@ -195,7 +195,9 @@ "emoji_picker": "表情符号选择器", "hide": "隐藏", "show": "展示", - "download_calendar": "下载日历" + "download_calendar": "下载日历", + "md_instructions": "在这里写下你的标记...", + "preview": "预览" }, "home": { "desc_1": "轻松发现、规划和探索", diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 9e357ea..d78ac54 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -6,6 +6,11 @@ import Lost from '$lib/assets/undraw_lost.svg'; import { DefaultMarker, MapLibre, Popup } from 'svelte-maplibre'; import { t } from 'svelte-i18n'; + import { marked } from 'marked'; // Import the markdown parser + + const renderMarkdown = (markdown: string) => { + return marked(markdown); + }; export let data: PageData; console.log(data); @@ -244,11 +249,12 @@ {/if}
{#if adventure.description} -
-

- {adventure.description} -

-
+

+
+ {@html renderMarkdown(adventure.description)} +
{/if}
From 7c68dc839ad7cca930cdadd8ab8998617e216c56 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Thu, 19 Dec 2024 18:46:52 -0500 Subject: [PATCH 03/14] Add geographic coordinates to Transportation model and update related components --- ...portation_destination_latitude_and_more.py | 33 + backend/server/adventures/models.py | 4 + backend/server/adventures/serializers.py | 2 +- frontend/src/lib/components/AboutModal.svelte | 173 ++++-- .../src/lib/components/MarkdownEditor.svelte | 3 +- .../lib/components/TransportationCard.svelte | 75 ++- .../lib/components/TransportationModal.svelte | 562 ++++++++++++++++++ frontend/src/lib/types.ts | 6 +- frontend/src/locales/en.json | 10 + .../src/routes/collections/[id]/+page.svelte | 70 +-- frontend/src/routes/settings/+page.svelte | 376 ++++++------ 11 files changed, 1025 insertions(+), 289 deletions(-) create mode 100644 backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py create mode 100644 frontend/src/lib/components/TransportationModal.svelte diff --git a/backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py b/backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py new file mode 100644 index 0000000..7971839 --- /dev/null +++ b/backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 5.0.8 on 2024-12-19 17:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('adventures', '0014_alter_category_unique_together'), + ] + + operations = [ + migrations.AddField( + model_name='transportation', + name='destination_latitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + migrations.AddField( + model_name='transportation', + name='destination_longitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + migrations.AddField( + model_name='transportation', + name='origin_latitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + migrations.AddField( + model_name='transportation', + name='origin_longitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + ] diff --git a/backend/server/adventures/models.py b/backend/server/adventures/models.py index a8460d7..98ae268 100644 --- a/backend/server/adventures/models.py +++ b/backend/server/adventures/models.py @@ -167,6 +167,10 @@ class Transportation(models.Model): end_date = models.DateTimeField(blank=True, null=True) flight_number = models.CharField(max_length=100, blank=True, null=True) from_location = models.CharField(max_length=200, blank=True, null=True) + origin_latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + origin_longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + destination_latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + destination_longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) to_location = models.CharField(max_length=200, 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/backend/server/adventures/serializers.py b/backend/server/adventures/serializers.py index 9b538ed..45a2141 100644 --- a/backend/server/adventures/serializers.py +++ b/backend/server/adventures/serializers.py @@ -170,7 +170,7 @@ class TransportationSerializer(CustomModelSerializer): fields = [ 'id', 'user_id', 'type', 'name', 'description', 'rating', 'link', 'date', 'flight_number', 'from_location', 'to_location', - 'is_public', 'collection', 'created_at', 'updated_at', 'end_date' + 'is_public', 'collection', 'created_at', 'updated_at', 'end_date', 'origin_latitude', 'origin_longitude', 'destination_latitude', 'destination_longitude' ] read_only_fields = ['id', 'created_at', 'updated_at', 'user_id'] diff --git a/frontend/src/lib/components/AboutModal.svelte b/frontend/src/lib/components/AboutModal.svelte index 60faa89..7b8fbf2 100644 --- a/frontend/src/lib/components/AboutModal.svelte +++ b/frontend/src/lib/components/AboutModal.svelte @@ -1,13 +1,14 @@ - - + - - + +
+

+ © {copyrightYear} + + Sean Morley + +

+

{$t('about.license')}

+

+ + {$t('about.source_code')} + +

+

{$t('about.message')}

+
+ + +
+ + +
+

+ {$t('about.oss_attributions')} +

+

+ {$t('about.nominatim_1')} + + OpenStreetMap + + . {$t('about.nominatim_2')} +

+

{$t('about.other_attributions')}

+
+ + +
+ +
+ + diff --git a/frontend/src/lib/components/MarkdownEditor.svelte b/frontend/src/lib/components/MarkdownEditor.svelte index 6ed5914..a280d7e 100644 --- a/frontend/src/lib/components/MarkdownEditor.svelte +++ b/frontend/src/lib/components/MarkdownEditor.svelte @@ -3,6 +3,7 @@ import { t } from 'svelte-i18n'; export let text: string | null | undefined = ''; // Markdown text + export let editor_height: string = 'h-64'; // Editor height let is_preview: boolean = false; // Toggle between Edit and Preview mode // Function to parse markdown to HTML @@ -46,7 +47,7 @@ {#if !is_preview} - -
- - { - if (e.key === 'Enter') { - e.preventDefault(); - addLink(); - } - }} - /> - -
- {#if newNote.links.length > 0} -
    - {#each newNote.links as link, i} -
  • - {link} - -
  • - {/each} -
- {/if} + {$t('adventures.date_constrain')} + (constrainDates = !constrainDates)} + /> + {/if} + + + + +
+
+ {#if !isReadOnly} + + {:else if note} +

+
+ {@html renderMarkdown(note.content || '')} +
+ {/if} +
+ + + {#if !isReadOnly} +
+ + { + if (e.key === 'Enter') { + e.preventDefault(); + addLink(); + } + }} + /> + +
+ {/if} + + + {#if newNote.links.length > 0} +
    + {#each newNote.links as link, i} +
  • + + {link} + + +
  • + {/each} +
+ {/if} + + + + {#if warning} -
diff --git a/frontend/src/lib/components/ShareModal.svelte b/frontend/src/lib/components/ShareModal.svelte index d4bb98b..0f4fcec 100644 --- a/frontend/src/lib/components/ShareModal.svelte +++ b/frontend/src/lib/components/ShareModal.svelte @@ -24,7 +24,11 @@ }); if (res.ok) { sharedWithUsers = sharedWithUsers.concat(user); - collection.shared_with.push(user.uuid); + if (collection.shared_with) { + collection.shared_with.push(user.uuid); + } else { + collection.shared_with = [user.uuid]; + } notSharedWithUsers = notSharedWithUsers.filter((u) => u.uuid !== user.uuid); addToast( 'success', @@ -42,7 +46,9 @@ }); if (res.ok) { notSharedWithUsers = notSharedWithUsers.concat(user); - collection.shared_with = collection.shared_with.filter((u) => u !== user.uuid); + if (collection.shared_with) { + collection.shared_with = collection.shared_with.filter((u) => u !== user.uuid); + } sharedWithUsers = sharedWithUsers.filter((u) => u.uuid !== user.uuid); addToast( 'success', @@ -60,8 +66,12 @@ if (res.ok) { let data = await res.json(); allUsers = data; - sharedWithUsers = allUsers.filter((user) => collection.shared_with.includes(user.uuid)); - notSharedWithUsers = allUsers.filter((user) => !collection.shared_with.includes(user.uuid)); + sharedWithUsers = allUsers.filter((user) => + (collection.shared_with ?? []).includes(user.uuid) + ); + notSharedWithUsers = allUsers.filter( + (user) => !(collection.shared_with ?? []).includes(user.uuid) + ); console.log(sharedWithUsers); console.log(notSharedWithUsers); } diff --git a/frontend/src/lib/components/TransportationCard.svelte b/frontend/src/lib/components/TransportationCard.svelte index 529ba1c..a9f6261 100644 --- a/frontend/src/lib/components/TransportationCard.svelte +++ b/frontend/src/lib/components/TransportationCard.svelte @@ -20,6 +20,25 @@ dispatch('edit', transportation); } + let unlinked: boolean = false; + + // unlinked if collection.start_date and collection.end_date are not within transportation.date and transportation.end_date. check for null in the collection dates first to avoid errors + $: { + if (collection?.start_date && collection.end_date) { + const startOutsideRange = + transportation.date && + collection.start_date < transportation.date && + collection.end_date < transportation.date; + + const endOutsideRange = + transportation.end_date && + collection.start_date > transportation.end_date && + collection.end_date > transportation.end_date; + + unlinked = !!(startOutsideRange || endOutsideRange); + } + } + async function deleteTransportation() { let res = await fetch(`/api/transportations/${transportation.id}`, { method: 'DELETE', @@ -64,6 +83,9 @@ {/if} + {#if unlinked} +
{$t('adventures.out_of_range')}
+ {/if}
@@ -100,7 +122,7 @@
- {#if transportation.user_id == user?.uuid || (collection && user && collection.shared_with.includes(user.uuid))} + {#if transportation.user_id == user?.uuid || (collection && user && collection.shared_with && collection.shared_with.includes(user.uuid))}
{/if} {#if collection} - {#if data.user && data.user.uuid && (data.user.uuid == collection.user_id || collection.shared_with.includes(data.user.uuid)) && !collection.is_archived} + {#if data.user && data.user.uuid && (data.user.uuid == collection.user_id || (collection.shared_with && collection.shared_with.includes(data.user.uuid))) && !collection.is_archived}
diff --git a/frontend/src/lib/components/NoteCard.svelte b/frontend/src/lib/components/NoteCard.svelte index f513f78..9b6ba62 100644 --- a/frontend/src/lib/components/NoteCard.svelte +++ b/frontend/src/lib/components/NoteCard.svelte @@ -25,7 +25,7 @@ const endOutsideRange = note.date && collection.start_date > note.date && collection.end_date > note.date; - unlinked = !!(startOutsideRange || endOutsideRange); + unlinked = !!(startOutsideRange || endOutsideRange || !note.date); } } diff --git a/frontend/src/lib/components/NoteModal.svelte b/frontend/src/lib/components/NoteModal.svelte index 8b37a7c..8344984 100644 --- a/frontend/src/lib/components/NoteModal.svelte +++ b/frontend/src/lib/components/NoteModal.svelte @@ -288,11 +288,10 @@
-
diff --git a/frontend/src/lib/components/TransportationModal.svelte b/frontend/src/lib/components/TransportationModal.svelte index a37c6bd..07291ea 100644 --- a/frontend/src/lib/components/TransportationModal.svelte +++ b/frontend/src/lib/components/TransportationModal.svelte @@ -589,7 +589,7 @@ it would also work to just use on:click on the MapLibre component itself. -->