Skip to content

Commit

Permalink
Merge branch 'latest' into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
the-rango committed May 2, 2019
2 parents 418f0e5 + 049c7fe commit 944ebdf
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 85 deletions.
13 changes: 9 additions & 4 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class App extends Component {
}

handleScheduleChange = direction => {

if (direction === 0) {
this.setState({
showFinalSchedule: false, currentScheduleIndex: (this.state.currentScheduleIndex - 1 + 4) % 4
Expand Down Expand Up @@ -458,13 +458,17 @@ class App extends Component {
this.setState({
destination: 'rmp'
});
}
}

handleSelectEE = () => {
this.setState({
destination: 'eatereval'
});
}
}
handleClearSchedule = (toDelete) =>{
const eventsThatAreDeleted = this.state.courseEvents.filter(courseEvent => !(toDelete.includes(courseEvent.scheduleIndex) ))
this.setState({courseEvents: eventsThatAreDeleted})
}

render () {
return (
Expand Down Expand Up @@ -537,8 +541,8 @@ class App extends Component {
onClassDelete={this.handleClassDelete}
onScheduleChange={this.handleScheduleChange}
onAddCustomEvent={this.handleAddCustomEvent}
onClearSchedule={this.handleClearSchedule}
onEditCustomEvent={this.handleEditCustomEvent}
handleClearSchedule={this.handleClearSchedule}
/>
</div>
</Grid>
Expand Down Expand Up @@ -575,6 +579,7 @@ class App extends Component {
onCopySchedule={this.handleCopySchedule}
onEditCustomEvent={this.handleEditCustomEvent}
destination = {this.state.destination}
handleClearSchedule={this.handleClearSchedule}
/>
:
(
Expand Down
67 changes: 53 additions & 14 deletions src/components/App/TabularView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
MenuItem,
Typography,
Snackbar,
Tooltip
Tooltip,
Collapse,
IconButton
} from "@material-ui/core";
import AlmanacGraphWrapped from '../AlmanacGraph/AlmanacGraph'
import locations from '../CoursePane/locations.json'
Expand All @@ -17,6 +19,7 @@ import {withStyles} from '@material-ui/core/styles';
import MouseOverPopover from "../CoursePane/MouseOverPopover";
import CustomEventsDialog from '../CustomEvents/Popup';
import Instructors from "../CoursePane/Instructors";
import {Clear} from '@material-ui/icons'

const styles = {
colorPicker: {
Expand Down Expand Up @@ -105,10 +108,21 @@ class TabularView extends Component {
constructor(props) {
super(props);

let disclaimer = true;
if (typeof Storage !== "undefined") {
disclaimer = window.localStorage.getItem("disclaimer");
if (disclaimer === null){ //nothing stored
disclaimer = true;
} else { //not first time
disclaimer = false;
}
}

this.state = {
copied: false,
clipboard: '',
anchorEl: null
anchorEl: null,
disclaim: disclaimer
};
}

Expand Down Expand Up @@ -167,6 +181,12 @@ class TabularView extends Component {
document.body.removeChild(Juanito);
this.setState({copied: true, clipboard: code})
}

handleClearDisclaimer = () => {
this.setState({disclaim: false});
window.localStorage.setItem("disclaimer", "dismissed");
}

render () {
const {classes} = this.props;
const events = this.props.eventsInCalendar;
Expand Down Expand Up @@ -222,28 +242,18 @@ class TabularView extends Component {
className={classes.container}
style={{display:'inline-flex',
width:"100%",
position: "relative",
marginBottom: 10}}>

<Typography
variant="title"
style={{
position: "absolute",
width: "50%",
top: "50%",
transform: "translateY(-50%)"}}>
style={{ flexGrow: 1 }}>
Schedule {this.props.scheduleIndex + 1} ({totalUnits} Units)
</Typography>

<Button
aria-owns={this.state.anchor ? 'simple-menu' : undefined}
aria-haspopup="true"
onClick={this.handleDropdownOpen}
style={{
position: "absolute",
top: "50%",
right: "0",
transform: "translateY(-50%)"}}>
onClick={this.handleDropdownOpen}>
Copy Schedule
</Button>

Expand All @@ -267,6 +277,35 @@ class TabularView extends Component {
Copy to All Schedules
</MenuItem>
</Menu>

<Button style={{color: 'red'}} onClick={
()=>{
if (window.confirm('Are you sure you want to clear this schedule?'))
this.props.handleClearSchedule([this.props.scheduleIndex])
}
}>Clear Schedule</Button>

</div>

<div> {/*go to webreg disclaimer*/}
<Collapse in={this.state.disclaim} >
<table style={{margin: 20}}>
<tr>
<td>
<IconButton onClick={this.handleClearDisclaimer}>
<Clear />
</IconButton>
</td>
<td>
<Typography variant="h6">
Adding courses on the AntAlmanac is NOT official enrollment!
<br />
Make sure to sign up on <a href="https://www.reg.uci.edu/registrar/soc/webreg.html" target="_blank" rel="noopener noreferrer">WebReg</a>
</Typography>
</td>
</tr>
</table>
</Collapse>
</div>

{courses.length === 0 ?
Expand Down
4 changes: 1 addition & 3 deletions src/components/App/colorPicker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import {Popover, Tooltip} from '@material-ui/core';
import {Popover} from '@material-ui/core';
import {SketchPicker} from 'react-color'

class ColorPicker extends React.Component {
Expand Down Expand Up @@ -41,7 +41,6 @@ class ColorPicker extends React.Component {
const open = Boolean(anchorEl);

return (
<Tooltip title="Modify Color">
<div
style={{backgroundColor: this.props.event.color}}
onClick={e => {this.handleClick(e)}}>
Expand All @@ -62,7 +61,6 @@ class ColorPicker extends React.Component {
onChange={this.handleColorChange}/>
</Popover>
</div>
</Tooltip>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Calendar extends Component {
<div className={classes.container} onClick={this.handleClosePopover}>
<CalendarPaneToolbar
onScheduleChange={this.props.onScheduleChange}
onClearSchedule={this.props.onClearSchedule}
handleClearSchedule={this.props.handleClearSchedule}
onUndo={this.props.onUndo}
onAddCustomEvent={this.props.onAddCustomEvent}
onTakeScreenshot={this.handleTakeScreenshot}
Expand Down
11 changes: 5 additions & 6 deletions src/components/Calendar/CalendarPaneToolbar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React, {Component} from 'react';
import {withStyles} from '@material-ui/core/styles';
import {IconButton, Tooltip, Typography} from "@material-ui/core";
import {IconButton, Tooltip, Typography, InputBase} from "@material-ui/core";
import {ChevronLeft, ChevronRight, Undo} from "@material-ui/icons";
import PropTypes from "prop-types";
import Submenu from "./Submenu"
import DownloadMenu from "./DownloadMenu";
import Input from '@material-ui/core/Input';
import InputBase from '@material-ui/core/InputBase';

const styles = {
toolbar: {
Expand Down Expand Up @@ -44,8 +42,8 @@ class CalendarPaneToolbar extends Component {
render() {
const {classes} = this.props;

if(this.state.schedule!=this.props.currentScheduleIndex)
{
if(this.state.schedule!==this.props.currentScheduleIndex)
{
let scheduleName = 'Schedule ' + (this.props.currentScheduleIndex + 1);
if (typeof Storage !== "undefined") {
const nameSchedule = window.localStorage.getItem("schedule"+this.props.currentScheduleIndex);
Expand Down Expand Up @@ -96,11 +94,12 @@ class CalendarPaneToolbar extends Component {
<Tooltip title="More">
<Submenu
onAddCustomEvent={this.props.onAddCustomEvent}
onClearSchedule={this.props.onClearSchedule}
handleClearSchedule={this.props.handleClearSchedule}
onTakeScreenshot={this.props.onTakeScreenshot}
eventsInCalendar={this.props.eventsInCalendar}
showFinalSchedule={this.props.showFinalSchedule}
displayFinal={this.props.displayFinal}
currentScheduleIndex={this.props.currentScheduleIndex}
/>
</Tooltip>
</div>
Expand Down
155 changes: 155 additions & 0 deletions src/components/Calendar/ClearSchedButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import React, { Fragment } from 'react'
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Checkbox,
FormGroup,
FormControlLabel,
} from '@material-ui/core';
import {
Delete
} from '@material-ui/icons'

export default class ClearSched extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
all: false,
one: this.props.currentScheduleIndex===0,
two: this.props.currentScheduleIndex===1,
three: this.props.currentScheduleIndex===2,
four: this.props.currentScheduleIndex===3
};
}

handleClickOpen = () => {
this.setState({ open: true });
};

handleClose = () => {
this.setState({
open: false,
all: false,
one: false,
two: false,
three: false,
four: false});
this.props.handleSubmenuClose();
}

handleClear = () => {
let toDelete = [];

if (this.state.one){
toDelete.push(0)
}
if (this.state.two){
toDelete.push(1)
}
if (this.state.three){
toDelete.push(2)
}
if (this.state.four){
toDelete.push(3)
}

this.props.handleClearSchedule(toDelete)
this.handleClose()
}

handleChange = name => event => {
if (name==='all'){
this.setState({
all: event.target.checked,
one: event.target.checked,
two: event.target.checked,
three: event.target.checked,
four: event.target.checked
})
}else{
this.setState({ [name]: event.target.checked });
}
};

render() {
return (
<Fragment>
<Button onClick={this.handleClickOpen} disableRipple={true} style={{width: "100%"}} className={"menu-button"}>
<Delete /> Clear Classes
</Button>
<Dialog
open={this.state.open}
onClose={this.handleClose}
aria-labelledby="form-dialog-title"
>
<DialogTitle id="form-dialog-title">Select a Schedule to Clear</DialogTitle>
<DialogContent>
<div>
<FormGroup>
<FormControlLabel
control={
<Checkbox
checked={this.state.all} onChange={this.handleChange('all')}
/>
}
value="all"
label="Clear All"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.one} onChange={this.handleChange('one')}
/>
}
value="one"
label="Schedule 1"
color="primary"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.two} onChange={this.handleChange('two')}
/>
}
value="two"
label="Schedule 2"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.three} onChange={this.handleChange('three')}
/>
}
value="three"
label="Schedule 3"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.four} onChange={this.handleChange('four')}
/>
}
value="four"
label="Schedule 4"
/>

</FormGroup>
</div>
</DialogContent>
<DialogActions>
<Button onClick={this.handleClose} color="primary">
Cancel
</Button>
<Button onClick={this.handleClear} style = {{backgroundColor:"#72a9ed", boxShadow:"none"}}>
Clear
</Button>
</DialogActions>
</Dialog>
</Fragment>
);
}
}
Loading

0 comments on commit 944ebdf

Please sign in to comment.