# Upgrade guide for Scheduler Pro v5.0.0

## Delaying calculations for faster initial render

Scheduler Pro now by default renders events quicker than previously for the initial load. This is achieved by postponing
the initial calculations to after rendering, using the raw data as is for the events. Thus, it requires loading
pre-normalized data to render correctly. When given un-normalized data it will render what it can and transition to the
normalized result when calculations are finished.

If you run into issues with this new "early rendering" mode, you can turn it off at the project level using the
[delayCalculation](#SchedulerPro/model/ProjectModel#config-delayCalculation) config:

```javascript
new ProjectModel({
    // Do not postpone calculations to after rendering, calculate first and delay rendering instead
    delayCalculation : false
})
```

In applications that have code to manipulate event records directly after load, the calculations (and setting up
references etc) might not yet have finished when your code executes. If this causes issues in your app, try waiting for
them to finish before manipulating the events (or dependencies / resources / assignments):

```javascript
// Wait for delayed initial calculations to be performed
await project.commitAsync();

// Events are now normalized, references and buckets are set up, etc.
// Perform your custom logic now...
if (project.eventStore.first.resources.length > 1) {
    ...
}
```

## New scheduling issues handling popup

With this release Scheduler Pro starts displaying a special popup informing user of scheduling
conflicts, cycles and calendar misconfigurations found.

In order to prevent the popup from showing please set
[displaySchedulingIssueResolutionPopup](#SchedulerPro/view/SchedulerPro#config-displaySchedulingIssueResolutionPopup) to
`false`.

```javascript
new SchedulerPro({
    // disable default resolution popup
    displaySchedulingIssueResolutionPopup : false
});
```

## DependencyModel.active field has been made persistable

The change means that the field will be sent to the server with other dependency data when persisting.
It also means that the field will take part in undo/redo operations (since
[StateTrackingManager](#Core/data/stm/StateTrackingManager) tracks persistable fields only).

In order to revert to previous behavior please override the field and
set its [persist](#Core/data/field/DataField#config-persist) config to `false`:

```javascript
export class MyDependency extends DependencyModel {

    static get fields() {
        return [
            { name : 'active', persist : false }
        ];
    }

}
```

## Dependency "Active" field has been added to the dependency editor

New `Active` field has been added to the [dependency editor](#SchedulerPro/feature/DependencyEdit).
It allows to disable a dependency so it won't take part in the scheduling process.

To revert to old editor look and get rid of the field please use this code:

```javascript
new SchedulerPro({
    ...
    features : {
        dependencyEdit : {
            // configure dependency editor to hide "Active" field
            editorConfig : {
                items : {
                    activeField : false
                }
            }
        },
```

## Dependency editor "Lag" field has been made visible by default

`Lag` field has been made visible in the [dependency editor](#SchedulerPro/feature/DependencyEdit) by default.

To hide the field please use this code:

```javascript
new SchedulerPro({
    ...
    features : {
        dependencyEdit : {
            // hide "Lag" field
            editorConfig : {
                items : {
                    lagField : false
                }
            }
        },
```

## Task editor "Constraint type" field "keepTime" config has been changed to "entered"

This was done to not loose user provided time value. Previously it was `false` by default which
resulted in stripping of time info of the provided value.

To revert to the old behavior please use this code:

```javascript
new SchedulerPro({
    ...
    features : {
        taskEdit : {
            items : {
                advancedTab : {
                    items : {
                        // adjust constraint type so it would strip time info
                        constraintDateField : {
                            keepTime : false
                        }
                    }
                }
            }
        },
```

## The Engine ResourceAllocationInfo class changes

The Engine `ResourceAllocationInfo` class `allocation` property has been changed from an `Array` to
an `Object` with two properties `total` and `byAssignments`. The `total` property contains an array of the resource
allocation intervals. And the `byAssignments` is a `Map` keeping individual assignment allocation intervals with
assignments as keys and arrays of allocation intervals as values.

Basically the old `allocation` property content has been moved to the new `allocation.total` property
so you need to adjust your code accordingly.

Old code:
```javascript
allocationInfo.allocation
```

New code:
```javascript
allocationInfo.allocation.total
```

## Manually scheduled events do not skip non-working time anymore

Manually scheduled events have been changed to not skip non-working time for their proposed start/end date values.
This behavior is regulated by a new project
[skipNonWorkingTimeWhenSchedulingManually](#SchedulerPro/model/ProjectModel#field-skipNonWorkingTimeWhenSchedulingManually)
which is `false` by default.
In order to revert to the previous behaviour when non-working time was skipped please set the config to `true`:

```javascript
new SchedulerPro({
    project : {
        skipNonWorkingTimeWhenSchedulingManually : true,
        ...
    }
});
```

## DurationColumn moved to Scheduler

DurationColumn was moved to the Scheduler package. If you used translations for this class,
make sure to review your localization files. If you import from sources, you will have to update the path.

## ResourceHistogram tooltip change

The histogram `getBarTip` config has been deprecated in favor of new
[barTooltipTemplate](#SchedulerPro/view/ResourceHistogram#config-barTooltipTemplate) config.

There are several differences between the two functions interfaces.
The new [barTooltipTemplate](#SchedulerPro/view/ResourceHistogram#config-barTooltipTemplate) function
accepts a single `Object` type argument whose properties provide the tooltip related info:

- `tip` - The tooltip instance
- `activeTarget` - The target bar-element that triggered the show
- `datum` - The hovered histogram bar info (third argument of deprecated `getBarTip` function)
- `datum.rectConfig` - The rectangle DOM configuration object (second argument of deprecated `getBarTip` function)

And the first argument (`series`) of deprecated `getBarTip` function is not supported by new `barTooltipTemplate`.
Since it was decided it's not used.

Please change your code accordingly.

**Old code:**
```javascript
new ResourceHistogram({
    getBarTip : (series, rectConfig, datum, index) => {
        return `<div class="my-tooltip">${datum.effort}</div>`;
    }
})
```

**New code:**
```javascript
new ResourceHistogram({
    barTooltipTemplate : ({ datum, index }) => {
        return `<div class="my-tooltip">${datum.effort}</div>`;
    }
})
```

## React wrappers now use module bundle

The React wrappers previously used the UMD bundle to import required classes:

**Old code:**
```javascript
import { EventModel } from '@bryntum/schedulerpro/schedulerpro.umd.js';
```

UMD bundle is not used anymore in the wrappers so the import line in the above code needs to be changed:

**New code:**
```javascript
import { EventModel } from '@bryntum/schedulerpro';
```

Imports from `@bryntum/schedulerpro-react` remain same.


<p class="last-modified">Last modified on 2023-10-26 8:19:27</p>