Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-scheduler): add ConfirmationDialog plugin (#2393)
- Loading branch information
1 parent
6bdc739
commit 9041bd5
Showing
36 changed files
with
1,451 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...ct-scheduler-demos/src/demo-sources/scheduler-editing/material-ui/copy-after-dragdrop.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* eslint-disable react/no-unused-state */ | ||
import * as React from 'react'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import { ViewState, EditingState, IntegratedEditing } from '@devexpress/dx-react-scheduler'; | ||
import { | ||
Scheduler, | ||
Appointments, | ||
AppointmentTooltip, | ||
WeekView, | ||
DragDropProvider, | ||
} from '@devexpress/dx-react-scheduler-material-ui'; | ||
import { appointments } from '../../../demo-data/appointments'; | ||
|
||
const SHIFT_KEY = 16; | ||
|
||
export default class Demo extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
data: appointments, | ||
currentDate: '2018-06-27', | ||
isShiftPressed: false, | ||
}; | ||
|
||
this.commitChanges = this.commitChanges.bind(this); | ||
this.onKeyDown = this.onKeyDown.bind(this); | ||
this.onKeyUp = this.onKeyUp.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
window.addEventListener('keydown', this.onKeyDown); | ||
window.addEventListener('keyup', this.onKeyUp); | ||
} | ||
|
||
componentWillUnmount() { | ||
window.removeEventListener('keydown'); | ||
window.removeEventListener('keyup'); | ||
} | ||
|
||
onKeyDown(event) { | ||
if (event.keyCode === SHIFT_KEY) { | ||
this.setState({ isShiftPressed: true }); | ||
} | ||
} | ||
|
||
onKeyUp(event) { | ||
if (event.keyCode === SHIFT_KEY) { | ||
this.setState({ isShiftPressed: false }); | ||
} | ||
} | ||
|
||
commitChanges({ added, changed, deleted }) { | ||
this.setState((state) => { | ||
let { data } = state; | ||
const { isShiftPressed } = this.state; | ||
if (added) { | ||
const startingAddedId = data.length > 0 ? data[data.length - 1].id + 1 : 0; | ||
data = [...data, { id: startingAddedId, ...added }]; | ||
} | ||
if (changed) { | ||
if (isShiftPressed) { | ||
const changedAppointment = data.find(appointment => changed[appointment.id]); | ||
const startingAddedId = data.length > 0 ? data[data.length - 1].id + 1 : 0; | ||
data = [ | ||
...data, | ||
{ ...changedAppointment, id: startingAddedId, ...changed[changedAppointment.id] }, | ||
]; | ||
} else { | ||
data = data.map(appointment => ( | ||
changed[appointment.id] | ||
? { ...appointment, ...changed[appointment.id] } | ||
: appointment)); | ||
} | ||
} | ||
if (deleted !== undefined) { | ||
data = data.filter(appointment => appointment.id !== deleted); | ||
} | ||
return { data }; | ||
}); | ||
} | ||
|
||
render() { | ||
const { currentDate, data } = this.state; | ||
|
||
return ( | ||
<Paper> | ||
<Scheduler | ||
data={data} | ||
height={660} | ||
> | ||
<ViewState | ||
currentDate={currentDate} | ||
/> | ||
<EditingState | ||
onCommitChanges={this.commitChanges} | ||
/> | ||
<IntegratedEditing /> | ||
|
||
<WeekView | ||
startDayHour={9} | ||
endDayHour={17} | ||
/> | ||
<Appointments /> | ||
<AppointmentTooltip | ||
showOpenButton | ||
showDeleteButton | ||
/> | ||
<DragDropProvider /> | ||
</Scheduler> | ||
</Paper> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/dx-react-scheduler-material-ui/src/plugins/confirmation-dialog.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { withComponents } from '@devexpress/dx-react-core'; | ||
import { ConfirmationDialog as ConfirmationDialogBase } from '@devexpress/dx-react-scheduler'; | ||
import { Overlay } from '../templates/common/dialog/overlay'; | ||
import { Layout } from '../templates/confirmation-dialog/layout'; | ||
import { OverlayContainer as Container } from '../templates/common/overlay-container'; | ||
import { Button } from '../templates/common/dialog/button'; | ||
|
||
export const ConfirmationDialog = withComponents({ | ||
Overlay, Layout, Container, Button, | ||
})(ConfirmationDialogBase); |
6 changes: 3 additions & 3 deletions
6
packages/dx-react-scheduler-material-ui/src/plugins/edit-recurrence-menu.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.