Regarding Enabling the editable_resource_diagram Attribute

Hello!

When modifying the allocation values of tasks in the resource diagram, the current data saving logic (splitting of allocation data) results in allocation data that is not easy for the backend to perform statistical analysis on. So, I was wondering if there is a way to override the save logic?

Here are examples of the data issues generated when modifying allocation data:
When I have the initial allocation data for a task:

{
    "id": "ass01",
    "start_date": "2024-06-24",
    "end_date": "2024-06-29",
    "duration": 5,
    "delay": 0,
    "value": 8,
    "resource_id": "6",
    "mode": "default"
}

Modification Method 1: First modify the allocation value of the last day of the task (2024-06-28) from 8 to 5 in the resource diagram. This will generate the following allocation data:

{
    "id": "ass01",
    "start_date": "2024-06-24",
    "end_date": "2024-06-28",
    "duration": 4,
    "delay": 0,
    "value": 8,
    "resource_id": "6",
    "mode": "fixedDuration"
}
{
    "id": "ass02",
    "start_date": "2024-06-28",
    "end_date": "2024-06-29",
    "duration": 1,
    "delay": 4,
    "value": 5,
    "resource_id": "6",
    "mode": "fixedDuration"
}

Modification Method 2: First modify the allocation values of the task on any day except the last day (except 2024-06-28) in the resource diagram. For example, change the value on 2024-06-27 from 8 to 5. This will generate the following allocation data:

{
    "id": "ass01",
    "start_date": "2024-06-24",
    "end_date": "2024-06-27",
    "duration": 3,
    "delay": 0,
    "value": 8,
    "resource_id": "6",
    "mode": "fixedDuration"
}
{
    "id": "ass02",
    "start_date": "2024-06-27",
    "end_date": "2024-06-28",
    "duration": 1,
    "delay": 3,
    "value": 8,
    "resource_id": "6",
    "mode": "fixedDuration"
}
{
    "id": "ass03",
    "start_date": "2024-06-28",
    "end_date": "2024-06-29",
    "duration": 1,
    "delay": 4,
    "value": 8,
    "resource_id": "6",
    "mode": "default"
}

There is no problem with the data generated by these two modification methods for now. However, note that in Method 1, the last allocation data has the mode “fixedDuration,” while in Method 2, the last allocation data has the mode “default.”

Next, perform modification operations on the two methods separately, such as reducing the task duration by 3 days (leaving only 2 days of task duration) by modifying the task duration in the grid or by dragging the task bar.

In Modification Method 1, there is no change in the task allocation data (no allocation data update request is sent to the backend).
In Modification Method 2, only the duration of the allocation data with id=ass03 is reduced by 3 days (an update request for the data with id=ass03 is sent to the backend), generating the following data:

{
    "id": "ass01",
    "start_date": "2024-06-24",
    "end_date": "2024-06-27",
    "duration": 3,
    "delay": 0,
    "value": 8,
    "resource_id": "6",
    "mode": "fixedDuration"
}
{
    "id": "ass02",
    "start_date": "2024-06-27",
    "end_date": "2024-06-28",
    "duration": 1,
    "delay": 3,
    "value": 8,
    "resource_id": "6",
    "mode": "fixedDuration"
}
{
    "id": "ass03",
    "start_date": "2024-06-28",
    "end_date": "2024-06-29",
    "duration": -2,
    "delay": 4,
    "value": 8,
    "resource_id": "6",
    "mode": "default"
}

The generated data can be parsed and displayed normally in the Gantt chart and resource diagram. However, such data makes it complex for the backend to analyze a specific resource for a task.

How can we modify the task duration to generate fewer allocation data, for example:

{
    "id": "ass01",
    "start_date": "2024-06-24",
    "end_date": "2024-06-26",
    "duration": 2,
    "delay": 0,
    "value": 8,
    "resource_id": "6",
    "mode": "default"
}

Hello,
In the default mode, the resource assignments stretch according to the task dates/duration.
With the keepDuration mode, the assignment duration doesn’t change, but the dates follow the task dates.
After you drag a task, the assignments with the default mode always start from the start_date of the task. You can add a delay, then the assignment will start on a different date. But the assignment before that date won’t change its duration. So, it means that several assignments will be applied to the same dates:


That’s why we need the fixedDuration mode.

When you resize tasks, the existing assignments are not removed. That’s why the assignments with the fixedDuration mode remain after you shrink a task.

You need to implement a custom solution for that.
The easiest way to do that is to use the onAfterTaskUpdate event handler.
There, you can remove the assignments that start after the task ends. And you can get the assignment with the latest dates and stretch it if it ends earlier than the task.
Here is an example of how it can be implemented:
https://snippet.dhtmlx.com/4z2e634z