Skip to content

Commit

Permalink
Initiated update to FullCalendar 4 and removed jQuery :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Merve7 committed Jul 11, 2018
1 parent 171473c commit bf9f18f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 34 deletions.
59 changes: 53 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
"chart.js": "2.7.1",
"classnames": "^2.2.5",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.1.0",
"fullcalendar": "4.0.0-alpha",
"quill": "1.3.3",
"jquery": "^3.1.1",
"moment": "^2.17.1",
"nanoscroller": "^0.8.7",
"prop-types": "^15.5.0",
Expand Down
55 changes: 29 additions & 26 deletions src/components/schedule/Schedule.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ObjectUtils from '../utils/ObjectUtils';
import jQuery from "jquery";
import "fullcalendar";
var FullCalendar = require('fullcalendar');

export class Schedule extends Component {

Expand Down Expand Up @@ -119,39 +118,39 @@ export class Schedule extends Component {
}

gotoDate(date) {
this.schedule.fullCalendar('gotoDate', date);
this.calendar.gotoDate(date);
}

prev() {
this.schedule.fullCalendar('prev');
this.calendar.prev();
}

next() {
this.schedule.fullCalendar('next');
this.calendar.next();
}

prevYear() {
this.schedule.fullCalendar('prevYear');
this.calendar.prevYear();
}

nextYear() {
this.schedule.fullCalendar('nextYear');
this.calendar.nextYear();
}

today() {
this.schedule.fullCalendar('today');
this.calendar.today();
}

incrementDate(duration) {
this.schedule.fullCalendar('incrementDate', duration);
this.calendar.incrementDate(duration);
}

changeView(viewName) {
this.schedule.fullCalendar('changeView', viewName);
this.calendar.changeView(viewName);
}

getDate() {
return this.schedule.fullCalendar('getDate');
return this.calendar.getDate();
}

componentDidMount() {
Expand Down Expand Up @@ -317,29 +316,33 @@ export class Schedule extends Component {
}
}

this.schedule = jQuery(this.scheduleEl);
this.schedule.fullCalendar(this.config);
this.events = [...this.props.events];
this.schedule.fullCalendar('addEventSource', this.events);
}

shouldComponentUpdate(nextProps, nextState) {
return false;
this.calendar = new FullCalendar.Calendar(this.calendarEl, this.config);
this.calendar.render();
this.calendar.addEventSource(this.props.events);
}

componentWillUnmount() {
jQuery(this.scheduleEl).fullCalendar('destroy');
if(this.calendar) {
this.calendar.destroy();
}
}
componentDidUpdate(prevProps, prevState, snaphot) {
if(!ObjectUtils.equals(this.props.events, this.events)) {

getSnapshotBeforeUpdate(prevProps, prevState) {
if(!ObjectUtils.equals(prevProps.events, this.props.events)) {
this.events = [...this.props.events];
this.schedule.fullCalendar('removeEventSources');
this.schedule.fullCalendar('addEventSource', this.events);
return this.events;
}
return null;
}

componentDidUpdate(prevProps, prevState, snapshot) {
if (snapshot !== null) {
this.calendar.removeEventSources();
this.calendar.addEventSource(this.events);
}
}

render() {
return <div id={this.props.id} ref={(el) => this.scheduleEl = el} style={this.props.style} className={this.props.className}></div>;
return <div id={this.props.id} ref={(el) => this.calendarEl = el} style={this.props.style} className={this.props.className}></div>;
}
}

0 comments on commit bf9f18f

Please sign in to comment.