Code Monkey home page Code Monkey logo

react-big-scheduler's Introduction

react-big-scheduler npm

A scheduler and resource planning component built for React and made for modern browsers (IE10+), IE needs babel-polyfill.
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).

Online demo

Inspired by Full Calendar Scheduler.

Version selection

Use and Setup

npm install react-big-scheduler --save

//1. import
import Scheduler, {SchedulerData, ViewTypes, DATE_FORMAT} from 'react-big-scheduler'
//include `react-big-scheduler/lib/css/style.css` for styles, link it in html or import it here
import 'react-big-scheduler/lib/css/style.css'
import moment from 'moment'
...

//2. create the view model, put it in the props obj
let schedulerData = new SchedulerData(new moment().format(DATE_FORMAT), ViewTypes.Week);
//set locale moment to the schedulerData, if your locale isn't English. By default, Scheduler comes with English(en, United States).
moment.locale('zh-cn');
schedulerData.setLocaleMoment(moment);
//set resources here or later
let resources = [
                    {
                       id: 'r0',
                       name: 'Resource0',
                       groupOnly: true
                    },
                    {
                       id: 'r1',
                       name: 'Resource1'
                    },
                    {
                       id: 'r2',
                       name: 'Resource2',
                       parentId: 'r0'
                    },
                    {
                       id: 'r3',
                       name: 'Resource3',
                       parentId: 'r4'
                    },
                    {
                       id: 'r4',
                       name: 'Resource4',
                       parentId: 'r2'
                    },
                ];
schedulerData.setResources(resources);
//set events here or later,
//the event array should be sorted in ascending order by event.start property, otherwise there will be some rendering errors
let 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'
                 },
                 {
                     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: 'r1',
                     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: 'r2',
                     title: 'R2 has recurring tasks every week on Tuesday, Friday',
                     rrule: 'FREQ=WEEKLY;DTSTART=20171219T013000Z;BYDAY=TU,FR',
                     bgColor: '#f759ab'
                 }
             ];
schedulerData.setEvents(events);

...

//3. render the scheduler component, mind that the Scheduler component should be placed in a DragDropContext(father or ancestor).
...
const {schedulerData} = this.props;
<Scheduler schedulerData={schedulerData}
           prevClick={this.prevClick}
           nextClick={this.nextClick}
           onSelectDate={this.onSelectDate}
           onViewChange={this.onViewChange}
           eventItemClick={this.eventClicked}
/>
...

Run examples locally

If you fail to execute the npm install command, remove the package-lock.json file and try again.

API

1.SchedulerData

SchedulerData is the view model of Scheduler, we can modify it to control the view of the Scheduler.

constructor

constructor(date=moment().format(DATE_FORMAT), viewType = ViewTypes.Week,
                showAgenda = false, isEventPerspective = false,
                newConfig = undefined, newBehaviors=undefined
                localeMoment = undefined)
  • date is a string in YYYY-MM-DD format, and is the initial date Scheduler will render. Take the date 2017-12-20 for example, Scheduler will render the time window of the week from 2017-12-18 to 2017-12-24 in ViewTypes.Week view type, and will render the time window of the 2017-12 month in ViewTypes.Month view type.
  • viewType is the initial view type, now Scheduler supports Day, Week, Month, Quarter, Year 5 built-in view types, in addition Scheduler now supports Custom, Custom1, Custom2 3 custom view types at the same time, in which you can control the time window yourself, refer to this example. viewType, showAgenda and isEventPerspective are a group which should be contained in the SchedulerData.config.views array, and they together decide which view should be rendered. When showAgenda and isEventPerspective are both false, Scheduler will render the resource view, refer to this example.
  • showAgenda is a bool value, if true, Scheduler will display the agenda view of current view type. Agenda view is read only.
  • isEventPerspective is a bool value, if true, Scheduler will display the task view of current view type. In resource view, every slot(row) describes how many events a resource does in the time window, while in task view, every slot describes how many events a big task is divided into and who will make it done. Add a groupId and groupName property to every event object, so that the events having the same groupId will belong to the same big task and be rendered in the same slot in task view. If groupId and groupName are not provided, SchedulerData will take the id as the groupId, and take the title as the groupName. See the eventsForTaskView in the DemoData.js for details.
  • newConfig is a config object, used to override the default config fully or partly.
  • newBehaviors is a config object, used to override the default behaviors fully or partly.
  • localeMoment is a locale moment object, which is unified used in react-big-scheduler. If not provided, Scheduler will come with English(en, United States) locale strings.

setLocaleMoment

setLocaleMoment(localeMoment);

Used to set locale moment to the schedulerData, if your locale isn't English. By default, Scheduler comes with English(en, United States)

setResources

setResources(resources);

Used to set the resources(the slots in resource view), make sure that there are no duplicated resource.id in the resources. See the demo resources in the DemoData.js.

setEvents

setEvents(events);

Used to set the events. the event array should be sorted in ascending order by event.start property. See the demo events in the DemoData.js. If we use the task view, we'd better add the groupId and the groupName property to each event object, see the eventsForTaskView in the DemoData.js for details.

prev

prev();

Let the time window scroll to the left once. When SchedulerData,viewType is ViewTypes.Month, the time window will scroll a month, when SchedulerData,viewType is ViewTypes.Week, the time window will scroll a week. SchedulerData.events will be clear after calling this method.

next

next();

Let the time window scroll to the right once. SchedulerData.events will be clear after calling this method.

setDate

setDate((date = moment().format(DATE_FORMAT)));

Let the time window jump to the provided date directly. SchedulerData.events will be clear after calling this method.

setViewType

setViewType(
  (viewType = ViewTypes.Week),
  (showAgenda = false),
  (isEventPerspective = false)
);

Tell SchedulerData to change current view, the viewType, showAgenda and isEventPerspective group should be provided, and should be contained in the SchedulerData.config.views array. SchedulerData.events will be clear after calling this method.

setEventGroups

setEventGroups(eventGroups);

Used to set the event groups(the slots in task view), make sure that there are no duplicated eventGroup.id in the eventGroups. This method is optional, and is needed only when SchedulerData.eventGroupsAutoGenerated is false.

setEventGroupsAutoGenerated

setEventGroupsAutoGenerated(autoGenerated);

Tell SchedulerData to generate SchedulerData.eventGroups automatically or not. If true, SchedulerData will generate the event groups(slots) automatically according to the event.groupId and 'event.groupName' automatically. If groupId and 'groupName' are not provided, SchedulerData will take event.id and event.title instead.

setMinuteStep

setMinuteStep(minuteStep);

Used to set minute step for daily view and refresh the render data.

toggleExpandStatus

toggleExpandStatus(slotId);

Used to toggle slot's(and its children's) expand status.

getMinuteStepsInHour

getMinuteStepsInHour();

Used to get minute steps in an hour, it equals 60 / SchedulerData.config.minuteStep.

addResource

addResource(resource);

Add the resource to the SchedulerData.resources, make sure that resource.id is not duplicated. Refer to this example.

addEventGroup

addEventGroup(eventGroup);

Add the eventGroup to the SchedulerData.eventGroups, make sure that eventGroup.id is not duplicated. Please note that the eventGroup added may be override when SchedulerData.eventGroupsAutoGenerated is true and SchedulerData.eventGroups is auto-generated.

addEvent

addEvent(newEvent);

Add the newEvent to the SchedulerData.events, make sure that newEvent.id is not duplicated. SchedulerData will place the newEvent in the right index according to the newEvent.start property.

updateEventStart

updateEventStart(event, newStart);

Update the newStart to the event.start, newStart is a string in YYYY-MM-DD HH:mm:ss format(similarly hereinafter). SchedulerData will replace the event in the right index according to the newStart value.

updateEventEnd

updateEventEnd(event, newEnd);

Update the newEnd to the event.end.

moveEvent

moveEvent(event, newSlotId, newSlotName, newStart, newEnd);

Update the newSlotId, newSlotName, newStart, newEnd of the event. In resource view, new slot is a resource, while in task view, new slot is a event group. SchedulerData will replace the event in the right index according to the newStart value.

removeEvent

removeEvent(event);

Remove the given event from SchedeulerData.events.

removeEventById

removeEventById(eventId);

Remove event from SchedeulerData.events by the given event id.

getSlots

getSlots();

Returns the slot array, SchedulerData.resources in resource view, SchedulerData.eventGroups in task view.

getSlotById

getSlotById(slotId);

Returns the slot by slotId, returns undefined if not found.

getResourceById

getResourceById(resourceId);

Returns the resource by resourceId, returns undefined if not found.

isEventInTimeWindow

isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd);

Returns whether an event is in the time window or not, remind that eventStart, eventEnd, windowStart, windowEnd are all moment objects.

2.Locale support(Refer to this example for details.)

SchedulerData.config.resourceName

The locale string of resource name.

SchedulerData.config.taskName

The locale string of task name.

SchedulerData.config.agendaViewHeader

The locale string of agenda view header.

SchedulerData.config.addMorePopoverHeaderFormat

The locale string of add more popover header format.

SchedulerData.config.eventItemPopoverDateFormat

The locale string of event item popover date format.

SchedulerData.config.nonAgendaDayCellHeaderFormat

The locale string of non-agenda view cell header format of day view type.

SchedulerData.config.nonAgendaOtherCellHeaderFormat

The locale string of non-agenda view cell header format of other view types.

SchedulerData.behaviors.getDateLabelFunc

Used to resolve the locale string of date label of Scheduler component.(Refer to the getDateLabel func for example)

3.SchedulerData.config(See the config.js for details.)

schedulerWidth

The width of Scheduler. If schedulerWidth is a number, Scheduler will use fixed width layout, while if schedulerWidth is a percentage, Scheduler will use responsive layout. And in the responsive layout: actual width of Scheduler = (SchedulerData.documentWidth - SchedulerData.config.besidesWidth) * SchedulerData.config.schedulerWidth SchedulerData.documentWidth is the window width of browser and will change automatically when resized.

schedulerMaxHeight

The max height of Scheduler. If the desired height is bigger than the max height, the header row of Scheduler will be frozen and vertical scroll bar will appear, but this won't happen when the max height is set to 0. Refer to this example.

tableHeaderHeight

Height of Scheduler table header.

agendaResourceTableWidth

Width of the left Scheduler resource column in agenda view.

agendaMaxEventWidth

Max width of an event item in agenda view.

dayResourceTableWidth, weekResourceTableWidth, monthResourceTableWidth, yearResourceTableWidth, quarterResourceTableWidth

Width of the left Scheduler resource column in resource view and task view of different view types.

dayCellWidth, weekCellWidth, monthCellWidth, yearCellWidth, quarterCellWidth

Width of Scheduler table cells in resource view and task view of different view types.

dayMaxEvents, weekMaxEvents, monthMaxEvents, yearMaxEvents, quarterMaxEvents

Max events count of a cell in resource view and task view of different view types. A '+N more' will appear when exceeded. Refer to this example.

eventItemHeight

Height of an event item in 3 views.

eventItemLineHeight

Line height of an event item in 3 views.

nonAgendaSlotMinHeight

Min height of a slot in non-agenda views, default 0, means there is no min height.

dayStartFrom

Start hour rendered from in ViewTypes.Day in resource view and task view, default 0.

dayStopTo

End hour rendered to in ViewTypes.Day in resource view and task view, default 23.

defaultEventBgColor

Default event item background color in 3 views, will be override if there is a bgColor property in event object.

selectedAreaColor

Selected cells color in resource view and task view, cells are selectable only when creatable is true.

nonWorkingTimeHeadColor

Color of non-working time head cells. Modify SchedulerData.behaviors.isNonWorkingTimeFunc to re-define non-working time. Refer the isNonWorkingTime func in the behaviors.js.

nonWorkingTimeHeadBgColor

Background color of non-working time head cells.

nonWorkingTimeBodyBgColor

Background color of non-working time body cells.

summaryColor

Color of cell summary. Modify SchedulerData.behaviors.getSummaryFunc to display summary in a cell. Refer the getSummary func in the behaviors.js.

summaryPos

Position of cell summary, supports SummaryPos.Top, SummaryPos.TopRight, SummaryPos.TopLeft, SummaryPos.Bottom, SummaryPos.BottomRight and SummaryPos.BottomLeft.

startResizable

Controls whether to resize the start of every event item in resource view and task view. If false, all item starts are non-resizable, if true, all item starts are resizable except those who have a resizable or startResizable property and its value is false.

endResizable

Controls whether to resize the end of every event item in resource view and task view. If false, all item ends are non-resizable, if true, all item ends are resizable except those who have a resizable or endResizable property and its value is false.

movable

Controls whether to move every event item in resource view and task view. If false, all items are non-movable, if true, all items are movable except those who have a movable property and its value is false.

creatable

Controls whether to create new event item in resource view and task view.

crossResourceMove

Controls whether to cross-slot move an event item in resource view and task view. If false, the slotId and slotName won't change in the moveEvent method. Refer to this example.

checkConflict

Controls whether to check conflicts when creating, resizing or moving an event item in resource view and task view. If true, Scheduler will call the conflictOccurred function if given. Refer to this example.

scrollToSpecialMomentEnabled

Controls Scheduler whether to scroll to special moment automatically when the time window contains special moment. If true, Scheduler horizontal bar will scroll to special moment after calling setScrollToSpecialMoment(true) to SchedulerData. Use SchedulerData.behaviors.getScrollSpecialMomentFunc to tell Scheduler what time the special moment is.

eventItemPopoverEnabled

Controls Scheduler whether to display event item popover when moving mouse on an event item, default true.

calendarPopoverEnabled

Controls Scheduler whether to display calendar popover when clicking on a date label in header, default true.

recurringEventsEnabled

Controls Scheduler whether to support recurring event, refer to this feature request, default true. If true, SchedulerData will filter out those template events who has a rrule string property in setEvents method, generate the recurring events in the time window, and insert them into the event array in the right orders. The recurring events generated from the same template event, all have a new id like ${templateEvent.id}-${number}, and have a recurringEventId property with the value templateEvent.id.

headerEnabled

Controls Scheduler whether to display header, default true.

displayWeekend

Controls Scheduler whether to display weekends in non-agenda view, default true.

relativeMove

Controls Scheduler whether to move events(only DnDTypes.EVENT type) relatively or absolutely, default true, means relatively.

minuteStep

Minute step for day view type in non-agenda view, can be 10, 12, 15, 20, 30, 60, etc, default 30.

views

Array of view that Scheduler will support.

4.SchedulerData.behaviors(See the behaviors.js for details.)

getEventTextFunc

getEventTextFunc(schedulerData, event);

Method that defines the text displayed in the event.

isNonWorkingTimeFunc

isNonWorkingTimeFunc(schedulerData, time);

Method that defines non-working time.

getSummaryFunc

getSummary(
  schedulerData,
  headerEvents,
  slotId,
  slotName,
  headerStart,
  headerEnd
);

Method that defines the summary text displayed in the Scheduler cells.Refer to this example.

getCustomDateFunc

getCustomDate(schedulerData, num, (date = undefined));

Method that controls the start and end of time window when current view type is Custom, Custom1 or Custom2.Refer to this example.

getNonAgendaViewBodyCellBgColorFunc

getNonAgendaViewBodyCellBgColor(schedulerData, slotId, header);

Method that sets the background color of cells dynamically.

getScrollSpecialMomentFunc

getScrollSpecialMoment(schedulerData, startMoment, endMoment);

Method that defines the special moment Scheduler will scroll to automatically, when the time window contains that moment.

5.Scheduler.propTypes

schedulerData

schedulerData: PropTypes.object.isRequired;

View model of the Scheduler component, provides data.

prevClick

prevClick: PropTypes.func.isRequired;
prevClick(schedulerData);

Callback function fired when the left point bracket '<' is clicked.

nextClick

nextClick: PropTypes.func.isRequired;
nextClick(schedulerData);

Callback function fired when the right point bracket '>' is clicked.

onViewChange

onViewChange: PropTypes.func.isRequired;
onViewChange(schedulerData, view);

Callback function fired when the Scheduler view changed. view is a json such as { viewType: ViewTypes.Month, showAgenda: true, isEventPerspective: false}.

onSelectDate

onSelectDate: PropTypes.func.isRequired;
onSelectDate(schedulerData, date);

Callback function fired when a new date is selected. date is the new selected data, a string in YYYY-MM-DD format.

eventItemClick

eventItemClick: PropTypes.func;
eventItemClick(schedulerData, event);

Callback function fired when you click an event item.

updateEventStart

updateEventStart: PropTypes.func;
updateEventStart(schedulerData, event, newStart);

Callback function fired when resizing the start of the event, newStart is a string in YYYY-MM-DD HH:mm:ss format.

updateEventEnd

updateEventEnd: PropTypes.func;
updateEventEnd(schedulerData, event, newEnd);

Callback function fired when resizing the end of the event, newEnd is a string in YYYY-MM-DD HH:mm:ss format.

moveEvent

moveEvent: PropTypes.func;
moveEvent((schedulerData, event, slotId, slotName, newStart, newEnd));

Callback function fired when moving the event. slotId, slotName are the new id and name of the slot moving into, but they won't change if the SchedulerData.config.crossResourceMove is false. newStart, newEnd are the new beginning and ending of the event.

newEvent

newEvent: PropTypes.func;
newEvent(schedulerData, slotId, slotName, start, end, type, item);

Callback function fired when creating a new event, or dragging an external item and dropping it into the resource view or task view. slotId and slotName are the slot creating in or dropping into, start, end are the beginning and ending of the event. If it's a drag&drop operation, the type is the DnDType of DnDSource registered to Scheduler, and the item is the external item.

leftCustomHeader, rightCustomHeader

leftCustomHeader: PropTypes.object;
rightCustomHeader: PropTypes.object;

Component you need to put in the Scheduler header, it could be a div or a react component. Refer to this example.

conflictOccurred

conflictOccurred: PropTypes.func;
conflictOccurred(
  schedulerData,
  action,
  event,
  type,
  slotId,
  slotName,
  start,
  end
);

Callback function fired when there is a conflict. This could happen when creating, resizing or moving an event, and when
SchedulerData.config.checkConflict is true.

eventItemTemplateResolver

eventItemTemplateResolver: PropTypes.func;
eventItemTemplateResolver(
  schedulerData,
  event,
  bgColor,
  isStart,
  isEnd,
  mustAddCssClass,
  mustBeHeight,
  agendaMaxEventWidth
);

Use this function, you can customize the event style. Refer to this example.

eventItemPopoverTemplateResolver

eventItemPopoverTemplateResolver: PropTypes.func;
eventItemPopoverTemplateResolver(
  schedulerData,
  eventItem,
  title,
  start,
  end,
  statusColor
);

Use this function, you can customize the event's popover style. Refer to this example.

slotItemTemplateResolver

slotItemTemplateResolver: PropTypes.func;
slotItemTemplateResolver(schedulerData, slot, slotClickedFunc, width, clsName);

Use this function, you can customize the left slot style.

nonAgendaCellHeaderTemplateResolver

nonAgendaCellHeaderTemplateResolver: PropTypes.func;
nonAgendaCellHeaderTemplateResolver(
  schedulerData,
  item,
  formattedDateItems,
  style
);

Use this function, you can customize the table header cell style. Refer to this example.

onScrollLeft, onScrollRight

onScrollLeft: PropTypes.func;
onScrollLeft(schedulerData, schedulerContent, maxScrollLeft);
onScrollRight: PropTypes.func;
onScrollRight(schedulerData, schedulerContent, maxScrollLeft);

Callback function fired when the scheduler content div scrolls to leftmost or rightmost. Refer to this example.

onScrollTop, onScrollBottom

onScrollTop: PropTypes.func;
onScrollTop(schedulerData, schedulerContent, maxScrollTop);
onScrollBottom: PropTypes.func;
onScrollBottom(schedulerData, schedulerContent, maxScrollTop);

Callback function fired when the scheduler content div scrolls to topmost or bottommost. Refer to this example.

slotClickedFunc

slotClickedFunc: PropTypes.func;

If it's set, slots will be clickable, and will fire this function when a slot is clicked. Refer to this example.

dndSources

dndSources: PropTypes.array;

DnDSource array that registered to Scheduler. Use DnDSource, we can simplify the drag and drop coding in React-Big-Scheduler. Refer to this example.

onSetAddMoreState

onSetAddMoreState: PropTypes.func;
onSetAddMoreState(newState);

Callback function fired when a '+N more' is clicked, is used to control the visibility and the position of the AddMorePopover. newState is a json such as {headerItem: headerItem, left: 20, top: 20, height: 100}. Refer to this example.

subtitleGetter

subtitleGetter: PropTypes.func;
subtitleGetter(schedulerData, event);

Use this function, you can display a subtitle in the EventItemPopover.

viewEventClick

viewEventClick: PropTypes.func;
viewEventClick(schedulerData, event);

Callback function fired when you click one operation link in the EventItemPopover. The operation link won't appear if this function isn't set.

viewEventText

viewEventText: PropTypes.string;

Text of one operation link in the EventItemPopover. The operation link won't appear if this text isn't set.

viewEvent2Click

viewEvent2Click: PropTypes.func;
viewEvent2Click(schedulerData, event);

Callback function fired when you click the other operation link in the EventItemPopover. The other operation link won't appear if this function isn't set.

viewEvent2Text

viewEvent2Text: PropTypes.string;

Text of the other operation link in the EventItemPopover. The other operation link won't appear if this text isn't set.

react-big-scheduler's People

Contributors

allsportster023 avatar davidfurlong avatar fizzbuzz791 avatar henryroach avatar jennysong avatar jokinen avatar mikedev96 avatar mongrelx avatar stephenchou1017 avatar tgbryanbailes avatar zomervinicius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-big-scheduler's Issues

Feature Request: Hide weekends with config option

In my project that uses react-big-scheduler I have a need to turn weekends off because they are never used, so as to not show unused days I went in a filtered them out before render. The one issue with that is they (days) still live on in the state, because they were filtered just before rendering

This would be an awesome feature for businesses -- with no need to see unused days -- wanting to use your project!

Great work on the project, it has been very useful! ๐Ÿ‘

EDIT: Do you want me to open another FR for toggling collapse in the config?

Run getSummary function without force updating the component

Hi, is there a way to run getSummary function without force updating the component?

My Usecase:
I have a array of some items that is used as the summary text. I want to update the summary text when state changes.
This is my summary function

getSummary = (schedulerData, headerEvents, slotId, slotName, headerStart, headerEnd) => {
    var date = headerStart.split(" ")[0];
    var id_index = this.state.workload.findIndex(x => x.id === slotId);
    var date_index = this.state.workload[id_index].workload.findIndex(x => x.date === date);
    var text = this.state.workload[id_index].workload[date_index].workload

    let color = 'green';
    if (text < 1)
      color = 'red';
    return { text: text, color: color, fontSize: '12px' };
  }

What i've done:
update the state and then forcerender the component. But don't think that is a good practice.
Any ideas?

Edit:
I found a way by manipulating the renderData object in schedulerData

[Bug] Mutating State directly

As far as I've traced it, state is modified directly and the object is never re-declared or over-written. This had led to feature developments and new implementations difficult, as I can't trust that the original objects I supply to schedulerData will not be modified.

Show week number?

Hi, is is possible to show week number in the "Quater" view?
Thanks

Separate DnDContext? Possible Bug.

I have ran into an issue where drawing more than 1 scheduler at the same time causes the DnDContext to be linked. Moving an event from one to the other removes it from viewModel.renderData but not viewModel.events causing an artifact issue. The event will persist in viewModel.events even after a state update but not be rendered on the screen.

Now I know that having more than one scheduler on the page was not the what you designed it for, but it seems to be the only way to fulfill our needs. So is there something in the DnD modules/files that you can think to modify to solve this 'issue?'

Before move:
image

After move, notice the price persisted on the bottom RBS
image

After moving within the top RBS causes the bottom one to change 'accordingly.'
image

I'm at a loss right now, could really use some help with this one

Example not wokring -- dragDropManager undefiend

"react-big-scheduler": "^0.2.2",
"react": "^16.5.2",
"react-dnd": "^6.0.0",
"react-dnd-html5-backend": "^6.0.0",

i copied the basic example and having this error :

Failed context type: The context dragDropManager is marked as required in DropTarget(ResourceEvents), but its value is undefined.

How to make same range event not stacked but side by side

Hi, I wanna make the events in daytime mode to be side-stacked when they are on the same range time

image

not like this

image

for the first image, I used 1 minuteStep so there won't any stacked event but the load much slower and the border also irritating.
Thanks, bro for your hard work

Set initial view to a specified date

Hi,
Is it possible to set the initial view (after mounting the component) to a specified date, rather than date of the today

example:
In the quarter view, the current date is 29/08/2018 , it is the first column in the table. But i want to set the first column to let's say 20/08/2018.
Is this possible?
Thanks

Day view schedule is not showed correctly

Hello, I've tested day view but when the page is loaded for the first time, the day view is not loaded correctly.
You can check in Basic example:
When I change the code at line 16 from
let schedulerData = new SchedulerData('2017-12-18', ViewTypes.Week);
to
let schedulerData = new SchedulerData('2017-12-18', ViewTypes.Day);
the view is not showed properly.

The context `dragDropManager` value is undefined

Im following the basic setup of the Scheduler but I always get the same error.

Failed context type: The context `dragDropManager` is marked as required in `DropTarget(ResourceEvents)`, but its value is `undefined`.
    in DropTarget(ResourceEvents) (created by Scheduler)

I have a component called SchedulePage that renders a Schedule component. The Schedule component is the Basic setup for the scheduler.

. . // imports

class Schedule extends Component {
  constructor(props) {
    super(props);

    //let schedulerData = new SchedulerData(new moment("2017-12-18").format(DATE_FORMAT), ViewTypes.Week);
    let schedulerData = new SchedulerData('2017-12-18', ViewTypes.Week);
    schedulerData.localeMoment.locale('en');
    schedulerData.setResources(DemoData.resources);
    schedulerData.setEvents(DemoData.events);
    this.state = {
      viewModel: schedulerData
    }
  }

  render() {
    const { viewModel } = this.state;
    return (
          <Scheduler
             ...props // props from the basic example
          />

    )
  }

export default withDragDropContext(Schedule)
class SchedulePage extends component {
 ... // fetching data and some logic

  return {
    render(
        <Schedule />
    )
  }
}

export default connect(
  mapStateToProps,
  {  ... dispatches },
)(ScheduleDetailsPage);

Im guessing Im wrapping the wrong component with the dnd context.

A beta version 0.2.3 published

Hi all,

Just now I published one beta version 0.2.3, to test the using of react-big-scheduler. Generally it's almost the same with the latest version 0.2.2, the only difference is that 0.2.3 tries to fix leaking antd global CSS rules described in here. I hope you can try this beta version, mainly in the two cases:

  1. All web site pages are antd style compatible and use antd global CSS rules;
  2. The web site pages have their own global CSS rules, only a few pages use the Scheduler component.

Feel free to tell me if any issues. Thanks.

Change minutes interval in day view

Hello, is it possible to change minutes interval in day view from 30 minutes to 15? If it's not currently possible, do you plan this feature in future?

Thank you

[Feature Request] Display month view without horizontal scrollbar

Would it be possible to have a view that shows the full month (or a defined number of weeks) all on one view without a horizontal scrollbar. I'm using this for longer term events, where each event will usually span 1 or 2 weeks, so it would be great to see lots of weeks at the same time without scrolling, even if each day is very small.

give a percentage to schedulerWidth

Hello Stephen,
Could you tell me is it possible that I can set the schedulerWidth with percentage instead of giving a fixed width?
I know I can give schedulerWidth a fixed width like this:
schedulerData.config.schedulerWidth = '600';
But what I want is:
schedulerData.config.schedulerWidth = '100%';
So that I can make sure that the scheduler never out of range.

Thank you so much.

Infinite scroll - Day scheduler

Hey,
Is it possible to set a schedule to show hourly day after day in an infinite scroll?
I mean the day's view, where after scrolling to the end of the day the next one is loaded.

thank you in advance for your help !

How to exchange two events?

Hi, I'm new to this.
I want to know that how can I exchange two events?
Like I have two events: event_A and event B, and each of them will be happened at 3 p.m. and 4 p.m.

Now I want to make it to event_A will be happened at 4 p.m. and event_B is at 3 p.m via click them.
Is it possible to make it realize?

Thank you.

dayMaxEvents not working for values > 2

If i set the configuration for less than 2 value the '+N more' works fines, but no value greater than 2 is working. It shows max of 2 events and then '+N more' appears.

[npm] Could you release a beta version of the next set of features into npm

Hi,

the version in npm is about four months old. You have since added some new features and made improvements in this repository, but we, the library users, can't yet take advantage of those.

I can appreciate that releasing a npm version might be a a burden, maybe due to documentation concerns for instance. But could you consider releasing the changes with a beta tag for instance? In that case you wouldn't need to complete the release, those of us who would want to use the improvements would get to do so and maybe you'd even get some beta testing out of us.

Thanks for the library and effort.

Feature Request: Sticky Header

If you have enough events that makes you scroll vertically, the timeline dates header should follow. This is useful to always show the relevant dates regardless what resource or event the user is looking at. The screenshot shows that it currently does not do that.

screen shot 2018-08-28 at 5 43 08 pm

slotItemTemplateResolver should return the item from the resources

Hello,
If I want to have a custom template on the resources table (left side of calendar) the method called by slotItemTemplateResolver is giving me and item with the following:

{
                slotId: ...,
                slotName: ....,
                rowHeight: ....,
                headerItems: ....
}

Even though I'm passing on schedulerData.setResources a complete object like:

{
                id: data.id,
                name: data.title,
                complexObject: {....}
}

When my custom template method is called I only get slotId, slotName etc... but i would like to have my object back the same as I set it on the schedulerData.setResources

The workaround for now is slotItemTemplateResolver is sending me back the id of my item and then i can search for it on my properties but I think the scheduler should return it as well.

Or maybe i have something wrong :)

Thank you so much!

Prevent snapping to cells

Stephen,
Thanks for developing and sharing this component - much appreciated.
One question, is there a way to prevent the events on the timeline from snapping to the nearest cell?
I have events which but up against each other and it causes the events to drop onto another row .
I have included an example to show what I mean. In the example the three events start/stop at adjacent times (i.e the first event finishes at 9:53, and the second event starts at 9:53.
Is there any way to get these to display on the same row rather than the second event dropping down?
Thanks in advance
Rich
capture

Publish on NPM

Hi,
I wanted to know when 'react-big-scheduler' with the 'Custom time window' will be publish on npm?

Thank you in advance for your help!

No events render on 0.2.5

After getting everything working on 0.2.2, I saw you published 0.2.5 today which fixes the css leaking issue from antd.

However, after upgrading to 0.2.5, no events are rendering, and no errors are thrown (the resources table renders fine). I've tried to dig through the changes, but I cannot for the life of me figure out what the issue is. My best guess is it has something to do with the DnD library version upgrade. I've attached a screenshot from the react devtools when running v0.2.5, and the state for the drop target component (rendered inside the scheduler-content-table) is empty and no context is defined.

The Scheduler component has events and eventGroups props defined when inspecting via react devtools.

screen shot 2018-11-29 at 4 25 41 pm

I'm running react v16.4.1, in case that could have any effect on things as well.

Change the background color of cells dynamically.

Hi.. Is this possible to do?
What i want to do is change the background color of a cell dynamically (if some condition becomes true, then change color).
Is there a function like getSummary to change the className or background color of the body cell?
Thanks

Unable to build project / run examples

Environment

$ node --version
v11.1.0

$ npm --version
6.4.1

Steps to reproduce

git clone https://github.com/StephenChou1017/react-big-scheduler.git
cd react-big-scheduler
npm install

The following error occurs:

npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting [email protected]:
npm ERR! Verification failed while extracting [email protected]:
npm ERR! sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0= integrity checksum failed when using sha1: wanted sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0= but got sha512-Bmr56pxML1c9kU+NS51SMFkiVQAb+9uFfXwyqR2tn4w2FPvmPt65eZ9aCcEfRXd9G74HkZnILC6p967pED4aiw== sha1-tx1A2UPQqV2gGVa1R/g8SltKNKw=. (8789 bytes)

After removing package-lock.json I am able to successfully run npm install, although there are warnings produced.

When I then run npm run example I get this error:

$ npm run example

> [email protected] example ~/Documents/home/projects/react-big-scheduler
> webpack-dev-server --config ./webpack/webpack-dev.config.js --hot

~/Documents/home/projects/react-big-scheduler/node_modules/webpack-cli/bin/config-yargs.js:89
				describe: optionsSchema.definitions.output.properties.path.description,
				                                           ^

TypeError: Cannot read property 'properties' of undefined

This seems to be related to webpack/webpack-cli#607. Running npm install --save-dev [email protected] fixes this problem.

Running npm run example again generates the last error that I could not solve:

ERROR in ./src/less/antd-globals-hiding-hack.less (./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./node_modules/less-loader/dist/cjs.js??ref--5-3!./src/less/antd-globals-hiding-hack.less)
Module build failed (from ./node_modules/less-loader/dist/cjs.js):


  @import 'antd/lib/style/core/index.less';
  @import 'antd/lib/style/themes/default.less';
^
Can't resolve './antd/lib/style/themes/default.less' in '~/Documents/home/projects/react-big-scheduler/src/less'
      in ~/Documents/home/projects/react-big-scheduler/src/less/antd-globals-hiding-hack.less (line 5, column 2)

The CSS styling doesn't work

Hi, I am trying to use scheduler in my project. The CSS does not load properly for the ant-pop-over.
image

As you can see when I try to hove over under-maintenance section, the pop-over is on the middle left of the screen with disturbed css.
My component Looks like this:

class Basic extends Component {
    constructor(props) {
        super(props);

        let schedulerData = new SchedulerData(new moment().format('YYYY-MM-DD'), ViewTypes.Day, false, false, config);
        schedulerData.setResources(DemoData.resources);
        schedulerData.setEvents(DemoData.events);
        this.state = {
            viewModel: schedulerData
        }
    }

    componentDidMount() {
        this.interval = setInterval(() => {
            let schedulerData = new SchedulerData(new moment().format('YYYY-MM-DD'), ViewTypes.Day, false, false, config);
            schedulerData.setResources(DemoData.resources);
            schedulerData.setEvents(DemoData.events);
            this.setState({ viewModel: schedulerData })
        }, 60000);

    }

    componentWillMount() {
        clearInterval(this.interval);
    }

    render() {
        const { viewModel } = this.state;
        return (
            <div>
                <div>
                    <Scheduler schedulerData={viewModel}
                        prevClick={() => { }}
                        nextClick={() => { }}
                        onViewChange={() => { }}
                        onSelectDate={() => { }}
                    />
                </div>
            </div>
        )
    }
}

export default withDragDropContext(Basic)

The config is:

const moment  =  require('moment');

export default {
    dayResourceTableWidth: 350,
    schedulerWidth: '1900',
    dayCellWidth: 25,
    schedulerMaxHeight: 1000,
    headerEnabled: false,
    eventItemHeight: 75,
    eventItemLineHeight: 80,
    dayStartFrom:13,
    dayStopTo: 17,
    minuteStep: 1,
    startResizable: true,
    endResizable: false,
    movable: false,
    creatable: false,
    resourceName: 'Machines'
}

and the demo data looks like this:
let moment = require('moment');

let moment = require('moment');

const DemoData = {
    resources: [{
            id: 'r1',
            name: 'Laser LCR-1',
        },
        {
            id: 'r2',
            name: 'Laser LCR-2',
        },
        {
            id: 'r3',
            name: 'Laser LCR-3',
        },
        {
            id: 'r4',
            name: 'Laser LCR-4',
        }
    ],
    events: [{
            id: 1,
            start: new moment().subtract(36,'minutes').format('YYYY-MM-DD HH:mm:ss'),
            end: new moment().subtract(31, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            resourceId: 'r1',
            title: 'Done',
            bgColor: '#D9D9D9'
        },{
            id: 2,
            start: new moment().subtract(30,'minutes').format('YYYY-MM-DD HH:mm:ss'),
            end: new moment().subtract(26, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            resourceId: 'r1',
            title: 'Done',
            bgColor: '#D9D9D9'
        },{
            id: 3,
            start: new moment().subtract(25, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            end: new moment().subtract(21, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            resourceId: 'r1',
            title: 'Done',
            bgColor: '#D9D9D9'
        },{
            id: 4,
            start: new moment().subtract(20, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            end: new moment().subtract(16, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            resourceId: 'r1',
            title: 'In Progress',
            bgColor: '#00CC00'
        },{
            id: 5,
            start: new moment().subtract(15, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            end: new moment().subtract(11, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            resourceId: 'r1',
            title: 'Next in line',
            bgColor: '#66FFFF'
        },{
            id: 6,
            start: new moment().subtract(10, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            end: new moment().subtract(6, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
            resourceId: 'r1',
            title: 'In commit Window',
            bgColor: '#66FFFF'
        }
    ]
}

export default DemoData;

Please Help

Ant design global styles are leaked through this package

Hello again!

I don't know if you have noticed, but Ant design leaks some global style definitions such as reset styles. There's quite an extensive issue about it in antd's repository which gives some background:
ant-design/ant-design#4331

The problem is that this library imports directly from within the index of the antd package:

import React, {Component} from 'react'
import {PropTypes} from 'prop-types'
import {Row, Col, Icon, Radio, Popover, Calendar} from 'antd'
import EventItem from './EventItem'

Which means that the global reset styles are applied on all projects which use this library. For instance with our project links would get coloured unexpectedly as we are using styled-components and have only a few global styles.

I've opened a PR (#19) for this issue which proposes a quite hacky fix. Hopefully it can act as a starting point for resolving this issue.

Disable +Nmore popover

I have a schedule with a whole bunch of events in a single ressource and I want to display all the events with no height limit.

Essentially I want to disable the +Nmore popover and always display the events instead, and I can't figure out how to do it.

Is there any way I can achieve that? And if not I guess this is a feature request.

Minute step is not set properly

Implementing the basic example in my application results in the following error: "Error: Minute step is not set properly - 60 minutes must be divisible without remainder by this number". This is occurring in 0.2.1

This occurs at this line:
let schedulerData = new SchedulerData('2017-12-18', ViewTypes.Week);
And will also occur when using moment and DATE_FORMAT:
let schedulerData = new SchedulerData(new moment("2017-12-18").format(DATE_FORMAT), ViewTypes.Week);

SchedulerData.js:702 Uncaught Error: Minute step is not set properly - 60 minutes must be divisible without remainder by this number
    at SchedulerData._validateMinuteStep (SchedulerData.js:702)
    at new SchedulerData (SchedulerData.js:60)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.