Using a dialog for confirm delete alert.
This commit is contained in:
parent
1f3c1c750e
commit
1f1b57e4b4
|
@ -0,0 +1,33 @@
|
||||||
|
import { Component, JSXElement } from 'solid-js';
|
||||||
|
|
||||||
|
import { Alert as MuiAlert } from '@suid/material';
|
||||||
|
import { AlertColor } from '@suid/material/Alert';
|
||||||
|
import Dialog from '../dialog';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
open: boolean;
|
||||||
|
closeHandler: (event: any, reason?: string) => void;
|
||||||
|
severity?: AlertColor;
|
||||||
|
icon?: JSXElement;
|
||||||
|
action?: JSXElement;
|
||||||
|
children?: JSXElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Alert: Component<Props> = ({
|
||||||
|
open,
|
||||||
|
closeHandler,
|
||||||
|
severity,
|
||||||
|
icon,
|
||||||
|
action,
|
||||||
|
children,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Dialog open={open()} closeHandler={closeHandler} maxWidth={false}>
|
||||||
|
<MuiAlert severity={severity} icon={icon} action={action}>
|
||||||
|
{children}
|
||||||
|
</MuiAlert>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Alert;
|
|
@ -0,0 +1 @@
|
||||||
|
export { default } from './Alert';
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, JSXElement } from 'solid-js';
|
import { Component, JSXElement, Show } from 'solid-js';
|
||||||
import {
|
import {
|
||||||
Dialog as MuiDialog,
|
Dialog as MuiDialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
@ -10,7 +10,8 @@ import CloseIcon from '@suid/icons-material/Close';
|
||||||
const Dialog: Component<{
|
const Dialog: Component<{
|
||||||
open: boolean;
|
open: boolean;
|
||||||
fullScreen?: boolean;
|
fullScreen?: boolean;
|
||||||
title: JSXElement;
|
maxWidth?: boolean;
|
||||||
|
title?: JSXElement;
|
||||||
closeHandler: (event: any, reason?: string) => void;
|
closeHandler: (event: any, reason?: string) => void;
|
||||||
children: JSXElement;
|
children: JSXElement;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
|
@ -21,24 +22,27 @@ const Dialog: Component<{
|
||||||
PaperProps={{ sx: { minWidth: '300px' } }}
|
PaperProps={{ sx: { minWidth: '300px' } }}
|
||||||
fullScreen={props.fullScreen}
|
fullScreen={props.fullScreen}
|
||||||
>
|
>
|
||||||
<DialogTitle
|
<Show when={props.title}>
|
||||||
sx={{
|
<DialogTitle
|
||||||
backgroundColor: 'rgba(14, 116, 144, 0.7)',
|
sx={{
|
||||||
color: 'white',
|
backgroundColor: 'rgba(14, 116, 144, 0.7)',
|
||||||
clear: 'both',
|
color: 'white',
|
||||||
margin: '0',
|
clear: 'both',
|
||||||
paddingLeft: '0',
|
margin: '0',
|
||||||
}}
|
paddingLeft: '0',
|
||||||
>
|
}}
|
||||||
<IconButton onClick={props.closeHandler}>
|
>
|
||||||
<CloseIcon />
|
<IconButton onClick={props.closeHandler}>
|
||||||
</IconButton>
|
<CloseIcon />
|
||||||
{props.title}
|
</IconButton>
|
||||||
</DialogTitle>
|
{props.title}
|
||||||
|
</DialogTitle>
|
||||||
|
</Show>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
sx={{
|
sx={{
|
||||||
width: 'calc(100% - 60px)',
|
width: 'calc(100% - 60px)',
|
||||||
paddingBottom: '2000px',
|
paddingBottom:
|
||||||
|
props.maxWidth === undefined || props.maxWidth ? '2000px' : '2px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|
|
@ -3,10 +3,11 @@ import { peekCachedSignal } from '../../workers/cached-signals';
|
||||||
import Tree from '../tree';
|
import Tree from '../tree';
|
||||||
import TrkIcon from '../../icons/human-footprints-svgrepo-com.svg?component-solid';
|
import TrkIcon from '../../icons/human-footprints-svgrepo-com.svg?component-solid';
|
||||||
import { TrksegViewer } from '../trkseg';
|
import { TrksegViewer } from '../trkseg';
|
||||||
import { Alert, Button, IconButton } from '@suid/material';
|
import { Button, IconButton } from '@suid/material';
|
||||||
import DeleteIcon from '@suid/icons-material/Delete';
|
import DeleteIcon from '@suid/icons-material/Delete';
|
||||||
import QuestionMarkIcon from '@suid/icons-material/QuestionMark';
|
import QuestionMarkIcon from '@suid/icons-material/QuestionMark';
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
|
import Alert from '../alert';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
trkId: string;
|
trkId: string;
|
||||||
|
@ -64,7 +65,7 @@ const TrkViewer: Component<Props> = ({ trkId, restrictToHierarchy }) => {
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<IconButton onClick={confirmDeleteHandler}>
|
<IconButton onClick={confirmDeleteHandler}>
|
||||||
<DeleteIcon />
|
<DeleteIcon fill='white' />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -82,34 +83,34 @@ const TrkViewer: Component<Props> = ({ trkId, restrictToHierarchy }) => {
|
||||||
</For>
|
</For>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Show when={confirmDelete()}>
|
<Alert
|
||||||
<Alert
|
open={confirmDelete}
|
||||||
severity='warning'
|
closeHandler={cancelDeleteHandler}
|
||||||
icon={<QuestionMarkIcon />}
|
severity='warning'
|
||||||
action={
|
icon={<QuestionMarkIcon />}
|
||||||
<>
|
action={
|
||||||
<Button
|
<>
|
||||||
color='error'
|
<Button
|
||||||
variant='contained'
|
color='error'
|
||||||
size='small'
|
variant='contained'
|
||||||
onClick={deleteHandler}
|
size='small'
|
||||||
>
|
onClick={deleteHandler}
|
||||||
YES
|
>
|
||||||
</Button>
|
YES
|
||||||
<Button
|
</Button>
|
||||||
color='primary'
|
<Button
|
||||||
variant='outlined'
|
color='primary'
|
||||||
size='small'
|
variant='outlined'
|
||||||
onclick={cancelDeleteHandler}
|
size='small'
|
||||||
>
|
onclick={cancelDeleteHandler}
|
||||||
NO
|
>
|
||||||
</Button>
|
NO
|
||||||
</>
|
</Button>
|
||||||
}
|
</>
|
||||||
>
|
}
|
||||||
Delete this track ?
|
>
|
||||||
</Alert>
|
Delete this track ?
|
||||||
</Show>
|
</Alert>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue