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
52 stars 6 forks source link

[Ext Gantt] Incorrect late dates when negative lag is used #9382

Open arcady-zherdev opened 3 weeks ago

arcady-zherdev commented 3 weeks ago

Reported here: https://forum.bryntum.com/viewtopic.php?t=29361

Incorrect late dates calculated for task 17 in the following dataset. The reason is a negative lag applied for its successor.

{
    "success"      : true,
    "dependencies" : {
        "rows" : [
            {
                "From" : 11,
                "To"   : 12
            },
            {
                "From" : 12,
                "To"   : 17
            },
            {
                "From" : 17,
                "To"   : 34,
                "Lag" : -2
            }
        ]
    },
    "tasks"        : {
        "metaData" : {
            "projectStartDate" : "2017-01-16"
        },
        "rows"     : [
            {
                "Id"                : 11,
                "leaf"              : true,
                "Name"              : "Investigate",
                "PercentDone"       : 50,
                "StartDate"         : "2017-01-16",
                "Duration"          : 4
            },
            {
                "Id"                : 12,
                "leaf"              : true,
                "Name"              : "Assign resources",
                "PercentDone"       : 50,
                "StartDate"         : "2017-01-20",
                "Duration"          : 3
            },
            {
                "Id"                : 17,
                "leaf"              : true,
                "Name"              : "Report to management",
                "PercentDone"       : 0,
                "StartDate"         : "2017-01-25",
                "Duration"          : 0
            },
            {
                "Id"                : 34,
                "leaf"              : true,
                "Name"              : "Report to Bla Bla",
                "PercentDone"       : 0,
                "StartDate"         : "2017-01-23",
                "Duration"          : 1
            }
        ]
    }
}
arcady-zherdev commented 3 weeks ago

A workaround to fix the issue is:

Ext.define('MyApp.Task', {
    extend  : 'Gnt.model.Task',

    requires : ['Ext.Array'],

    processLateStartDateValue : function (value, context) {
        var project         = this.getProject(),
            options         = context.options,
            store           = options.taskStore || this.getTaskStore(true),
            projectEndDate  = project ? project.getEndDate() : store.getProjectEndDate(),
            // ..subtract duration
            projectEndDateMinusDuration = this.endDateToStartDate(projectEndDate);

        if (value > projectEndDateMinusDuration) {
            value = projectEndDateMinusDuration;
        }

        return this.callParent([value, context]);
    },

    processLateEndDateValue : function (value, context) {
        var project         = this.getProject(),
            options         = context.options,
            store           = options.taskStore || this.getTaskStore(true),
            projectEndDate  = project ? project.getEndDate() : store.getProjectEndDate();

        if (value > projectEndDate) {
            value = projectEndDate;
        }

        return this.callParent([value, context]);
    }
});