Our pure JavaScript Scheduler component


Post by dphilip »

Consider the following use case where Both Event A and Event B should not be scheduled before 2020-03-23 12:02 AM and after 2020-03-23 4:00 PM
To achieve this I have used getDateConstraints https://bryntum.com/products/schedulerpro/docs/api/Scheduler/view/SchedulerBase#config-getDateConstraints

if you play with the zoom levels, and try to drag event A to have the end datetime to the latest datetime (which is 4:00 pm in this case), Event A will auto adjust itself to have end datetime as 2020-03-23 3:53 PM (based on the zoom level).
Similarly with the start date, if you drag event A to the earliest datetime (which is 12:02 AM), Event A will auto adjust it's start datetime to 2020-03-23 12:00 AM (based on the zoom level).

Can you help me with this? How can I stop the Events from auto adjusting itself to a random datetime? I believe the events auto adjust itself to nearest 15/30 minute interval.

P.S. In some cases, the events do not respect the constraints and auto adjust itself after the latest date or/and before the earliest date.

Code for the above use case:

import {  SchedulerPro } from '../../build/schedulerpro.module.js?465031';
import shared from '../_shared/shared.module.js?465031';

const scheduler = new SchedulerPro({
    project: {
        "resources": [{
                "id": 1,
                "name": "Resource 1",
            },
            {
                "id": 2,
                "name": "Resource 2",
            },
        ],
        "events": [{
                "id": 1,
                "name": "Event A",
                "startDate": "2020-03-23T03:00",
                "duration": 111,
                "durationUnit": "minutes",
            },
            {
                "id": 2,
                "name": "Event B",
                "startDate": "2020-03-23T01:00",
                "duration": 97,
                "durationUnit": "minutes",
            },
        ],
        "assignments": [{
                "id": 1,
                "event": 1,
                "resource": 1
            },
            {
                "id": 2,
                "event": 2,
                "resource": 2
            }
        ]
    },

appendTo: 'container',
startDate: '2020-03-23',
endDate: '2020-03-24',
rowHeight: 40,
barMargin: 10,
viewPreset: 'hourAndDay',
getDateConstraints() {
    const start = new Date("2020-03-23 12:02 AM");
    const end = new Date("2020-03-23 4:00 PM");

    return {
        start,
        end,
    };
},
features: {
    eventDrag: {
        constrainDragToResource: false,
        unifiedDrag: false,
        showExactDropPosition: true,
    },

},

timeResolution: {
    unit: 'minute',
    increment: 1
},
shiftIncrement: 1,
shiftUnit: 'minute',
columns: [
    {
        text: 'Resource',
        width: 150,
        field: 'name',
        htmlEncode: false,
    }
],
});

Post by alex.l »

Hi dphilip@kinaxis.com,

Thank you for clear test case!
I've reproduced that, here is a ticket to track the status: https://github.com/bryntum/support/issues/6041
Meanwhile you can manage https://bryntum.com/products/schedulerpro/docs/api/Scheduler/preset/ViewPreset#field-shiftIncrement for viewPresets, it will help to allow drop event to exact position without adjusting.
More info here https://bryntum.com/products/schedulerpro/docs/api/Scheduler/preset/ViewPreset
Demo: https://bryntum.com/products/schedulerpro/examples-scheduler/configuration/

All the best,
Alex


Post by dphilip »

Thank you for your response.

If you add following lines to the code I sent previously -- it still does not resolve the issue.

  shiftIncrement    : 1,
  shiftUnit         : 'second',

The Demo you shared seems to be working correctly. However I notice that you have used Scheduler instead of SchedulerPro wonder if that could be the reason it works in your demo and not mine?

It seemed like the value for the start and end date was changing at afterEventDrop, Hence as a workaround(for now), in my code I forcefully set the event startDate and endDate in afterEventDrop.

afterEventDrop({context}) {
        const {startDate, endDate, newResource} = context;   
context.eventRecord.set("startDate", startDate); context.eventRecord.set("endDate", endDate); }

Do you think adding this piece of code could pose a problem / create bugs in other areas?
Also can you please suggest a more ideal solution?


Post by alex.l »

Hi,

Could you please share more context about the last case you described? I need particular code, data and steps to reproduce for analyse. As you know, SchedulerPro has the Engine for event scheduling, but Scheduler doesn't. I need to make sure that event has correct constraints to be in the place you want.

If you add following lines to the code I sent previously -- it still does not resolve the issue.

In this case it's deeper than I thought and we need to wait for the ticket to know better what's wrong.

All the best,
Alex


Post by dphilip »

Thank you for your response.

Can this ticket be taken up sooner? ( I hold a premium subscription now)


Post by mats »

We'll try to take a look later in the week or next. Thanks again for the report!


Post Reply