Our pure JavaScript Scheduler component


Post by anthony.dasre »

Hello,
I am using Scheduler(v4.3.6 ). I'm trying to implement the functionality of moving the events. The objective of this functionality is to move an event from one resource to another resource under the condition that the target time range is not occupied by another event.
One important point is to check whether the target time range is used by other events in the same "resource". To do that, I have to predict the endDate of the moving event before it's actually dropped. The problem that I'm facing is that I don't know how to get the "endDate" of the event with the "startDate", "duration" and the working time. I found "context['endDate']" in the function

 "beforeEventDropFinalize({context, source})",

however, it doesn't consider the not working time in the scheduler.

Could someone please tell me how to calculate the "endDate" with "startDate", "duration", and the calendar in the function "beforeEventDropFinalize" and "beforeEventSave" of scheduler? Is there a function in the plugin that allows doing this?
And is there a function to check whether the time range is used by the other events?

For more context, here's an example, in the attachment, there are two events(event 1 et event2), two resources( "PRESSE S1,"PRESSE S2" ), calendar(every weekday from 7:00 to 18:00).
I want to drag the event 1 from ressource "PRESSE S1" to ressource "PRESSE S2". In the background of my application, resource "PRESSE S1" can take different events in the same time range. But for the resource "PRESSE S2" doesn't allow different events in the same time range, which means a time range is exclusively allocated to one event. If I want to drop the event to resource "PRESSE S2", it needs to check whether the new time range to place "event 1" isn't used by the others events in the function " beforeEventDropFinalize".

Thank you in advance.

Attachments
Q2.png
Q2.png (16.06 KiB) Viewed 296 times

Post by alex.l »

context object should have all data you need. Check context.endDate ?

All the best,
Alex


Post by anthony.dasre »

In the attachment, the calendar

{
  "id": "1",
  "name": "PLANNING",
  "unspecifiedTimeIsWorking": false,
  "intervals": [
    {
      "recurrentStartDate": "every weekday at 7:00",
      "recurrentEndDate": "every weekday at 18:00",
      "isWorking": true
    }
  ]
}

I have moved the event from the "2022-1-24 7:00 - 2022-1-26 9:00" to another time range . However, the startDate and endDate in the context is the date which doesn't consider the working time(7:00 - 18:00). It shows that the new time range is from "2022-1-24 23:00" to "2022-1-27 01:00". In fact, the time range after dropping the event is from "2022-1-25 07:00" to "2022-1-27 09:00".

Attachments
q2_reply.png
q2_reply.png (93.42 KiB) Viewed 283 times

Post by Animal »

The Scheduler's TimeAxis is used (which knows about the ViewPreset and units and increments) to round the date.

https://www.bryntum.com/docs/scheduler/api/Scheduler/data/TimeAxis#function-roundDate


Post by anthony.dasre »

Sorry. Can you give me an example of it? I don't understand how to use it for rounding the date in the function

thebeforeEventDropFinalize({context, source}) 
//and
beforeEventSave({eventRecord,resourceRecord,context,values})

. Thank you in advance.


Post by alex.l »

    listeners : {
        beforeEventDropFinalize({ context, source }) {
            const roundedDate = source.timeAxis.roundDate(context.startDate);
        }
    },

All the best,
Alex


Post Reply