From 5404a6e5ad13534bde5ad27b9ca86f802ca9c1d1 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Mon, 6 Mar 2023 09:24:39 +0100 Subject: [PATCH] Implementing notes (WIP) --- src/components/note/Note.tsx | 23 +++++++++++++++++------ src/components/wpt/WptEditDialog.tsx | 5 +++-- src/db/types.d.ts | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/components/note/Note.tsx b/src/components/note/Note.tsx index 746ac85..5d4fe93 100644 --- a/src/components/note/Note.tsx +++ b/src/components/note/Note.tsx @@ -1,14 +1,24 @@ import { IconButton } from '@suid/material'; import { Component, createSignal } from 'solid-js'; +import { Geolocation } from '@awesome-cordova-plugins/geolocation'; import NoteIcon from '@suid/icons-material/Note'; import style from './Note.module.css'; +import WptEditDialog from '../wpt/WptEditDialog'; +import { Coordinate } from 'ol/coordinate'; interface Props {} const Note: Component = (props) => { - const [open, setOpen] = createSignal(); + const [open, setOpen] = createSignal(false); + const [coordinate, setCoordinate] = createSignal(); + + const openWptEditDialogWithCurrentLocation = async () => { + const position = await Geolocation.getCurrentPosition(); + setCoordinate([position.coords.longitude, position.coords.latitude]); + setOpen(true); + }; return ( <> @@ -20,14 +30,15 @@ const Note: Component = (props) => { } > {' '} - { - setOpen(true); - }} - > + + setOpen(false)} + coordinate={coordinate} + /> ); }; diff --git a/src/components/wpt/WptEditDialog.tsx b/src/components/wpt/WptEditDialog.tsx index c3291aa..346c8f7 100644 --- a/src/components/wpt/WptEditDialog.tsx +++ b/src/components/wpt/WptEditDialog.tsx @@ -18,12 +18,13 @@ import { Coordinate } from 'ol/coordinate'; interface Props { wptId?: string; coordinate?: () => Coordinate | undefined; + type?: string; open: () => boolean; - closeHandler?: () => vpod; + closeHandler?: () => void; } const WptEditDialog: Component = (props) => { - const { wptId, closeHandler, open, coordinate } = props; + const { wptId, closeHandler, open, coordinate, type = 'poi' } = props; const [t, { add, locale, dict }] = useI18n(); const wpt = !!wptId diff --git a/src/db/types.d.ts b/src/db/types.d.ts index f0529f9..95b4536 100644 --- a/src/db/types.d.ts +++ b/src/db/types.d.ts @@ -42,6 +42,17 @@ interface Bounds_ { maxlon: number; } +export enum Category { + NOTE = 'note', + POI = 'poi', + UNKNOWN = '', +} + +export enum SubCategory { + ACCOMMODATION = 'accommodation', + UNKNOWN = '', +} + interface Extensions { 'dyo:speed'?: number; 'dyo:course'?: number; @@ -51,6 +62,10 @@ interface Extensions { 'dyo:minZoom'?: number; address?: any; to?: string; + startTime?: string; + endTime?: string; + category?: Category; + subCategory?: SubCategory; } interface Trk {