bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

Issue with scrollToDate and workingTime #5694

Closed taauntik closed 1 year ago

taauntik commented 1 year ago

Forum post

import '../_shared/shared.js'; // not required, our example styling etc.
import Scheduler from '../../lib/Scheduler/view/Scheduler.js';

//region Data
const
    resources = [
        { id : 'r1', name : 'Mike' },
        { id : 'r2', name : 'Linda' },
        { id : 'r3', name : 'Don' },
        { id : 'r4', name : 'Karen' },
        { id : 'r5', name : 'Doug' },
        { id : 'r6', name : 'Peter' },
        { id : 'r7', name : 'Sam' },
        { id : 'r8', name : 'Melissa' },
        { id : 'r9', name : 'John' },
        { id : 'r10', name : 'Ellen' }
    ],
    events = [
        {
            id         : 1,
            resourceId : 'r1',
            startDate  : new Date(2017, 0, 1, 10),
            endDate    : new Date(2017, 0, 1, 12),
            name       : 'Click me',
            iconCls    : 'b-fa b-fa-mouse-pointer'
        },
        {
            id         : 2,
            resourceId : 'r2',
            startDate  : new Date(2017, 0, 1, 12),
            endDate    : new Date(2017, 0, 1, 13, 30),
            name       : 'Drag me',
            iconCls    : 'b-fa b-fa-arrows-alt'
        },
        {
            id           : 3,
            resourceId   : 'r3',
            startDate    : new Date(2017, 0, 1, 14),
            duration     : 2,
            durationUnit : 'h',
            name         : 'Double click me',
            eventColor   : 'purple',
            iconCls      : 'b-fa b-fa-mouse-pointer'
        },
        {
            id         : 4,
            resourceId : 'r4',
            startDate  : new Date(2017, 0, 1, 8),
            endDate    : new Date(2017, 0, 1, 11),
            name       : 'Right click me',
            iconCls    : 'b-fa b-fa-mouse-pointer'
        },
        {
            id         : 5,
            resourceId : 'r5',
            startDate  : new Date(2017, 0, 1, 15),
            endDate    : new Date(2017, 0, 1, 17),
            name       : 'Resize me',
            iconCls    : 'b-fa b-fa-arrows-alt-h'
        },
        {
            id         : 6,
            resourceId : 'r6',
            startDate  : new Date(2017, 0, 1, 16),
            endDate    : new Date(2017, 0, 1, 19),
            name       : 'Important meeting (read-only)',
            iconCls    : 'b-fa b-fa-exclamation-triangle',
            eventColor : 'red',
            readOnly   : true
        },
        {
            id         : 7,
            resourceId : 'r6',
            startDate  : new Date(2017, 0, 1, 6),
            endDate    : new Date(2017, 0, 1, 8),
            name       : 'Sports event',
            iconCls    : 'b-fa b-fa-basketball-ball'
        },
        {
            id         : 8,
            resourceId : 'r7',
            startDate  : new Date(2017, 0, 1, 9),
            endDate    : new Date(2017, 0, 1, 11, 30),
            name       : 'Dad\'s birthday!',
            iconCls    : 'b-fa b-fa-birthday-cake',
            // Custom styling from data
            style      : 'background-color : teal; font-size: 18px',
            // Prevent default styling
            eventStyle : 'none'
        }
    ];

//endregion

let startOfMonth = new Date(2017, 0, 1, 6);
let endOfMonth = new Date(startOfMonth.getFullYear(), startOfMonth.getMonth()+1, 0, 20);
const scheduler = new Scheduler({
    appendTo         : 'container',
    resources        : resources,
    events           : events,
    startDate        : startOfMonth,
    endDate          : endOfMonth,
    viewPreset : {
        base           : 'day',
        shiftIncrement : 1,
        shiftUnit      : 'month'
    },
    snap: true,
    timeResolution : {
        unit      : 'minute',
        increment : 15
    },
    weekStartDay: 1,
    workingTime: { fromDay : 1, toDay : 5, fromHour : 6, toHour : 20},
    rowHeight        : 50,
    barMargin        : 5,
    multiEventSelect : true,
    columns          : [
        { text : 'Name', field : 'name', width : 130 }
    ],

tbar : [
    '->',
    {
        type  : 'buttongroup',
        items : [
            {
                type    : 'button',
                icon    : 'b-fa-angle-right',
                tooltip : 'Next month',
                async onAction() {
                    let start = new Date(scheduler.startDate.getFullYear(), scheduler.startDate.getMonth()+1, 1);
                    let end = new Date(scheduler.startDate.getFullYear(), scheduler.startDate.getMonth()+2, 0, scheduler.endDate.getHours());

                    scheduler.setTimeSpan(start, end);
                    scheduler.scrollToDate(new Date(start.getFullYear(), start.getMonth(), start.getDate(), 6), { block : 'start' });
                }
            }
        ]
    }
]
});

You can reproduce it in our basic example

  1. in the basic app.js remove the whole code and copy and paste the code above.
  2. press the next month button to head into the next month.
  3. for the first time you click it shows from the beginning of the month and to end of the month
  4. then press 3 or 4 times or more times
  5. then you'll see that it's not starting from the beginning of the and not ends in the end of the month
    workingTime: { fromDay : 1, toDay : 5, fromHour : 6, toHour : 20},

when you comment out this line it works fine. but with workingTime it doesn't work properly

mkiriejevas commented 1 year ago

Hello, the bug is not scheduled for fix yet. Is there any temporary workaround (we have to keep workingTime filtered :( ) or maybe there is info on upcoming bug fix in the next few weeks?

chuckn0rris commented 1 year ago

Won't fix. The problem in user code. I will reply in forum's thread.