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

Wrong baselines dates should not cause crash #2422

Closed
jsakalos opened this issue Feb 19, 2021 · 0 comments
Closed

Wrong baselines dates should not cause crash #2422

jsakalos opened this issue Feb 19, 2021 · 0 comments
Assignees
Labels
bug Something isn't working forum Issues from forum low-priority resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@jsakalos
Copy link

Forum post

If a baseline endDate is before baseline startDate the app crashes.

Screen Shot 2021-02-19 at 13 24 10

To reproduce use the following app.js in place of examples/baselines/app.js. When startDate is swapped with endDate (in both baselines data), it works.

The application should not crash but we should handle the situation somehow, probably by console warning about the integrity of data. Or otherwise but not crash.

import '../_shared/shared.js'; // not required, our example styling etc.
import DateHelper from '../../lib/Core/helper/DateHelper.js';
import Gantt from '../../lib/Gantt/view/Gantt.js';
import ProjectModel from '../../lib/Gantt/model/ProjectModel.js';
import ResourceStore from '../../lib/Gantt/data/ResourceStore.js';
import TaskStore from '../../lib/Gantt/data/TaskStore.js';
import AssignmentStore from '../../lib/Gantt/data/AssignmentStore.js';
import DependencyStore from '../../lib/Gantt/data/DependencyStore.js';
import '../../lib/Grid/feature/Filter.js';
import '../../lib/Gantt/column/WBSColumn.js';
import '../../lib/Gantt/feature/Baselines.js';
import '../../lib/Gantt/feature/Rollups.js';
import '../../lib/Gantt/feature/Labels.js';
import '../../lib/Gantt/feature/ProjectLines.js';
import '../../lib/Gantt/feature/TaskEdit.js';

function setBaseline(index) {
    gantt.taskStore.setBaseline(index);
}

function toggleBaselineVisible(index, visible) {
    gantt.element.classList[visible ? 'remove' : 'add'](
        `b-hide-baseline-${index}`
    );
}

const taskStore = new TaskStore({
    data: [
        {
            id: '123123',
            isResource: true,
            name: 'AAA',
            children: [
                {
                    id: 3101,
                    name: 'Task 1',
                    endDate: '2021-02-18T06:27:18.900Z',
                    startDate: '2021-02-17T12:11:18.900Z',
                    resourceId: 12,
                    rollup: true,
                    manuallyScheduled: false,
                    dependencies: null,
                    baselines: [
                        {
                            startDate: '2021-02-18T10:58:33.505Z',
                            endDate: '2021-02-16T02:00:00.000Z'
                        }
                    ],
                    cls: 'task-status-2',
                    taskStatusName: 'Runned'
                },
                {
                    id: 3155,
                    name: 'Task 2',
                    endDate: '2021-02-19T08:42:18.900Z',
                    startDate: '2021-02-18T06:27:18.900Z',
                    resourceId: 12,
                    rollup: true,
                    manuallyScheduled: false,
                    baselines: [
                        {
                            startDate: '2021-02-18T10:58:33.505Z',
                            endDate: '2021-02-17T04:00:00.000Z'
                        }
                    ],
                    cls: 'task-status-5',
                    taskStatusName: 'To finish'
                }
            ],
            resourceId: 12
        }
    ]
});

const resourcesStore = new ResourceStore({
    data: [
        {
            id: 12,
            name: 'AAA'
        }
    ]
});

const assignmentStore = new AssignmentStore({
    data: [
        {
            eventId: 3101,
            resourceId: 12
        },
        {
            eventId: 3155,
            resourceId: 12
        }
    ]
});

const dependencyStore = new DependencyStore({
    data: [
        {
            toTask: 3155,
            fromTask: 3101,
            type: 2
        }
    ]
});
// Project contains all the data and is responsible for correct scheduling
const project = new ProjectModel({
    taskStore: taskStore,
    resourceStore: resourcesStore,
    assignmentStore: assignmentStore,
    dependencyStore: dependencyStore
    // projectStart: '2021-02-15'
});

const gantt = new Gantt({
    appendTo: 'container',

    dependencyIdField: 'wbsCode',

    project,

    columns: [{ type: 'wbs' }, { type: 'name' }],

    subGridConfigs: {
        locked: {
            flex: 1
        },
        normal: {
            flex: 2
        }
    },

    // Allow extra space for baseline(s)
    rowHeight: 60,

    features: {
        baselines: true,
        columnLines: false,
        filter: true,
        labels: {
            left: {
                field: 'name',
                editor: {
                    type: 'textfield'
                }
            }
        }
    },

    tbar: {
        items: [
            {
                type: 'checkbox',
                text: 'Show baselines',
                checked: true,
                toggleable: true,
                onAction({ checked }) {
                    gantt.features.baselines.disabled = !checked;
                }
            }
        ]
    }
});

@jsakalos jsakalos added bug Something isn't working forum Issues from forum labels Feb 19, 2021
@isglass isglass self-assigned this Sep 6, 2022
@isglass isglass added this to the 5.2.x milestone Sep 6, 2022
@isglass isglass added ready for review Issue is fixed, the pull request is being reviewed 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 Sep 6, 2022
@isglass isglass modified the milestones: 5.2.x, 5.2.0-alpha-1 Sep 6, 2022
@SergeyMaltsev SergeyMaltsev modified the milestones: 5.2.0-alpha-1, 5.2.0 Jun 30, 2023
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 low-priority resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

4 participants