From f3ae5cfcf468ac87a4e05041190da675e36e55d5 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Mon, 7 Aug 2023 18:13:43 +0200 Subject: [PATCH] Saving edited tags in GpxDialog --- src/components/gpx-dialog/GpxDialog.tsx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/gpx-dialog/GpxDialog.tsx b/src/components/gpx-dialog/GpxDialog.tsx index 1c2f8e7..1116085 100644 --- a/src/components/gpx-dialog/GpxDialog.tsx +++ b/src/components/gpx-dialog/GpxDialog.tsx @@ -19,7 +19,12 @@ import GpxChooser from '../gpx-chooser'; import GpxIcon from '../gpx/GpxIcon'; //import GpxesIcon from '../../icons/adventure-journey-location-svgrepo-com.svg'; import style from './GpxDialog.module.css'; -import { getTagValue, getTagsFromObj } from '../../lib/tags/tags'; +import { + getTagValue, + getTagsFromObj, + setTagValue, + setTagsIntoObj, +} from '../../lib/tags/tags'; export const [currentGpxId, setCurrentGpxId] = createSignal('new'); @@ -136,6 +141,18 @@ const GpxDialog: Component<{}> = (props) => { }); }; + const getGpxTagValue = (tagName: string, defaultValue: string) => { + return getTagValue(getTagsFromObj(gpx()), tagName) || defaultValue; + }; + + const gpxLocomotionChangeHandler = (event: any) => { + const newGpx: Gpx = cloneDeep(gpx()) as Gpx; + const tags = getTagsFromObj(newGpx); + setTagValue(tags, 'locomotion', event.target.value); + setTagsIntoObj(newGpx, tags); + setGpx(newGpx); + }; + const saveHandler = async (event: any) => { const id = (await dispatch({ action: 'putGpx', @@ -201,9 +218,8 @@ const GpxDialog: Component<{}> = (props) => { />
Locomotion