WPT editor

This commit is contained in:
Eric van der Vlist 2023-01-16 22:55:08 +01:00
parent bdb11a52bb
commit 088c3c4e27
1 changed files with 29 additions and 11 deletions

View File

@ -1,18 +1,12 @@
import { useI18n } from '@solid-primitives/i18n'; import { useI18n } from '@solid-primitives/i18n';
import { import { Box, TextField, Stack, Button, IconButton } from '@suid/material';
Dialog,
Box,
TextField,
Stack,
Button,
IconButton,
} from '@suid/material';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import { Component, createSignal } from 'solid-js'; import { Component, createSignal } from 'solid-js';
import { emptyWpt } from '../../db/wpt'; import { emptyWpt } from '../../db/wpt';
import { peekCachedSignal } from '../../workers/cached-signals'; import { peekCachedSignal } from '../../workers/cached-signals';
import dispatch from '../../workers/dispatcher-main'; import dispatch from '../../workers/dispatcher-main';
import EditIcon from '@suid/icons-material/Edit'; import EditIcon from '@suid/icons-material/Edit';
import Dialog from '../dialog';
enum Mode { enum Mode {
CLOSED, CLOSED,
@ -37,6 +31,11 @@ const WptEditor: Component<Props> = ({ wptId }) => {
const edit = () => { const edit = () => {
setMode(Mode.EDIT); setMode(Mode.EDIT);
setEditedWpt(cloneDeep(wpt())); setEditedWpt(cloneDeep(wpt()));
console.log({
caller: 'WptEditor / edit',
wptId,
editedWpt: editedWpt(),
});
}; };
const closeHandler = () => { const closeHandler = () => {
@ -45,7 +44,7 @@ const WptEditor: Component<Props> = ({ wptId }) => {
const saveHandler = () => { const saveHandler = () => {
console.log({ console.log({
caller: 'Wpt / saveHandler', caller: 'WptEditor / saveHandler',
wptId, wptId,
editedWpt: editedWpt(), editedWpt: editedWpt(),
}); });
@ -66,11 +65,20 @@ const WptEditor: Component<Props> = ({ wptId }) => {
<EditIcon /> <EditIcon />
</IconButton> </IconButton>
<Dialog <Dialog
open={mode() === Mode.EDIT} open={mode() === Mode.EDIT && wpt()}
title={getTitle()} title={getTitle()}
closeHandler={closeHandler} closeHandler={closeHandler}
> >
<Box sx={{ flexGrow: 1, padding: '10px' }}> <Box
component='form'
sx={{
width: '100%',
'& .MuiTextField-root': { m: 1, width: '100%' },
paddingTop: '5px',
}}
noValidate
autoComplete='off'
>
<div> <div>
<TextField <TextField
required required
@ -98,6 +106,16 @@ const WptEditor: Component<Props> = ({ wptId }) => {
setEditedWpt({ ...editedWpt(), extensions }); setEditedWpt({ ...editedWpt(), extensions });
}} }}
/> />
<TextField
label={t('gpxDesc')}
type='text'
rows={5}
value={editedWpt()?.desc || ''}
onChange={(event: any) => {
setEditedWpt({ ...editedWpt(), desc: event.target.value });
}}
InputProps={{ inputComponent: 'textarea' }}
/>
<Stack spacing={2} direction='row' sx={{ marginTop: '20px' }}> <Stack spacing={2} direction='row' sx={{ marginTop: '20px' }}>
<Button <Button
variant='outlined' variant='outlined'