react-big-scheduler
react-big-scheduler copied to clipboard
Monday as weekend!
Hello
I used the Basic demo to build the component, there is a mistake also in the demo, It considers that Monday is a weekend, not Saturday? Can I fix this?
@AbdelilahJbr This is highly customizable libary, you just want change the configuration in Scheduler components and config.js file. After that you can customize the scheduler as you want.
I ran into the same issues. Mondays are shown as weekend. I didn't find how to fix this with settings. I checked the code and I think the issue could be due to these lines:
if (this.config.displayWeekend || dayOfWeek !== 0 && dayOfWeek !== 6) { // ... }
I believe that it's necessary to check which day week starts in the locale and depending on it use 5 instead of zero...
@bladerunner2020 You can override the isNonWorkingTime function.
let schedulerData = new SchedulerData(
new moment().format(DATE_FORMAT),
ViewTypes.Month,
false,
false,
config,
{ isNonWorkingTimeFunc: this.isNonWorkingTime }
);
function isNonWorkingTime(schedulerData, time) {
var localeMoment = schedulerData.localeMoment;
if (schedulerData.cellUnit === _index.CellUnits.Hour) {
var hour = localeMoment(time).hour();
if (hour < 9 || hour > 18) return true;
} else {
var dayOfWeek = localeMoment(time).weekday();
if (dayOfWeek === 5 || dayOfWeek === 6) return true;
}
return false;
};
Perfect! Thank you very much. I overlooked this function...
@jeffreybos also related to isNonWorkingTime function, is it possible to detect whether or not it is non-working time on selecting date/-s? so far I've tried this in Basic.js:
newEvent = (schedulerData, slotId, slotName, start, end, type, item) => {
if (schedulerData.isNonWorkingTimeFunc(start, end)) {
alert('You selected a non-working day!');
}
}
Just out of curiosity, the above 2 functions both toggle the colors as to what is detected as a weekend, right? Neither of those would allow me to change the start date of the week to Monday? My scheduler goes from Monday - Sunday
EDIT: I have provided this as a solution to changing the week-view from sunday-saturday to monday-sunday, as well as highlighting the weekends here