react-big-scheduler icon indicating copy to clipboard operation
react-big-scheduler copied to clipboard

Monday as weekend!

Open AbdelilahJbr opened this issue 6 years ago • 6 comments

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 avatar Mar 13 '19 10:03 AbdelilahJbr

@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.

desilvaNSP avatar Mar 14 '19 02:03 desilvaNSP

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 avatar Jun 02 '19 23:06 bladerunner2020

@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;
};

jeffreybos avatar Jun 04 '19 11:06 jeffreybos

Perfect! Thank you very much. I overlooked this function...

bladerunner2020 avatar Jun 04 '19 22:06 bladerunner2020

@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!');
        }
}

madzadev avatar Nov 23 '19 16:11 madzadev

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

usahai avatar Sep 20 '20 07:09 usahai