diff --git a/src/App.tsx b/src/App.tsx index fa4793d..280b130 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -55,6 +55,7 @@ export const routeResolver = new RouteResolver({ _id: { _base: ':itemUid', edit: 'edit', + copy: 'copy', log: 'log', }, new: 'new', diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index 91b875a..8ec43e9 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -5,6 +5,7 @@ import * as React from 'react'; import { Route, Switch } from 'react-router'; import Button from '@material-ui/core/Button'; import IconEdit from '@material-ui/icons/Edit'; +import IconCopy from '@material-ui/icons/FileCopy'; import IconChangeHistory from '@material-ui/icons/ChangeHistory'; import { withStyles } from '@material-ui/core/styles'; @@ -189,6 +190,34 @@ const CollectionRoutes = withStyles(styles)(withRouter( ); }} /> + {props.routePrefix === 'pim.events' && + { + const itemUid = decodeURIComponent(match.params.itemUid); + if (this.itemUndefined(itemUid)) { + return PageNotFound(); + } + return ( + + {(itemUid in props.items) && + + } + + ); + }} + /> + } Edit + + {props.routePrefix === 'pim.events' && + + } diff --git a/src/components/EventEdit.tsx b/src/components/EventEdit.tsx index 397dbc5..cac085a 100644 --- a/src/components/EventEdit.tsx +++ b/src/components/EventEdit.tsx @@ -50,6 +50,7 @@ interface PropsType { onCancel: () => void; location: Location; history: History; + copy: boolean; } class EventEdit extends React.PureComponent { @@ -105,8 +106,12 @@ class EventEdit extends React.PureComponent { endDate.adjust(-1, 0, 0, 0); } - this.state.uid = event.uid; - this.state.title = event.title ? event.title : ''; + if (this.props.copy) { + this.state.title = event.title ? `Copy of ${event.title}` : ''; + } else { + this.state.uid = event.uid; + this.state.title = event.title ? event.title : ''; + } this.state.allDay = allDay; this.state.start = event.startDate.convertToZone(ICAL.Timezone.localTimezone).toJSDate(); this.state.end = endDate.convertToZone(ICAL.Timezone.localTimezone).toJSDate(); @@ -120,7 +125,8 @@ class EventEdit extends React.PureComponent { this.state.rrule.until = rruleProp.until; } } - } else { + } + if (this.props.copy || this.props.item === undefined) { this.state.uid = uuid.v4(); } @@ -222,7 +228,7 @@ class EventEdit extends React.PureComponent { return; } - const event = (this.props.item) ? + const event = (this.props.item && !this.props.copy) ? this.props.item.clone() : new EventType() @@ -281,7 +287,7 @@ class EventEdit extends React.PureComponent { return ( <>

- {this.props.item ? 'Edit Event' : 'New Event'} + {(this.props.item && !this.props.copy) ? 'Edit Event' : 'New Event'}

{recurring && (