diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index 8f870a761..000000000
--- a/.babelrc
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "presets": ["es2015", "react", "stage-0"],
- "plugins": ["transform-decorators-legacy"]
-}
diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 000000000..fc56e3145
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,7 @@
+{
+ "trailingComma": "es5",
+ "tabWidth": 2,
+ "semi": true,
+ "singleQuote": true,
+ "printWidth": 120
+}
diff --git a/Pipfile b/Pipfile
deleted file mode 100644
index b723d0199..000000000
--- a/Pipfile
+++ /dev/null
@@ -1,11 +0,0 @@
-[[source]]
-name = "pypi"
-url = "https://pypi.org/simple"
-verify_ssl = true
-
-[dev-packages]
-
-[packages]
-
-[requires]
-python_version = "3.7"
diff --git a/Pipfile.lock b/Pipfile.lock
deleted file mode 100644
index 9a51a2828..000000000
--- a/Pipfile.lock
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "_meta": {
- "hash": {
- "sha256": "7e7ef69da7248742e869378f8421880cf8f0017f96d94d086813baa518a65489"
- },
- "pipfile-spec": 6,
- "requires": {
- "python_version": "3.7"
- },
- "sources": [
- {
- "name": "pypi",
- "url": "https://pypi.org/simple",
- "verify_ssl": true
- }
- ]
- },
- "default": {},
- "develop": {}
-}
diff --git a/babel.config.js b/babel.config.js
new file mode 100644
index 000000000..b5c3ace8f
--- /dev/null
+++ b/babel.config.js
@@ -0,0 +1,23 @@
+module.exports = (api, targets) => {
+ // https://babeljs.io/docs/en/config-files#config-function-api
+ const isTestEnv = api.env('test')
+
+ return {
+ babelrc: false,
+ ignore: ['./node_modules'],
+ presets: [
+ [
+ '@babel/preset-env',
+ {
+ loose: true,
+ modules: isTestEnv ? 'commonjs' : false,
+ targets: isTestEnv ? { node: 'current' } : targets,
+ },
+ ],
+ ],
+ plugins: [
+ '@babel/plugin-transform-react-jsx',
+ ['@babel/plugin-transform-typescript', { isTSX: true }],
+ ],
+ }
+}
diff --git a/example/AddMore.tsx b/example/AddMore.tsx
deleted file mode 100644
index 457f18cff..000000000
--- a/example/AddMore.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, { SchedulerAddMorePopover, SchedulerData, SchedulerHeader, SchedulerViewTypes } from "../src/Scheduler";
-import { DemoData } from "./DemoData";
-import * as ExampleFunction from "./ExampleFunctions";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-interface IAddMoreState {
- viewModel: SchedulerData;
- headerItem: SchedulerHeader;
- left: number;
- top: number;
- height: number;
-}
-
-class AddMore extends Component<{}, IAddMoreState> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- dayMaxEvents: 2,
- weekMaxEvents: 4,
- monthMaxEvents: 4,
- quarterMaxEvents: 4,
- yearMaxEvents: 4,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- headerItem: undefined,
- left: 0,
- top: 0,
- height: 0,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
-
- let popover =
;
- if (this.state.headerItem !== undefined) {
- popover =
- ;
- }
-
- return (
-
-
-
-
Add more
-
- {popover}
-
-
- );
- }
-
-}
-
-export default withDragDropContext(AddMore);
diff --git a/example/AddResource.tsx b/example/AddResource.tsx
deleted file mode 100644
index 691973bd5..000000000
--- a/example/AddResource.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SCHEDULER_DATE_FORMAT,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import moment from "moment";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-import "antd/lib/style/index.css";
-import "antd/lib/input/style/index.css";
-
-interface AddResourceState {
- viewModel: SchedulerData;
- visible: boolean;
-}
-
-class AddResource extends Component<{}, AddResourceState> {
- public form: any;
- constructor(props: Readonly<{}>) {
- super(props);
- const today = moment().format(SCHEDULER_DATE_FORMAT);
- const schedulerData = new SchedulerData(today, SchedulerViewTypes.Week);
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- visible: false,
- };
- }
- public showModal = () => {
- this.setState({ visible: true });
- }
- public handleCancel = () => {
- this.setState({ visible: false });
- }
- public handleCreate = () => {
- const form = this.form;
- form.validateFields((err: any, values: any) => {
- if (err) {
- return;
- }
- this.addResource(values.name);
- form.resetFields();
- this.setState({ visible: false });
- });
-
- }
- public saveFormRef = (form: any) => {
- this.form = form;
- }
-
- public addResource = (resourceName: string) => {
- const schedulerData = this.state.viewModel;
- const newFreshId = schedulerData.resources.length + 1;
- const newFreshName = resourceName;
- schedulerData.addResource({ id: newFreshId.toString(), name: newFreshName });
- this.setState({
- viewModel: schedulerData,
- });
- }
-
- public render() {
- const { viewModel } = this.state;
-
- const leftCustomHeader = (
-
- );
-
- return (
-
- );
- }
-}
-
-export default withDragDropContext(AddResource);
diff --git a/example/Basic.tsx b/example/Basic.tsx
index acc3648cf..f4daa81ce 100644
--- a/example/Basic.tsx
+++ b/example/Basic.tsx
@@ -1,65 +1,64 @@
-import * as moment from "moment";
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import { DemoData } from "./DemoData";
-import * as ExampleFunction from "./ExampleFunctions";
-import Nav from "./Nav";
-import Tips from "./Tips";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
+import * as moment from 'moment';
+import * as React from 'react';
+import { Component } from 'react';
+import { SchedulerData, Scheduler, SchedulerViewTypes } from '../lib';
+import { DemoData } from './DemoData';
+import * as ExampleFunction from './ExampleFunctions';
+import Nav from './Nav';
+import Tips from './Tips';
+import ViewSrcCode from './ViewSrcCode';
+import withDragDropContext from './withDnDContext';
interface IBasicState {
- viewModel: SchedulerData;
+ viewModel: any;
}
class Basic extends Component<{}, IBasicState> {
- constructor(props: Readonly<{}>) {
- super(props);
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week);
- // To set locale
- moment.locale("en");
- const demoData = DemoData;
- schedulerData.setResources(demoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Basic example
-
-
-
-
-
- );
- }
+ constructor(props: Readonly<{}>) {
+ super(props);
+ const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week);
+ // To set locale
+ moment.locale('en');
+ const demoData = DemoData;
+ schedulerData.setResources(demoData.resources);
+ schedulerData.setEvents(DemoData.events);
+ this.state = {
+ viewModel: schedulerData,
+ };
+ }
+ public render() {
+ const { viewModel } = this.state;
+ return (
+
+
+
+
+ Basic example
+
+
+
+
+
+
+ );
+ }
}
export default withDragDropContext(Basic);
diff --git a/example/CustomEventStyle.tsx b/example/CustomEventStyle.tsx
deleted file mode 100644
index f16245c86..000000000
--- a/example/CustomEventStyle.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import * as React from "react";
-import { Component, useState } from "react";
-import Scheduler, {
- SchedulerData,
- SCHEDULER_DATE_FORMAT,
- SchedulerResource,
- SchedulerViewTypes,
- SchedulerEvent,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-interface CustomEventStyleState {
- viewModel: SchedulerData;
-}
-
-class CustomEventStyle extends Component<{}, CustomEventStyleState> {
- constructor(props) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- views: [
- { viewName: "Day(Agenda)", viewType: SchedulerViewTypes.Day, showAgenda: true, isEventPerspective: false },
- { viewName: "Week", viewType: SchedulerViewTypes.Week, showAgenda: false, isEventPerspective: false },
- { viewName: "Month(TaskView)", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: true },
- { viewName: "Year", viewType: SchedulerViewTypes.Year, showAgenda: false, isEventPerspective: false },
- ],
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.eventsForCustomEventStyle);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Custom event style
-
-
-
- );
- }
-
- public eventItemTemplateResolver = (
- schedulerData: SchedulerData,
- event: SchedulerEvent,
- bgColor: string,
- isStart: boolean,
- isEnd: boolean,
- mustAddCssClass: any,
- mustBeHeight: number,
- agendaMaxEventWidth: any) => {
- let borderWidth = isStart ? '4' : '0';
- let borderColor = 'rgba(0,139,236,1)', backgroundColor = '#80C5F6';
- let titleText = schedulerData.behaviors.getEventTextFunc(schedulerData, event);
- if (!!event.type) {
- borderColor = event.type == 1 ? 'rgba(0,139,236,1)' : (event.type == 3 ? 'rgba(245,60,43,1)' : '#999');
- backgroundColor = event.type == 1 ? '#80C5F6' : (event.type == 3 ? '#FA9E95' : '#D9D9D9');
- }
- let divStyle = { borderLeft: borderWidth + 'px solid ' + borderColor, backgroundColor: backgroundColor, height: mustBeHeight, maxWidth: undefined };
- if (!!agendaMaxEventWidth)
- divStyle = { ...divStyle, maxWidth: agendaMaxEventWidth };
-
- return
- {titleText}
-
;
- }
-}
-
-export default withDragDropContext(CustomEventStyle)
diff --git a/example/CustomHeader.tsx b/example/CustomHeader.tsx
deleted file mode 100644
index 4e21b51a9..000000000
--- a/example/CustomHeader.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import * as React from "react";
-import { Component, useState } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class CustomHeader extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week);
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
-
- const leftCustomHeader = (
- Put your content here
- );
- const rightCustomHeader = (
- or here
- );
-
- return (
-
-
-
-
Custom header
-
-
-
- );
- }
-}
-
-export default withDragDropContext(CustomHeader);
diff --git a/example/CustomPopoverStyle.tsx b/example/CustomPopoverStyle.tsx
deleted file mode 100644
index 91c021b22..000000000
--- a/example/CustomPopoverStyle.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import * as React from "react";
-import { Component, useState } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerEvent,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import * as moment from "moment";
-import Col from "antd/lib/col";
-import Row from "antd/lib/row";
-import Button from "antd/lib/button";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class CustomPopoverStyle extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week);
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Custom popover style example
-
-
-
- );
- }
-
- public eventItemPopoverTemplateResolver = (schedulerData: SchedulerData, eventItem: SchedulerEvent, title: string, start: moment.Moment, end: moment.Moment, statusColor: string) => {
- return (
- //
- // {title}
- // {start.format("HH:mm")} - {end.format("HH:mm")}
- //
- //
-
-
-
-
-
-
- {title}
-
-
-
-
-
-
-
- {start.format("HH:mm")} - {end.format("HH:mm")}
-
-
-
-
-
-
-
- { this.demoButtonClicked(eventItem); }}>Demo
-
-
-
- );
- }
-
- public demoButtonClicked = (eventItem: SchedulerEvent) => {
- alert(`You just clicked demo button. event title: ${eventItem.title}`);
- }
-}
-
-export default withDragDropContext(CustomPopoverStyle);
diff --git a/example/CustomTableHeaders.tsx b/example/CustomTableHeaders.tsx
deleted file mode 100644
index d9a1d0d70..000000000
--- a/example/CustomTableHeaders.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import * as React from "react";
-import { Component, useState } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as moment from "moment";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class CustomHeaders extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- calendarPopoverEnabled: false,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public nonAgendaCellHeaderTemplateResolver = (schedulerData: SchedulerData, item: any, formattedDateItems: any, style: React.CSSProperties) => {
- const datetime = moment(item.time);
- let isCurrentDate = false;
-
- if (schedulerData.viewType === SchedulerViewTypes.Day) {
- isCurrentDate = datetime.isSame(new Date(), "hour");
- } else {
- isCurrentDate = datetime.isSame(new Date(), "day");
- }
-
- if (isCurrentDate) {
- style.backgroundColor = "#118dea";
- style.color = "white";
- }
-
- return (
-
- {
- formattedDateItems.map((formattedItem: any, index: any) => (
- $&") }} />
- ))
- }
-
- );
- }
-
- public render() {
- const { viewModel } = this.state;
-
- return (
-
-
-
-
Custom table headers (with disabled calendar popup)
-
-
-
-
- );
- }
-
-}
-
-export default withDragDropContext(CustomHeaders);
diff --git a/example/CustomTimeWindow.tsx b/example/CustomTimeWindow.tsx
deleted file mode 100644
index 569a8d27a..000000000
--- a/example/CustomTimeWindow.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SCHEDULER_DATE_FORMAT,
- SchedulerCellUnits,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import * as moment from "moment";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class CustomTimeWindow extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(),
- SchedulerViewTypes.Custom,
- false,
- false,
- {
- customCellWidth: 30,
- nonAgendaDayCellHeaderFormat: "M/D|HH:mm",
- views: [
- { viewName: "Two days", viewType: SchedulerViewTypes.Custom, showAgenda: false, isEventPerspective: false },
- { viewName: "Two weeks", viewType: SchedulerViewTypes.Custom1, showAgenda: false, isEventPerspective: false },
- { viewName: "Two months", viewType: SchedulerViewTypes.Custom2, showAgenda: false, isEventPerspective: false },
- ],
- },
- {
- getCustomDateFunc: this.getCustomDate,
- isNonWorkingTimeFunc: this.isNonWorkingTime,
- },
- );
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Custom time window
-
-
-
- )
- }
-
-
- getCustomDate = (schedulerData: SchedulerData, num: number, date: string = undefined) => {
- const { viewType } = schedulerData;
- let selectDate = schedulerData.startDate;
- if (date != undefined)
- selectDate = date;
-
- let startDate = num === 0 ? selectDate :
- moment(selectDate).add(2 * num, 'days').format(SCHEDULER_DATE_FORMAT),
- endDate = moment(startDate).add(1, 'days').format(SCHEDULER_DATE_FORMAT),
- cellUnit = SchedulerCellUnits.Hour;
- if (viewType === SchedulerViewTypes.Custom1) {
- let monday = moment(selectDate).startOf('week').format(SCHEDULER_DATE_FORMAT);
- startDate = num === 0 ? monday : moment(monday).add(2 * num, 'weeks').format(SCHEDULER_DATE_FORMAT);
- endDate = moment(startDate).add(1, 'weeks').endOf('week').format(SCHEDULER_DATE_FORMAT);
- cellUnit = SchedulerCellUnits.Day;
- } else if (viewType === SchedulerViewTypes.Custom2) {
- let firstDayOfMonth = moment(selectDate).startOf('month').format(SCHEDULER_DATE_FORMAT);
- startDate = num === 0 ? firstDayOfMonth : moment(firstDayOfMonth).add(2 * num, 'months').format(SCHEDULER_DATE_FORMAT);
- endDate = moment(startDate).add(1, 'months').endOf('month').format(SCHEDULER_DATE_FORMAT);
- cellUnit = SchedulerCellUnits.Day;
- }
-
- return {
- startDate,
- endDate,
- cellUnit
- };
- }
-
- isNonWorkingTime = (schedulerData: SchedulerData, time: string) => {
- if (schedulerData.cellUnit === SchedulerCellUnits.Hour) {
- let hour = moment(time).hour();
- if (hour < 1)
- return true;
- }
- else {
- let dayOfWeek = moment(time).weekday();
- if (dayOfWeek === 0 || dayOfWeek === 6)
- return true;
- }
-
- return false;
- }
-
-}
-
-export default withDragDropContext(CustomTimeWindow);
diff --git a/example/DemoData.ts b/example/DemoData.ts
index 947fd8a94..504496bd9 100644
--- a/example/DemoData.ts
+++ b/example/DemoData.ts
@@ -1,389 +1,389 @@
-import { Resource, Event } from "../src/SchedulerData";
+import { Resource, Event } from '../lib';
export interface DemoData {
- resources: Resource[];
- events: Event[];
- eventsForTaskView: Event[];
- eventsForCustomEventStyle: Event[];
+ resources: Resource[];
+ events: Event[];
+ eventsForTaskView: Event[];
+ eventsForCustomEventStyle: Event[];
}
const data: DemoData = {
- resources: [
- {
- id: "r0",
- name: "Resource0",
- groupOnly: true,
- },
- {
- id: "r1",
- name: "Resource1",
- parentId: "r0",
- },
- {
- id: "r2",
- name: "Resource2",
- parentId: "r3",
- },
- {
- id: "r3",
- name: "Resource3",
- parentId: "r1",
- },
- {
- id: "r4",
- name: "Resource4",
- },
- {
- id: "r5",
- name: "Resource5",
- },
- {
- id: "r6",
- name: "Resource6",
- },
- {
- id: "r7",
- name: "Resource7Resource7Resource7Resource7Resource7",
- },
- ],
- events: [
- {
- id: "1",
- start: "2017-12-18 09:30:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r1",
- title: "I am finished",
- bgColor: "#D9D9D9",
- showPopover: false,
- },
- {
- id: "2",
- start: "2017-12-18 12:30:00",
- end: "2017-12-26 23:30:00",
- resourceId: "r2",
- title: "I am not resizable",
- resizable: false,
- },
- {
- id: "3",
- start: "2017-12-19 12:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r3",
- title: "I am not movable",
- movable: false,
- },
- {
- id: "4",
- start: "2017-12-19 14:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r4",
- title: "I am not start-resizable",
- startResizable: false,
- },
- {
- id: "5",
- start: "2017-12-19 15:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r5",
- title: "I am not end-resizable",
- endResizable: false,
- },
- {
- id: "6",
- start: "2017-12-19 15:35:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r6",
- title: "I am normal",
- },
- {
- id: "7",
- start: "2017-12-19 15:40:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r7",
- title: "I am exceptional",
- bgColor: "#FA9E95",
- },
- {
- id: "8",
- start: "2017-12-19 15:50:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r1",
- title: "I am locked",
- movable: false,
- resizable: false,
- bgColor: "red",
- },
- {
- id: "9",
- start: "2017-12-19 16:30:00",
- end: "2017-12-27 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 1",
- },
- {
- id: "10",
- start: "2017-12-19 17:30:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r1",
- title: "R1 has recurring tasks every week on Tuesday, Friday",
- rrule: "FREQ=WEEKLY;DTSTART=20171219T013000Z;BYDAY=TU,FR",
- bgColor: "#f759ab",
- },
- {
- id: "11",
- start: "2017-12-19 18:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 3",
- },
- {
- id: "12",
- start: "2017-12-20 18:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 4",
- },
- {
- id: "13",
- start: "2017-12-21 18:30:00",
- end: "2017-12-24 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 5",
- },
- {
- id: "14",
- start: "2017-12-23 18:30:00",
- end: "2017-12-27 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 6",
- },
- ],
- eventsForTaskView: [
- {
- id: "1",
- start: "2017-12-18 09:30:00",
- end: "2017-12-18 23:30:00",
- resourceId: "r1",
- title: "I am finished",
- bgColor: "#D9D9D9",
- groupId: "1",
- groupName: "Task1",
- },
- {
- id: "2",
- start: "2017-12-18 12:30:00",
- end: "2017-12-26 23:30:00",
- resourceId: "r2",
- title: "I am not resizable",
- resizable: false,
- groupId: "2",
- groupName: "Task2",
- },
- {
- id: "3",
- start: "2017-12-19 12:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r3",
- title: "I am not movable",
- movable: false,
- groupId: "3",
- groupName: "Task3",
- },
- {
- id: "7",
- start: "2017-12-19 15:40:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r7",
- title: "I am exceptional",
- bgColor: "#FA9E95",
- groupId: "4",
- groupName: "Task4",
- },
- {
- id: "4",
- start: "2017-12-20 14:30:00",
- end: "2017-12-21 23:30:00",
- resourceId: "r4",
- title: "I am not start-resizable",
- startResizable: false,
- groupId: "1",
- groupName: "Task1",
- },
- {
- id: "5",
- start: "2017-12-21 15:30:00",
- end: "2017-12-22 23:30:00",
- resourceId: "r5",
- title: "I am not end-resizable",
- endResizable: false,
- groupId: "3",
- groupName: "Task3",
- },
- {
- id: "9",
- start: "2017-12-21 16:30:00",
- end: "2017-12-21 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks",
- groupId: "4",
- groupName: "Task4",
- },
- {
- id: "6",
- start: "2017-12-22 15:35:00",
- end: "2017-12-23 23:30:00",
- resourceId: "r6",
- title: "I am normal",
- groupId: "1",
- groupName: "Task1",
- },
- {
- id: "8",
- start: "2017-12-25 15:50:00",
- end: "2017-12-26 23:30:00",
- resourceId: "r1",
- title: "I am locked",
- movable: false,
- resizable: false,
- bgColor: "red",
- groupId: "1",
- groupName: "Task1",
- },
- {
- id: "10",
- start: "2017-12-26 18:30:00",
- end: "2017-12-26 23:30:00",
- resourceId: "r2",
- title: "R2 has many tasks",
- groupId: "4",
- groupName: "Task4",
- },
- {
- id: "11",
- start: "2017-12-27 18:30:00",
- end: "2017-12-27 23:30:00",
- resourceId: "r14",
- title: "R4 has many tasks",
- groupId: "4",
- groupName: "Task4",
- },
- {
- id: "12",
- start: "2017-12-28 18:30:00",
- end: "2017-12-28 23:30:00",
- resourceId: "r6",
- title: "R6 has many tasks",
- groupId: "3",
- groupName: "Task3",
- },
- ],
- eventsForCustomEventStyle: [
- {
- id: "1",
- start: "2017-12-18 09:30:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r1",
- title: "I am finished",
- bgColor: "#D9D9D9",
- type: 1,
- },
- {
- id: "2",
- start: "2017-12-18 12:30:00",
- end: "2017-12-26 23:30:00",
- resourceId: "r2",
- title: "I am not resizable",
- resizable: false,
- type: 2,
- },
- {
- id: "3",
- start: "2017-12-19 12:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r3",
- title: "I am not movable",
- movable: false,
- type: 3,
- },
- {
- id: "4",
- start: "2017-12-19 14:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r4",
- title: "I am not start-resizable",
- startResizable: false,
- type: 1,
- },
- {
- id: "5",
- start: "2017-12-19 15:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r5",
- title: "I am not end-resizable",
- endResizable: false,
- type: 2,
- },
- {
- id: "6",
- start: "2017-12-19 15:35:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r6",
- title: "I am normal",
- type: 3,
- },
- {
- id: "7",
- start: "2017-12-19 15:40:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r7",
- title: "I am exceptional",
- bgColor: "#FA9E95",
- type: 1,
- },
- {
- id: "8",
- start: "2017-12-19 15:50:00",
- end: "2017-12-19 23:30:00",
- resourceId: "r1",
- title: "I am locked",
- movable: false,
- resizable: false,
- bgColor: "red",
- type: 2,
- },
- {
- id: "9",
- start: "2017-12-19 16:30:00",
- end: "2017-12-27 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 1",
- type: 3,
- },
- {
- id: "10",
- start: "2017-12-20 18:30:00",
- end: "2017-12-20 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 2",
- type: 1,
- },
- {
- id: "11",
- start: "2017-12-21 18:30:00",
- end: "2017-12-22 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 3",
- type: 2,
- },
- {
- id: "12",
- start: "2017-12-23 18:30:00",
- end: "2017-12-27 23:30:00",
- resourceId: "r1",
- title: "R1 has many tasks 4",
- type: 3,
- },
- ],
+ resources: [
+ {
+ id: 'r0',
+ name: 'Resource0',
+ groupOnly: true,
+ },
+ {
+ id: 'r1',
+ name: 'Resource1',
+ parentId: 'r0',
+ },
+ {
+ id: 'r2',
+ name: 'Resource2',
+ parentId: 'r3',
+ },
+ {
+ id: 'r3',
+ name: 'Resource3',
+ parentId: 'r1',
+ },
+ {
+ id: 'r4',
+ name: 'Resource4',
+ },
+ {
+ id: 'r5',
+ name: 'Resource5',
+ },
+ {
+ id: 'r6',
+ name: 'Resource6',
+ },
+ {
+ id: 'r7',
+ name: 'Resource7Resource7Resource7Resource7Resource7',
+ },
+ ],
+ events: [
+ {
+ id: '1',
+ start: '2017-12-18 09:30:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r1',
+ title: 'I am finished',
+ bgColor: '#D9D9D9',
+ showPopover: false,
+ },
+ {
+ id: '2',
+ start: '2017-12-18 12:30:00',
+ end: '2017-12-26 23:30:00',
+ resourceId: 'r2',
+ title: 'I am not resizable',
+ resizable: false,
+ },
+ {
+ id: '3',
+ start: '2017-12-19 12:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r3',
+ title: 'I am not movable',
+ movable: false,
+ },
+ {
+ id: '4',
+ start: '2017-12-19 14:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r4',
+ title: 'I am not start-resizable',
+ startResizable: false,
+ },
+ {
+ id: '5',
+ start: '2017-12-19 15:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r5',
+ title: 'I am not end-resizable',
+ endResizable: false,
+ },
+ {
+ id: '6',
+ start: '2017-12-19 15:35:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r6',
+ title: 'I am normal',
+ },
+ {
+ id: '7',
+ start: '2017-12-19 15:40:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r7',
+ title: 'I am exceptional',
+ bgColor: '#FA9E95',
+ },
+ {
+ id: '8',
+ start: '2017-12-19 15:50:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r1',
+ title: 'I am locked',
+ movable: false,
+ resizable: false,
+ bgColor: 'red',
+ },
+ {
+ id: '9',
+ start: '2017-12-19 16:30:00',
+ end: '2017-12-27 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 1',
+ },
+ {
+ id: '10',
+ start: '2017-12-19 17:30:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has recurring tasks every week on Tuesday, Friday',
+ rrule: 'FREQ=WEEKLY;DTSTART=20171219T013000Z;BYDAY=TU,FR',
+ bgColor: '#f759ab',
+ },
+ {
+ id: '11',
+ start: '2017-12-19 18:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 3',
+ },
+ {
+ id: '12',
+ start: '2017-12-20 18:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 4',
+ },
+ {
+ id: '13',
+ start: '2017-12-21 18:30:00',
+ end: '2017-12-24 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 5',
+ },
+ {
+ id: '14',
+ start: '2017-12-23 18:30:00',
+ end: '2017-12-27 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 6',
+ },
+ ],
+ eventsForTaskView: [
+ {
+ id: '1',
+ start: '2017-12-18 09:30:00',
+ end: '2017-12-18 23:30:00',
+ resourceId: 'r1',
+ title: 'I am finished',
+ bgColor: '#D9D9D9',
+ groupId: '1',
+ groupName: 'Task1',
+ },
+ {
+ id: '2',
+ start: '2017-12-18 12:30:00',
+ end: '2017-12-26 23:30:00',
+ resourceId: 'r2',
+ title: 'I am not resizable',
+ resizable: false,
+ groupId: '2',
+ groupName: 'Task2',
+ },
+ {
+ id: '3',
+ start: '2017-12-19 12:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r3',
+ title: 'I am not movable',
+ movable: false,
+ groupId: '3',
+ groupName: 'Task3',
+ },
+ {
+ id: '7',
+ start: '2017-12-19 15:40:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r7',
+ title: 'I am exceptional',
+ bgColor: '#FA9E95',
+ groupId: '4',
+ groupName: 'Task4',
+ },
+ {
+ id: '4',
+ start: '2017-12-20 14:30:00',
+ end: '2017-12-21 23:30:00',
+ resourceId: 'r4',
+ title: 'I am not start-resizable',
+ startResizable: false,
+ groupId: '1',
+ groupName: 'Task1',
+ },
+ {
+ id: '5',
+ start: '2017-12-21 15:30:00',
+ end: '2017-12-22 23:30:00',
+ resourceId: 'r5',
+ title: 'I am not end-resizable',
+ endResizable: false,
+ groupId: '3',
+ groupName: 'Task3',
+ },
+ {
+ id: '9',
+ start: '2017-12-21 16:30:00',
+ end: '2017-12-21 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks',
+ groupId: '4',
+ groupName: 'Task4',
+ },
+ {
+ id: '6',
+ start: '2017-12-22 15:35:00',
+ end: '2017-12-23 23:30:00',
+ resourceId: 'r6',
+ title: 'I am normal',
+ groupId: '1',
+ groupName: 'Task1',
+ },
+ {
+ id: '8',
+ start: '2017-12-25 15:50:00',
+ end: '2017-12-26 23:30:00',
+ resourceId: 'r1',
+ title: 'I am locked',
+ movable: false,
+ resizable: false,
+ bgColor: 'red',
+ groupId: '1',
+ groupName: 'Task1',
+ },
+ {
+ id: '10',
+ start: '2017-12-26 18:30:00',
+ end: '2017-12-26 23:30:00',
+ resourceId: 'r2',
+ title: 'R2 has many tasks',
+ groupId: '4',
+ groupName: 'Task4',
+ },
+ {
+ id: '11',
+ start: '2017-12-27 18:30:00',
+ end: '2017-12-27 23:30:00',
+ resourceId: 'r14',
+ title: 'R4 has many tasks',
+ groupId: '4',
+ groupName: 'Task4',
+ },
+ {
+ id: '12',
+ start: '2017-12-28 18:30:00',
+ end: '2017-12-28 23:30:00',
+ resourceId: 'r6',
+ title: 'R6 has many tasks',
+ groupId: '3',
+ groupName: 'Task3',
+ },
+ ],
+ eventsForCustomEventStyle: [
+ {
+ id: '1',
+ start: '2017-12-18 09:30:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r1',
+ title: 'I am finished',
+ bgColor: '#D9D9D9',
+ type: 1,
+ },
+ {
+ id: '2',
+ start: '2017-12-18 12:30:00',
+ end: '2017-12-26 23:30:00',
+ resourceId: 'r2',
+ title: 'I am not resizable',
+ resizable: false,
+ type: 2,
+ },
+ {
+ id: '3',
+ start: '2017-12-19 12:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r3',
+ title: 'I am not movable',
+ movable: false,
+ type: 3,
+ },
+ {
+ id: '4',
+ start: '2017-12-19 14:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r4',
+ title: 'I am not start-resizable',
+ startResizable: false,
+ type: 1,
+ },
+ {
+ id: '5',
+ start: '2017-12-19 15:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r5',
+ title: 'I am not end-resizable',
+ endResizable: false,
+ type: 2,
+ },
+ {
+ id: '6',
+ start: '2017-12-19 15:35:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r6',
+ title: 'I am normal',
+ type: 3,
+ },
+ {
+ id: '7',
+ start: '2017-12-19 15:40:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r7',
+ title: 'I am exceptional',
+ bgColor: '#FA9E95',
+ type: 1,
+ },
+ {
+ id: '8',
+ start: '2017-12-19 15:50:00',
+ end: '2017-12-19 23:30:00',
+ resourceId: 'r1',
+ title: 'I am locked',
+ movable: false,
+ resizable: false,
+ bgColor: 'red',
+ type: 2,
+ },
+ {
+ id: '9',
+ start: '2017-12-19 16:30:00',
+ end: '2017-12-27 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 1',
+ type: 3,
+ },
+ {
+ id: '10',
+ start: '2017-12-20 18:30:00',
+ end: '2017-12-20 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 2',
+ type: 1,
+ },
+ {
+ id: '11',
+ start: '2017-12-21 18:30:00',
+ end: '2017-12-22 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 3',
+ type: 2,
+ },
+ {
+ id: '12',
+ start: '2017-12-23 18:30:00',
+ end: '2017-12-27 23:30:00',
+ resourceId: 'r1',
+ title: 'R1 has many tasks 4',
+ type: 3,
+ },
+ ],
};
export const DemoData = data;
diff --git a/example/DragAndDrop.tsx b/example/DragAndDrop.tsx
deleted file mode 100644
index 37dbf9d41..000000000
--- a/example/DragAndDrop.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Col from "antd/lib/col";
-import Row from "antd/lib/row";
-import Scheduler, { SchedulerData, SchedulerViewTypes, SchedulerDnDSource, SchedulerEvent, SchedulerEventGroup } from "../src/Scheduler";
-import { DemoData } from "./DemoData";
-import { DnDTypes } from "../src/types/DnDTypes";
-import TaskItem from "./TaskItem";
-import TaskList from "./TaskList";
-import ResourceItem from "./ResourceItem";
-import ResourceList from "./ResourceList";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-import { Event } from "../src/SchedulerData";
-import * as ExampleFunction from "./ExampleFunctions";
-
-interface DragAndDropState {
- viewModel: SchedulerData;
- taskDndSource: SchedulerDnDSource;
- resourceDndSource: SchedulerDnDSource;
-}
-
-interface View {
- viewName: string;
- viewType: number;
- showAgenda: boolean;
- isEventPerspective: boolean;
-}
-
-class DragAndDrop extends Component<{}, DragAndDropState> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const views: View[] = [
- { viewName: "Agenda View", viewType: SchedulerViewTypes.Month, showAgenda: true, isEventPerspective: false },
- { viewName: "Resource View", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: false },
- { viewName: "Task View", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: true },
- ];
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Month, false, false, {
- schedulerWidth: "80%",
- schedulerMaxHeight: 500,
- views,
- });
-
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.eventsForTaskView);
- this.state = {
- viewModel: schedulerData,
- taskDndSource: new SchedulerDnDSource((p: { task: any; }) => p.task, TaskItem, DnDTypes.TASK),
- resourceDndSource: new SchedulerDnDSource((p: { resource: any; }) => p.resource, ResourceItem, DnDTypes.RESOURCE),
- };
- }
-
- public render() {
- const { viewModel, taskDndSource, resourceDndSource } = this.state;
- const h3 = viewModel.isEventPerspective ? "Drag and drop from outside: Drag a resource and drop to the task view" : "Drag and drop from outside: Drag a task and drop to the resource view";
-
- const dndList = viewModel.isEventPerspective ? (
-
- ) : (
-
- );
-
- // register the external DnDSources
- const dndSources = [taskDndSource, resourceDndSource];
- return (
-
-
-
-
{h3}
-
-
-
-
-
- {dndList}
-
-
-
-
- );
- }
- public subtitleGetter = (schedulerData: SchedulerData, event: SchedulerEvent) => {
- return schedulerData.isEventPerspective ? schedulerData.getResourceById(event.resourceId).name : event.groupName;
- }
-}
-
-export default withDragDropContext(DragAndDrop);
diff --git a/example/ExampleFunctions.tsx b/example/ExampleFunctions.tsx
index 7cda8d188..f513d54a0 100644
--- a/example/ExampleFunctions.tsx
+++ b/example/ExampleFunctions.tsx
@@ -1,166 +1,219 @@
-import {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerEvent,
- SchedulerContentState,
-} from "../src/Scheduler";
-import { DemoData } from "./DemoData";
+import { SchedulerData, SchedulerViewTypes, SchedulerEvent, SchedulerContentState } from '../lib';
+import { DemoData } from './DemoData';
export const getNow = (): string => {
- // moment().format(SCHEDULER_DATE_FORMAT)
- return "2017-12-18";
+ // moment().format(SCHEDULER_DATE_FORMAT)
+ return '2017-12-18';
};
export function prevClick(schedulerData: SchedulerData) {
- schedulerData.prev();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
+ schedulerData.prev();
+ schedulerData.setEvents(DemoData.events);
+ this.setState({
+ viewModel: schedulerData,
+ });
}
export function toggleExpandFunc(schedulerData: SchedulerData, slotId: string) {
- schedulerData.toggleExpandStatus(slotId);
- this.setState({
- viewModel: schedulerData,
- });
+ schedulerData.toggleExpandStatus(slotId);
+ this.setState({
+ viewModel: schedulerData,
+ });
}
export function nextClick(schedulerData: SchedulerData) {
- schedulerData.next();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
+ schedulerData.next();
+ schedulerData.setEvents(DemoData.events);
+ this.setState({
+ viewModel: schedulerData,
+ });
}
-export function onViewChange(schedulerData: SchedulerData, view: { viewType: any; showAgenda: any; isEventPerspective: any; }) {
- schedulerData.setViewType(view.viewType, view.showAgenda, view.isEventPerspective);
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
+export function onViewChange(
+ schedulerData: SchedulerData,
+ view: { viewType: any; showAgenda: any; isEventPerspective: any }
+) {
+ schedulerData.setViewType(view.viewType, view.showAgenda, view.isEventPerspective);
+ schedulerData.setEvents(DemoData.events);
+ this.setState({
+ viewModel: schedulerData,
+ });
}
export function onSelectDate(schedulerData: SchedulerData, date: string) {
- schedulerData.setDate(date);
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
+ schedulerData.setDate(date);
+ schedulerData.setEvents(DemoData.events);
+ this.setState({
+ viewModel: schedulerData,
+ });
}
export function eventClicked(schedulerData: SchedulerData, event: SchedulerEvent) {
- alert(`You just clicked an event: {id: ${event.id}, title: ${event.title}}`);
+ alert(`You just clicked an event: {id: ${event.id}, title: ${event.title}}`);
}
export function ops1(schedulerData: SchedulerData, event: SchedulerEvent) {
- alert(`You just executed ops1 to event: {id: ${event.id}, title: ${event.title}}`);
+ alert(`You just executed ops1 to event: {id: ${event.id}, title: ${event.title}}`);
}
export function ops2(schedulerData: SchedulerData, event: SchedulerEvent) {
- alert(`You just executed ops2 to event: {id: ${event.id}, title: ${event.title}}`);
-}
-
-export function newEvent(schedulerData: SchedulerData, slotId: string, slotName: string, start: string, end: string, type: string, item: SchedulerEvent) {
- if (confirm(`Do you want to create a new event? {slotId: ${slotId}, slotName: ${slotName}, start: ${start}, end: ${end}, type: ${type}, item: ${item}}`)) {
-
- let newFreshId = "0";
- schedulerData.events.forEach((i) => {
- if (i.id >= newFreshId) {
- newFreshId = i.id + 1;
- }
- });
-
- const newE = {
- id: newFreshId,
- title: "New event you just created",
- start,
- end,
- resourceId: slotId,
- bgColor: "purple",
- };
- schedulerData.addEvent(newE);
- this.setState({
- viewModel: schedulerData,
- });
- }
-}
+ alert(`You just executed ops2 to event: {id: ${event.id}, title: ${event.title}}`);
+}
+
+export function newEvent(
+ schedulerData: SchedulerData,
+ slotId: string,
+ slotName: string,
+ start: string,
+ end: string,
+ type: string,
+ item: SchedulerEvent
+) {
+ if (
+ confirm(
+ `Do you want to create a new event? {slotId: ${slotId}, slotName: ${slotName}, start: ${start}, end: ${end}, type: ${type}, item: ${item}}`
+ )
+ ) {
+ let newFreshId = '0';
+ schedulerData.events.forEach((i) => {
+ if (i.id >= newFreshId) {
+ newFreshId = i.id + 1;
+ }
+ });
-export function updateEventStart(schedulerData: SchedulerData, event: SchedulerEvent, newStart: string) {
- if (confirm(`Do you want to adjust the start of the event? {eventId: ${event.id}, eventTitle: ${event.title}, newStart: ${newStart}}`)) {
- schedulerData.updateEventStart(event, newStart);
- }
+ const newE = {
+ id: newFreshId,
+ title: 'New event you just created',
+ start,
+ end,
+ resourceId: slotId,
+ bgColor: 'purple',
+ };
+ schedulerData.addEvent(newE);
this.setState({
- viewModel: schedulerData,
+ viewModel: schedulerData,
});
+ }
+}
+
+export function updateEventStart(schedulerData: SchedulerData, event: SchedulerEvent, newStart: string) {
+ if (
+ confirm(
+ `Do you want to adjust the start of the event? {eventId: ${event.id}, eventTitle: ${event.title}, newStart: ${newStart}}`
+ )
+ ) {
+ schedulerData.updateEventStart(event, newStart);
+ }
+ this.setState({
+ viewModel: schedulerData,
+ });
}
export function updateEventEnd(schedulerData: SchedulerData, event: SchedulerEvent, newEnd: string) {
- if (confirm(`Do you want to adjust the end of the event? {eventId: ${event.id}, eventTitle: ${event.title}, newEnd: ${newEnd}}`)) {
- schedulerData.updateEventEnd(event, newEnd);
- }
+ if (
+ confirm(
+ `Do you want to adjust the end of the event? {eventId: ${event.id}, eventTitle: ${event.title}, newEnd: ${newEnd}}`
+ )
+ ) {
+ schedulerData.updateEventEnd(event, newEnd);
+ }
+ this.setState({
+ viewModel: schedulerData,
+ });
+}
+
+export function moveEvent(
+ schedulerData: SchedulerData,
+ event: SchedulerEvent,
+ slotId: string,
+ slotName: string,
+ start: string,
+ end: string
+) {
+ if (
+ confirm(
+ `Do you want to move the event? {eventId: ${event.id}, eventTitle: ${event.title}, newSlotId: ${slotId}, newSlotName: ${slotName}, newStart: ${start}, newEnd: ${end}`
+ )
+ ) {
+ schedulerData.moveEvent(event, slotId, slotName, start, end);
this.setState({
- viewModel: schedulerData,
+ viewModel: schedulerData,
});
-}
-
-export function moveEvent(schedulerData: SchedulerData, event: SchedulerEvent, slotId: string, slotName: string, start: string, end: string) {
- if (confirm(`Do you want to move the event? {eventId: ${event.id}, eventTitle: ${event.title}, newSlotId: ${slotId}, newSlotName: ${slotName}, newStart: ${start}, newEnd: ${end}`)) {
- schedulerData.moveEvent(event, slotId, slotName, start, end);
- this.setState({
- viewModel: schedulerData,
- });
- }
+ }
}
export function onSetAddMoreState(newState: any) {
- if (newState === undefined) {
- this.setState({
- headerItem: undefined,
- left: 0,
- top: 0,
- height: 0,
- });
- } else {
- this.setState({
- ...newState,
- });
- }
-}
-
-export function onScrollRight(schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) {
- if (schedulerData.viewType === SchedulerViewTypes.Day) {
- schedulerData.next();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
-
- schedulerContent.scrollLeft = maxScrollLeft - 10;
- }
+ if (newState === undefined) {
+ this.setState({
+ headerItem: undefined,
+ left: 0,
+ top: 0,
+ height: 0,
+ });
+ } else {
+ this.setState({
+ ...newState,
+ });
+ }
}
-export function onScrollLeft(schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) {
- if (schedulerData.viewType === SchedulerViewTypes.Day) {
- schedulerData.prev();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
-
- schedulerContent.scrollLeft = 10;
- }
-}
+export function onScrollRight(
+ schedulerData: SchedulerData,
+ schedulerContent: SchedulerContentState,
+ maxScrollLeft: number
+) {
+ if (schedulerData.viewType === SchedulerViewTypes.Day) {
+ schedulerData.next();
+ schedulerData.setEvents(DemoData.events);
+ this.setState({
+ viewModel: schedulerData,
+ });
-export function onScrollTop(schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) {
- console.log("onScrollTop");
+ schedulerContent.scrollLeft = maxScrollLeft - 10;
+ }
}
-export function onScrollBottom(schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) {
- console.log("onScrollBottom");
-}
+export function onScrollLeft(
+ schedulerData: SchedulerData,
+ schedulerContent: SchedulerContentState,
+ maxScrollLeft: number
+) {
+ if (schedulerData.viewType === SchedulerViewTypes.Day) {
+ schedulerData.prev();
+ schedulerData.setEvents(DemoData.events);
+ this.setState({
+ viewModel: schedulerData,
+ });
-export function conflictOccurred(schedulerData: SchedulerData, action: string, event: SchedulerEvent, type: string, slotId: string, slotName: string, start: string, end: string) {
- alert(`Conflict occurred. {action: ${action}, event: ${event}`);
+ schedulerContent.scrollLeft = 10;
+ }
+}
+
+export function onScrollTop(
+ schedulerData: SchedulerData,
+ schedulerContent: SchedulerContentState,
+ maxScrollLeft: number
+) {
+ console.log('onScrollTop');
+}
+
+export function onScrollBottom(
+ schedulerData: SchedulerData,
+ schedulerContent: SchedulerContentState,
+ maxScrollLeft: number
+) {
+ console.log('onScrollBottom');
+}
+
+export function conflictOccurred(
+ schedulerData: SchedulerData,
+ action: string,
+ event: SchedulerEvent,
+ type: string,
+ slotId: string,
+ slotName: string,
+ start: string,
+ end: string
+) {
+ alert(`Conflict occurred. {action: ${action}, event: ${event}`);
}
diff --git a/example/FreezeFirstRow.tsx b/example/FreezeFirstRow.tsx
deleted file mode 100644
index b6227c1ca..000000000
--- a/example/FreezeFirstRow.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class FreezeFirstRow extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Month, false, false, {
- schedulerMaxHeight: 400,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Set schedulerMaxHeight to freeze first row
-
-
-
- );
- }
-}
-
-export default withDragDropContext(FreezeFirstRow);
diff --git a/example/HideWeekends.tsx b/example/HideWeekends.tsx
deleted file mode 100644
index f02e51c20..000000000
--- a/example/HideWeekends.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class HideWeekends extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- displayWeekend: false,
- weekCellWidth: "16%",
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Hide weekends
-
-
-
- );
- }
-}
-
-export default withDragDropContext(HideWeekends);
diff --git a/example/InfiniteScroll.tsx b/example/InfiniteScroll.tsx
deleted file mode 100644
index d42f53644..000000000
--- a/example/InfiniteScroll.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerContentState,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-import * as moment from "moment";
-
-class InfiniteScroll extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Month, false, false, {
- views: [
- { viewName: "Month", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: false },
- ],
- });
- moment.locale("en");
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Infinite scroll
-
-
-
- );
- }
-
- public onScrollRight = (schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) => {
- if (schedulerData.viewType === SchedulerViewTypes.Month) {
- schedulerData.next();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
-
- schedulerContent.scrollLeft = maxScrollLeft - 10;
- }
- }
-
- public onScrollLeft = (schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) => {
- if (schedulerData.viewType === SchedulerViewTypes.Month) {
- schedulerData.prev();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
-
- schedulerContent.scrollLeft = 10;
- }
- }
-
-}
-
-export default withDragDropContext(InfiniteScroll);
diff --git a/example/InfiniteScroll2.tsx b/example/InfiniteScroll2.tsx
deleted file mode 100644
index e0dfcb87a..000000000
--- a/example/InfiniteScroll2.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SCHEDULER_DATE_FORMAT,
- SchedulerCellUnits,
- SchedulerContentState,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import * as moment from "moment";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class InfiniteScroll2 extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Custom, false, false, {
- headerEnabled: false,
- customCellWidth: 30,
- nonAgendaDayCellHeaderFormat: "M/D|HH:mm",
- views: [
- { viewName: "Day", viewType: SchedulerViewTypes.Custom, showAgenda: false, isEventPerspective: false },
- { viewName: "Week", viewType: SchedulerViewTypes.Week, showAgenda: false, isEventPerspective: false },
- ],
- }, {
- getCustomDateFunc: this.getCustomDate,
- isNonWorkingTimeFunc: this.isNonWorkingTime,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Infinite scroll 2
-
-
-
- );
- }
-
- public getCustomDate = (schedulerData: SchedulerData, num: number, date: string = undefined) => {
- let selectDate = schedulerData.startDate;
- if (date === undefined) {
- selectDate = date;
- }
-
- let startDate = selectDate;
- let endDate = moment(startDate).add(1, "days").format(SCHEDULER_DATE_FORMAT);
- const cellUnit = SchedulerCellUnits.Hour;
- if (num === 1) {
- startDate = schedulerData.startDate;
- endDate = moment(schedulerData.endDate).add(1, "days").format(SCHEDULER_DATE_FORMAT);
- } else if (num === -1) {
- startDate = moment(schedulerData.startDate).add(-1, "days").format(SCHEDULER_DATE_FORMAT);
- endDate = schedulerData.endDate;
- }
-
- return {
- startDate,
- endDate,
- cellUnit,
- };
- }
-
- public isNonWorkingTime = (schedulerData: SchedulerData, time: string) => {
- if (schedulerData.cellUnit === SchedulerCellUnits.Hour) {
- const hour = moment(time).hour();
- if (hour < 1) {
- return true;
- }
- } else {
- const dayOfWeek = moment(time).weekday();
- if (dayOfWeek === 0 || dayOfWeek === 6) {
- return true;
- }
- }
-
- return false;
- }
- public onScrollRight = (schedulerData: SchedulerData, schedulerContent: SchedulerContentState, maxScrollLeft: number) => {
- schedulerData.next();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
-
- schedulerContent.scrollLeft = maxScrollLeft - 10;
- }
-
- public onScrollLeft = (schedulerData, schedulerContent, maxScrollLeft) => {
- schedulerData.prev();
- schedulerData.setEvents(DemoData.events);
- this.setState({
- viewModel: schedulerData,
- });
-
- schedulerContent.scrollLeft = 10;
- }
-}
-
-export default withDragDropContext(InfiniteScroll2);
diff --git a/example/Locale.tsx b/example/Locale.tsx
deleted file mode 100644
index edddb7030..000000000
--- a/example/Locale.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerHeader,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import * as moment from "moment";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-import Header from "antd/lib/calendar/Header";
-
-class Locale extends Component<{}, { viewModel: SchedulerData, headerItem: SchedulerHeader, left: number, top: number, height: number }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- moment.locale("zh-cn");
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- dayMaxEvents: 2,
- weekMaxEvents: 4,
- monthMaxEvents: 4,
- yearMaxEvents: 4,
- resourceName: "资源名称",
- taskName: "任务名称",
- agendaViewHeader: "工作事项",
- addMorePopoverHeaderFormat: "YYYY年M月D日 dddd",
- eventItemPopoverDateFormat: "M月D日",
- nonAgendaDayCellHeaderFormat: "HH:mm",
- nonAgendaOtherCellHeaderFormat: "ddd|M/D",
- views: [
- { viewName: "天", viewType: SchedulerViewTypes.Day, showAgenda: false, isEventPerspective: false },
- { viewName: "周", viewType: SchedulerViewTypes.Week, showAgenda: false, isEventPerspective: false },
- { viewName: "月", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: false },
- { viewName: "季", viewType: SchedulerViewTypes.Quarter, showAgenda: false, isEventPerspective: false },
- { viewName: "年", viewType: SchedulerViewTypes.Year, showAgenda: false, isEventPerspective: false },
- ],
- }, {
- getDateLabelFunc: this.getDateLabel,
- isNonWorkingTimeFunc: this.isNonWorkingTime,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- headerItem: undefined,
- left: 0,
- top: 0,
- height: 0,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- const popover =
;
- if (this.state.headerItem !== undefined) {
- {/*popover =
- ;
- */}
- }
- return (
-
-
-
-
Locale
-
- {popover}
-
-
- );
- }
-
- public getDateLabel = (schedulerData: SchedulerData, viewType: number, startDate: string, endDate: string) => {
- const start = moment(startDate);
- const end = moment(endDate);
- let dateLabel = start.format("YYYY年M月D日");
-
- if (viewType === SchedulerViewTypes.Week) {
- dateLabel = `${start.format("YYYY年M月D日")}-${end.format("D日")}`;
- if (start.month() !== end.month()) {
- dateLabel = `${start.format("YYYY年M月D日")}-${end.format("M月D日")}`;
- }
- if (start.year() !== end.year()) {
- dateLabel = `${start.format("YYYY年M月D日")}-${end.format("YYYY年M月D日")}`;
- }
- } else if (viewType === SchedulerViewTypes.Month) {
- dateLabel = start.format("YYYY年M月");
- } else if (viewType === SchedulerViewTypes.Quarter) {
- dateLabel = `${start.format("YYYY年M月D日")}-${end.format("M月D日")}`;
- } else if (viewType === SchedulerViewTypes.Year) {
- dateLabel = start.format("YYYY年");
- }
-
- return dateLabel;
- }
-
- public isNonWorkingTime = (schedulerData: SchedulerData, time: string) => {
- if (schedulerData.viewType === SchedulerViewTypes.Day) {
- const hour = moment(time).hour();
- if (hour < 9 || hour > 18) {
- return true;
- }
- } else {
- const dayOfWeek = moment(time).weekday();
- if (dayOfWeek === 5 || dayOfWeek === 6) {
- return true;
- }
- }
-
- return false;
- }
-}
-
-export default withDragDropContext(Locale);
diff --git a/example/Nav.tsx b/example/Nav.tsx
index a98187f73..59bf5bc29 100644
--- a/example/Nav.tsx
+++ b/example/Nav.tsx
@@ -1,154 +1,37 @@
-import * as React from "react";
-import { Component, CSSProperties } from "react";
-import { Link } from "react-router-dom";
+import * as React from 'react';
+import { Component, CSSProperties } from 'react';
class Nav extends Component<{}, {}> {
- constructor(props: Readonly<{}>) {
- super(props);
- }
+ constructor(props: Readonly<{}>) {
+ super(props);
+ }
- public render() {
- const ulStyle: CSSProperties = {
- listStyle: "none",
- margin: "0px",
- padding: "0px",
- width: "auto",
- };
- const liStyle: CSSProperties = {
- float: "left",
- marginLeft: "20px",
- };
- return (
-
-
-
- React Big Scheduler
-
-
-
- Basic
-
-
-
-
- Read only
-
-
-
-
- Locale
-
-
-
-
- Views
-
-
-
-
- Custom header
-
-
-
-
- Custom event style
-
-
-
-
- Add resource
-
-
-
-
- Drag&Drop
-
-
-
-
- Summary
-
-
-
-
- Add more
-
-
-
-
- Overlap check
-
-
-
-
- No cross-slot move
-
-
-
-
- Freeze first row
-
-
-
-
- Resource clickable
-
-
-
-
- Custom table headers
-
-
-
-
- Hide weekends
-
-
-
-
- Custom time window
-
-
-
-
- Infinite scroll
-
-
-
-
- Infinite scroll 2
-
-
-
-
- Custom popover style
-
-
-
-
-
- );
- }
+ public render() {
+ const ulStyle: CSSProperties = {
+ listStyle: 'none',
+ margin: '0px',
+ padding: '0px',
+ width: 'auto',
+ };
+ const liStyle: CSSProperties = {
+ float: 'left',
+ marginLeft: '20px',
+ };
+ return (
+
+ );
+ }
}
export default Nav;
diff --git a/example/NoCrossSlotMove.tsx b/example/NoCrossSlotMove.tsx
deleted file mode 100644
index bb5a77f78..000000000
--- a/example/NoCrossSlotMove.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class Basic extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- crossResourceMove: false,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
No cross-slot move
-
-
-
- );
- }
-}
-
-export default withDragDropContext(Basic);
diff --git a/example/OverlapCheck.tsx b/example/OverlapCheck.tsx
deleted file mode 100644
index 33130bf13..000000000
--- a/example/OverlapCheck.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class OverlapCheck extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- checkConflict: true,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Overlap check
-
-
-
- );
- }
-}
-
-export default withDragDropContext(OverlapCheck);
diff --git a/example/Readonly.tsx b/example/Readonly.tsx
deleted file mode 100644
index cae5060ca..000000000
--- a/example/Readonly.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class Readonly extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: {}) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, {
- startResizable: false,
- endResizable: false,
- movable: false,
- creatable: false,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Readonly view
-
-
-
- );
- }
-}
-
-export default withDragDropContext(Readonly);
diff --git a/example/ResourceClickable.tsx b/example/ResourceClickable.tsx
deleted file mode 100644
index 9e1b0f414..000000000
--- a/example/ResourceClickable.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerRenderData,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class Basic extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week);
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
Resource clickable
-
-
-
- );
- }
- public slotClickedFunc = (schedulerData: SchedulerData, slot: SchedulerRenderData) => {
- alert(`You just clicked a ${schedulerData.isEventPerspective ? "task" : "resource"}.{id: ${slot.slotId}, name: ${slot.slotName}}`);
- }
-}
-
-export default withDragDropContext(Basic);
diff --git a/example/ResourceItem.tsx b/example/ResourceItem.tsx
deleted file mode 100644
index 71b361d9b..000000000
--- a/example/ResourceItem.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import {
- SchedulerResource,
-} from "../src/Scheduler";
-class ResourceItem extends Component<{
- resource: SchedulerResource,
- isDragging: boolean,
- connectDragSource: (action: any) => any,
- connectDragPreview: (action: any) => any,
-}, {}> {
- constructor(props: Readonly<{ resource: SchedulerResource; isDragging: boolean; connectDragSource: (action: any) => any; connectDragPreview: (action: any) => any; }>) {
- super(props);
- }
-
- public render() {
- const { resource, isDragging, connectDragSource, connectDragPreview } = this.props;
- const dragContent = {resource.name} ;
-
- return (
- isDragging ? null : (
-
- {
- connectDragPreview(
- connectDragSource(dragContent),
- )
- }
-
- )
- );
- }
-}
-
-export default ResourceItem;
diff --git a/example/ResourceList.tsx b/example/ResourceList.tsx
deleted file mode 100644
index 001496073..000000000
--- a/example/ResourceList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import {
- SchedulerData,
-} from "../src/Scheduler";
-
-import DnDSource from "../src/DnDSource";
-
-class ResourceList extends Component<{
- schedulerData: SchedulerData,
- newEvent: any,
- resourceDndSource: DnDSource,
-}, {}> {
- constructor(props: Readonly<{ schedulerData: SchedulerData; newEvent: any; resourceDndSource: DnDSource; }>) {
- super(props);
- }
-
- public render() {
- const { schedulerData, newEvent, resourceDndSource } = this.props;
- const DnDResourceItem = resourceDndSource.getDragSource();
- const resources = schedulerData.resources;
- const resourceList = resources.map((item) => {
- return ;
- });
-
- return (
-
- );
- }
-}
-
-export default ResourceList;
diff --git a/example/Summary.tsx b/example/Summary.tsx
deleted file mode 100644
index 6d57810b6..000000000
--- a/example/Summary.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerSummaryPos,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
-
-class Summary extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
-
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Week, false, false, undefined, {
- getSummaryFunc: this.getSummary,
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.events);
- this.state = {
- viewModel: schedulerData,
- };
- }
-
- public render() {
- const { viewModel } = this.state;
-
- const leftCustomHeader = (
-
- );
-
- return (
-
- );
- }
-
- public getSummary = (schedulerData: SchedulerData, headerEvents: any, slotId: string, slotName: string, headerStart: string, headerEnd: string) => {
- const text = headerEvents.length.toString();
- let color = "#d9d9d9";
- if (headerEvents.length > 0) {
- color = headerEvents.length <= 1 ? "green" : "red";
- }
- return { text, color, fontSize: "12px" };
- }
-
- public changeSummaryPos = () => {
- const schedulerData = this.state.viewModel;
- schedulerData.config.summaryPos = schedulerData.config.summaryPos === SchedulerSummaryPos.TopRight ? SchedulerSummaryPos.BottomRight : SchedulerSummaryPos.TopRight;
- this.setState({
- viewModel: schedulerData,
- });
- }
-
-}
-
-export default withDragDropContext(Summary);
diff --git a/example/TaskItem.tsx b/example/TaskItem.tsx
deleted file mode 100644
index b1b304e41..000000000
--- a/example/TaskItem.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-
-class TaskItem extends Component<
- {
- task: any,
- isDragging: boolean,
- connectDragSource: (a?: any) => any,
- connectDragPreview: (a?: any) => any,
- }, {}> {
- constructor(props: Readonly<{ task: any; isDragging: boolean; connectDragSource: (a?: any) => any; connectDragPreview: (a?: any) => any; }>) {
- super(props);
- }
-
- public render() {
- const { task, isDragging, connectDragSource, connectDragPreview } = this.props;
- const dragContent = {task.name} ;
-
- return (
- isDragging ? null : (
-
- {
- connectDragPreview(
- connectDragSource(dragContent),
- )
- }
-
- )
- );
- }
-}
-
-export default TaskItem;
diff --git a/example/TaskList.tsx b/example/TaskList.tsx
deleted file mode 100644
index c367e6f77..000000000
--- a/example/TaskList.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import * as React from "react";
-import { Component } from "react";
-import {
- SchedulerData, SchedulerDnDSource,
-} from "../src/Scheduler";
-
-class TaskList extends Component<{
- schedulerData: SchedulerData,
- newEvent: any,
- taskDndSource: SchedulerDnDSource,
-}, {}> {
- constructor(props: Readonly<{ schedulerData: SchedulerData; newEvent: any; taskDndSource: SchedulerDnDSource; }>) {
- super(props);
- }
-
- public render() {
- const { schedulerData, newEvent, taskDndSource } = this.props;
- const DnDTaskItem = taskDndSource.getDragSource();
- const tasks = schedulerData.eventGroups;
- const taskList = tasks.map((item) => {
- return ;
- });
-
- return (
-
- );
- }
-}
-
-export default TaskList;
diff --git a/example/Tips.tsx b/example/Tips.tsx
index 3575b04b1..fb66bfa5f 100644
--- a/example/Tips.tsx
+++ b/example/Tips.tsx
@@ -1,45 +1,58 @@
-import * as React from "react";
-import { Component } from "react";
+import * as React from 'react';
+import { Component } from 'react';
class Tips extends Component<{}, {}> {
- constructor(props: Readonly<{}>) {
- super(props);
- }
+ constructor(props: Readonly<{}>) {
+ super(props);
+ }
- public render() {
- const divStyle = {
- margin: "24px auto",
- padding: "0px",
- width: "1000px",
- };
- const liStyle = {
- margin: "10 0 10 20",
- listStyle: "none",
- };
- return (
-
-
Thank you for trying React Big Scheduler. Here are some tips:
-
-
- 1. SchedulerData is the view model of Scheduler. For simplicity, I put it in react state object, you'd better put it in react props object when using.
-
-
- 2. Default configs are in the SchedulerData.config object, we can modify them when needed.
-
-
- 3. Default behaviors are in the SchedulerData.behaviors object, we can modify them when needed.
-
-
- 4. The event array set to the SchedulerData should be sorted in ascending order by event.start property, otherwise there will be many rendering errors in the Scheduler component.
-
-
- 5. From the npm version 0.2.6, Scheduler will use responsive layout by default(set SchedulerData.config.schedulerWidth to a percentage instead of a number).
-
-
-
-
- );
- }
+ public render() {
+ const divStyle = {
+ margin: '24px auto',
+ padding: '0px',
+ width: '1000px',
+ };
+ const liStyle = {
+ margin: '10 0 10 20',
+ listStyle: 'none',
+ };
+ return (
+
+
Thank you for trying React Big Scheduler. Here are some tips:
+
+
+
+ 1. SchedulerData is the view model of Scheduler. For simplicity, I put it in react state object, you'd
+ better put it in react props object when using.
+
+
+
+
+ 2. Default configs are in the SchedulerData.config object, we can modify them when needed.
+
+
+
+
+ 3. Default behaviors are in the SchedulerData.behaviors object, we can modify them when needed.
+
+
+
+
+ 4. The event array set to the SchedulerData should be sorted in ascending order by event.start property,
+ otherwise there will be many rendering errors in the Scheduler component.
+
+
+
+
+ 5. From the npm version 0.2.6, Scheduler will use responsive layout by default(set
+ SchedulerData.config.schedulerWidth to a percentage instead of a number).
+
+
+
+
+
+ );
+ }
}
export default Tips;
diff --git a/example/ViewSrcCode.tsx b/example/ViewSrcCode.tsx
index e0972af59..1eed2f28d 100644
--- a/example/ViewSrcCode.tsx
+++ b/example/ViewSrcCode.tsx
@@ -1,17 +1,23 @@
-import * as React from "react";
-import { Component } from "react";
+import * as React from 'react';
+import { Component } from 'react';
class ViewSrcCode extends Component<{ srcCodeUrl: string }, {}> {
- constructor(props: Readonly<{ srcCodeUrl: string; }>) {
- super(props);
- }
+ constructor(props: Readonly<{ srcCodeUrl: string }>) {
+ super(props);
+ }
- public render() {
- const { srcCodeUrl } = this.props;
- return (
- (</>View example source code )
- );
- }
+ public render() {
+ const { srcCodeUrl } = this.props;
+ return (
+
+ (
+
+ </>View example source code
+
+ )
+
+ );
+ }
}
export default ViewSrcCode;
diff --git a/example/Views.tsx b/example/Views.tsx
index 11ce38dff..a3c1efefa 100644
--- a/example/Views.tsx
+++ b/example/Views.tsx
@@ -1,67 +1,67 @@
-import * as React from "react";
-import { Component } from "react";
-import Scheduler, {
- SchedulerData,
- SchedulerViewTypes,
- SchedulerEvent,
-} from "../src/Scheduler";
-import * as ExampleFunction from "./ExampleFunctions";
-import { DemoData } from "./DemoData";
-import Nav from "./Nav";
-import ViewSrcCode from "./ViewSrcCode";
-import withDragDropContext from "./withDnDContext";
+import * as React from 'react';
+import { Component } from 'react';
+import { Scheduler, SchedulerData, SchedulerViewTypes, SchedulerEvent } from '../lib';
+import * as ExampleFunction from './ExampleFunctions';
+import { DemoData } from './DemoData';
+import Nav from './Nav';
+import ViewSrcCode from './ViewSrcCode';
+import withDragDropContext from './withDnDContext';
class Basic extends Component<{}, { viewModel: SchedulerData }> {
- constructor(props: Readonly<{}>) {
- super(props);
+ constructor(props: Readonly<{}>) {
+ super(props);
- const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Month, false, false, {
- eventItemPopoverEnabled: false,
- views: [
- { viewName: "Agenda View", viewType: SchedulerViewTypes.Month, showAgenda: true, isEventPerspective: false },
- { viewName: "Resource View", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: false },
- { viewName: "Task View", viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: true },
- ],
- });
- schedulerData.setResources(DemoData.resources);
- schedulerData.setEvents(DemoData.eventsForTaskView);
- this.state = {
- viewModel: schedulerData,
- };
- }
+ const schedulerData = new SchedulerData(ExampleFunction.getNow(), SchedulerViewTypes.Month, false, false, {
+ eventItemPopoverEnabled: false,
+ views: [
+ { viewName: 'Agenda View', viewType: SchedulerViewTypes.Month, showAgenda: true, isEventPerspective: false },
+ { viewName: 'Resource View', viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: false },
+ { viewName: 'Task View', viewType: SchedulerViewTypes.Month, showAgenda: false, isEventPerspective: true },
+ ],
+ });
+ schedulerData.setResources(DemoData.resources);
+ schedulerData.setEvents(DemoData.eventsForTaskView);
+ this.state = {
+ viewModel: schedulerData,
+ };
+ }
- public render() {
- const { viewModel } = this.state;
- return (
-
-
-
-
3 View Types (take month for example)
-
-
-
- );
- }
+ public render() {
+ const { viewModel } = this.state;
+ return (
+
+
+
+
+ 3 View Types (take month for example)
+
+
+
+
+
+ );
+ }
- public subtitleGetter = (schedulerData: SchedulerData, event: SchedulerEvent) => {
- return schedulerData.isEventPerspective ? schedulerData.getResourceById(event.resourceId).name : event.groupName;
- }
+ public subtitleGetter = (schedulerData: SchedulerData, event: SchedulerEvent) => {
+ return schedulerData.isEventPerspective ? schedulerData.getResourceById(event.resourceId).name : event.groupName;
+ };
}
export default withDragDropContext(Basic);
diff --git a/example/bundle.tsx b/example/bundle.tsx
index 6d7df5ba5..cc2c36a5d 100644
--- a/example/bundle.tsx
+++ b/example/bundle.tsx
@@ -1,50 +1,12 @@
-import * as React from "react";
-import { render } from "react-dom";
-import { HashRouter as Router, Route } from "react-router-dom";
-import Basic from "./Basic";
-import Readonly from "./Readonly";
-import Locale from "./Locale";
-import Views from "./Views";
-import CustomHeader from "./CustomHeader";
-import CustomTableHeaders from "./CustomTableHeaders";
-import CustomEventStyle from "./CustomEventStyle";
-import AddResource from "./AddResource";
-import DragAndDrop from "./DragAndDrop";
-import Summary from "./Summary";
-import AddMore from "./AddMore";
-import OverlapCheck from "./OverlapCheck";
-import NoCrossSlotMove from "./NoCrossSlotMove";
-import FreezeFirstRow from "./FreezeFirstRow";
-import ResourceClickable from "./ResourceClickable";
-import HideWeekends from "./HideWeekends";
-import CustomTimeWindow from "./CustomTimeWindow";
-import InfiniteScroll from "./InfiniteScroll";
-import InfiniteScroll2 from "./InfiniteScroll2";
-import CustomPopoverStyle from "./CustomPopoverStyle";
+import * as React from 'react';
+import { render } from 'react-dom';
+import { HashRouter as Router, Route } from 'react-router-dom';
+import Basic from './Basic';
+import '../src/css/style.css';
-import "../src/css/style.css";
-
-render((
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-), document.getElementById("root"));
+render(
+
+
+ ,
+ document.getElementById('root')
+);
diff --git a/example/index.html b/example/index.html
index 728b17586..e312b6a6c 100644
--- a/example/index.html
+++ b/example/index.html
@@ -1,18 +1,16 @@
-
-
-
-
+
+
+
-
+
React Big Scheduler Examples
-
+
-
+
-
-
-
\ No newline at end of file
+
+