Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar intervals not applied properly in case of using specific rules #8754

Closed
chuckn0rris opened this issue Mar 6, 2024 · 7 comments
Closed
Assignees
Labels
bug Something isn't working forum Issues from forum high-priority Urgent to have fixed large-account Reported by large customer OEM OEM customer resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@chuckn0rris
Copy link

chuckn0rris commented Mar 6, 2024

Forum post

import { Toolbar, Toast, DateHelper, CSSHelper, Column, ColumnStore, Combo, TaskModel, Gantt,StringHelper } from '../../build/gantt.module.js?474872';
import shared from '../_shared/shared.module.js?474872';


const gantt = new Gantt({
    appendTo          : 'container',
    dependencyIdField : 'sequenceNumber',
    rowHeight         : 45,
    tickSize          : 45,
    barMargin         : 8,

    columns : [
        { type : 'name', width : 250 },
        { type : 'startdate', width : 100 },
        { type : 'enddate', width : 100 },
        { type : 'duration', width : 80 },
        { type : 'effort', width : 80 }
    ],

    // Custom task content, display task name on child tasks
    taskRenderer({ taskRecord }) {
        if (taskRecord.isLeaf && !taskRecord.isMilestone) {
            return StringHelper.encodeHtml(taskRecord.name);
        }
    }
});

const project = gantt.project.inlineData;

project.eventsData = [
    {
        id        : 1,
        name      : 'Task 1',
        startDate : '2021-01-01T08:00:00',
        endDate   : '2021-01-04T16:00:00',
        duration  : 5
    },
    {
        id        : 2,
        name      : 'Task 2',
        startDate : '2021-01-01T08:00:00',
        endDate   : '2021-01-04T16:00:00',
        duration  : 5
    }
];

project.calendarsData = [
    {
        id        : 123456,
        name      : 'My Calendar',
        intervals : [
            {
                recurrentStartDate : 'at 08:00',
                recurrentEndDate   : 'at 16:00',
                isWorking          : true
            },
            {
                recurrentStartDate : 'on Sat at 00:00',
                recurrentEndDate   : 'on Mon at 00:00',
                isWorking          : false
            }
        ],
        unspecifiedTimeIsWorking : false
    }
];

gantt.project.inlineData = project;

gantt.project.hoursPerDay = 8;
gantt.project.calendar = 123456;

See non working intervals applied to only few weekends.
Screenshot 2024-03-06 at 13 56 56

@chuckn0rris chuckn0rris added bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer labels Mar 6, 2024
@isglass isglass added the high-priority Urgent to have fixed label Mar 6, 2024
@canonic-epicure canonic-epicure self-assigned this Mar 7, 2024
@canonic-epicure
Copy link

canonic-epicure commented Mar 7, 2024

Seems to be fine for me, perhaps fixed in the latest release?
image

@canonic-epicure
Copy link

Ah, reproducible with the code from the 1st post, I'll update the snippet in the ticket.

@canonic-epicure
Copy link

So it seems to be dependent on the order of the intervals, works fine if weekend is defined first:

            {
                recurrentStartDate : 'on Sat at 00:00',
                recurrentEndDate   : 'on Mon at 00:00',
                isWorking          : false
            },
            {
                recurrentStartDate : 'at 08:00',
                recurrentEndDate   : 'at 16:00',
                isWorking          : true
            },

I'll be checking why this matters.

@canonic-epicure
Copy link

So the issue is caused by the fact, that the recurrent intervals intersect:

        intervals : [
            {
                recurrentStartDate : 'at 08:00',
                recurrentEndDate   : 'at 16:00',
                isWorking          : true
            },
            {
                recurrentStartDate : 'on Sat at 00:00',
                recurrentEndDate   : 'on Mon at 00:00',
                isWorking          : false
            }
        ]

Here the timespan 08:00-16:00 is defined both in the 1st recurrent interval and the 2nd, and also the isWorking flag is different in them. Currently, in such cases, it is undefined behavior, which interval will be picked. To define which interval "wins" one can use the priority field (currently undocumented, interval with higher priority "wins"):

        intervals : [
            {
                recurrentStartDate : 'at 08:00',
                recurrentEndDate   : 'at 16:00',
                priority : 1, 
                isWorking          : true
            },
            {
                recurrentStartDate : 'on Sat at 00:00',
                recurrentEndDate   : 'on Mon at 00:00',
                priority : 2, 
                isWorking          : false
            }
        ]

Or, (recommended), define the intervals so that they don't intersect - for example limit the 08-16 rule by weekdays only:

   intervals : [
         {
                recurrentStartDate : 'on Mon, Tue, Wed, Thu, Fri at 08:00',
                recurrentEndDate   : 'on Mon, Tue, Wed, Thu, Fri at 16:00',
                isWorking          : true
            },
            {
                recurrentStartDate : 'on Sat at 00:00',
                recurrentEndDate   : 'on Mon at 00:00',
                isWorking          : false
            }
        ],

@canonic-epicure
Copy link

I guess the resolution for this ticket will be updating the docs about the behavior of intersecting recurrent intervals and documenting the priority field on them.

@canonic-epicure
Copy link

Or, we can prioritize the interval with the bigger index in the store.

@canonic-epicure
Copy link

After conversation with Arcady we decided to do both.

@canonic-epicure canonic-epicure added ready for review Issue is fixed, the pull request is being reviewed and removed in progress labels Mar 11, 2024
@isglass isglass added resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed labels Mar 11, 2024
@isglass isglass added this to the 5.6.9 milestone Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum high-priority Urgent to have fixed large-account Reported by large customer OEM OEM customer resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

3 participants