DevExpress / devextreme-reactive

Business React components for Bootstrap and Material-UI
https://devexpress.github.io/devextreme-reactive/
Other
2.07k stars 376 forks source link

Drag recurring appointment #3594

Closed micha-heigl closed 1 year ago

micha-heigl commented 1 year ago

Is there an existing issue for this?

I'm using ...

React Scheduler

Current Behaviour

I am moving the second occurance of a recurring appointment to a different time by drag n drop. I answer the "Edit recurring appointment" question with "all appointments" to shift them all in time. image

Now they all get shifted in date too: image

Although I understand this behaviour, it is not intuitive. If I move the first occurence, everythign works as expected. But if I move the second occurence I dont' t expect the first occurance to shift to this date. Especially with recurring appointments with larger gaps and a wide date range it might be complicated to find the first occurence to move the appointments to a different time.

Expected Behaviour

I would expect the appointments to shift in time, but not in date. image image

Steps to Reproduce

Go to this example Drag an appontment on tuesday to a different time.

Environment

Krijovnick commented 1 year ago

Hi, @micha-nerdlichter

It is not a bug. When a user changes appointments, the EditingState plugin fires the onCommitChanges event that changes the editing state. You need to modify the commitChanges method in the example to achieve the behavior you require.

micha-heigl commented 1 year ago

Hi @Krijovnick, thank you for your response. I don't think I can do this in the commitChanges method, as I need the dragged appointment in order to calculate the correct date. In the function I only have the first occurance and the new (miscalculated) date.

I still think this is a bug. Please note that with "this and following appointments" everything works as I would expect. But if I select "all appointments" I don't suspect the head to move to the new time, but the exact appointment I dragged.

If anyone has the same problem: I fixed this by adding the following code to packages/dx-scheduler-core/src/plugins/editing-state/helpers.ts in line 156:

if (parentData && !moment.utc(appointmentData.startDate).isSame(moment.utc(parentData.startDate))) {
    const dateDiff = moment.utc(changes.startDate).diff(moment.utc(appointmentData.startDate));
    const optimizedStartDate = moment(parentData.startDate).add(dateDiff, 'ms');
    const optimizedEndDate = moment(parentData.endDate).add(dateDiff, 'ms');

    return  {
      changed: {
        [appointmentData.id!]: {
          ...changes,
          startDate: optimizedStartDate.toDate(),
          endDate: optimizedEndDate.toDate(),
        }
      }
    };
  }

I don't think a PR makes any sense if this is not considered a bug.

github-actions[bot] commented 1 year ago

Thank you for using Devextreme Reactive. We use GitHub issues to track bug and feature requests. We process incoming issues as soon as possible. Issues that have been inactive for 30 days are closed. If you have an active DevExtreme license, you can contact us in our Support Center for updates. Otherwise, post your question on StackOverflow.