Skip to content

Commit

Permalink
Show preview of content to be deleted for activity and activity section
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcavoy committed Jan 8, 2021
1 parent ccf19de commit ab11d96
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
65 changes: 54 additions & 11 deletions apps/src/lib/levelbuilder/OrderControls.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Dialog from '../../templates/Dialog';
import BaseDialog from '@cdo/apps/templates/BaseDialog';
import ActivitySection from '@cdo/apps/templates/lessonOverview/activities/ActivitySection';
import DialogFooter from '@cdo/apps/templates/teacherDashboard/DialogFooter';
import Button from '@cdo/apps/templates/Button';
import Activity from '@cdo/apps/templates/lessonOverview/activities/Activity';
import color from '@cdo/apps/util/color';

const styles = {
controls: {
Expand All @@ -9,14 +14,31 @@ const styles = {
controlIcon: {
margin: '0 5px',
cursor: 'pointer'
},
previewContainer: {
color: color.default_text
},
preview: {
border: '1px solid #ccc',
padding: '5px 25px'
},
dialog: {
paddingLeft: 20,
paddingRight: 20,
paddingBottom: 20,
width: 970,
fontFamily: '"Gotham 4r", sans-serif, sans-serif',
marginLeft: -500
}
};

export default class OrderControls extends Component {
static propTypes = {
move: PropTypes.func.isRequired,
remove: PropTypes.func.isRequired,
name: PropTypes.string.isRequired
name: PropTypes.string.isRequired,
item: PropTypes.object,
itemType: PropTypes.oneOf(['activity', 'activitySection'])
};

state = {
Expand Down Expand Up @@ -46,7 +68,7 @@ export default class OrderControls extends Component {

render() {
const {showConfirm} = this.state;
const {name} = this.props;
const {name, item, itemType} = this.props;
const text = `Are you sure you want to remove "${name}" and all its contents from the script?`;
return (
<div style={styles.controls}>
Expand All @@ -65,16 +87,37 @@ export default class OrderControls extends Component {
style={styles.controlIcon}
className="fa fa-trash"
/>
<Dialog
body={text}
cancelText="Cancel"
confirmText="Delete"
confirmType="danger"
<BaseDialog
isOpen={showConfirm}
handleClose={this.handleClose}
onCancel={this.handleClose}
onConfirm={this.handleConfirm}
/>
useUpdatedStyles
style={styles.dialog}
>
<h2>{text}</h2>
{item && itemType && (
<div style={styles.previewContainer}>
<h4>Preview of Content To Delete: </h4>
<div style={styles.preview}>
{itemType === 'activity' && <Activity activity={item} />}
{itemType === 'activitySection' && (
<ActivitySection section={item} />
)}
</div>
</div>
)}
<DialogFooter rightAlign>
<Button
text={'Cancel'}
onClick={this.handleClose}
color={Button.ButtonColor.gray}
/>
<Button
text={'Delete'}
onClick={this.handleConfirm}
color={Button.ButtonColor.red}
/>
</DialogFooter>
</BaseDialog>
</div>
);
}
Expand Down
2 changes: 2 additions & 0 deletions apps/src/lib/levelbuilder/lesson-editor/ActivityCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class ActivityCard extends Component {
name={activity.displayName || 'Unnamed Activity'}
move={this.handleMoveActivity}
remove={this.handleRemoveActivity}
item={this.props.activity}
itemType={'activity'}
/>
</div>
<div style={styles.activityBody} hidden={this.props.collapsed}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ class ActivitySectionCard extends Component {
}
move={this.handleMoveActivitySection}
remove={this.handleRemoveActivitySection}
item={this.props.activitySection}
itemType={'activitySection'}
/>
</label>
<div style={styles.checkboxesAndButtons}>
Expand Down

0 comments on commit ab11d96

Please sign in to comment.