In our main application, it's possible to schedule a resource on a task and on a specific date. E.g. a task exists with start date Nov 1 and end date Nov 3, a resource can be scheduled to work on it just on Nov 1. And another resource on Nov 2 and so on. In Gantt, is it only possible to schedule a resource to the complete duration of the task? How could I implement something like this?
Yes the Gantt doesn't support that out of the box.
That will require customization of the some methods implemented in the scheduling engine.
Long store short:
1) You'll need to add startDate field to the assignment model. In typescript that might look like this:
export class MyAssignmentMixin extends Mixin(
[ GanttAssignmentMixin ],
(base : AnyConstructor<GanttAssignmentMixin, typeof GanttAssignmentMixin>) => {
class MyAssignmentMixin extends base {
@model_field({ type : 'date' })
startDate : Date
}
return MyAssignmentMixin
}){}
2) You'll need to override existing engine methods to take that new field into account. Check lib/Engine/quark/model/scheduler_pro/SchedulerProHasAssignmentsMixin.ts code. There is a forEachAvailabilityInterval method which is responsible for iteration over working periods of time. You need it to take into account that startDate field. In order to override code you can make a new class (similar to MyAssignmentMixin above). So then you'll simply use those mixin classes to build your custom task and assignment models.
That's a bit tricky, but doable for sure!
Or as an option you could use our professional services (please contact sales at bryntum.com for a quote)
I'm trying to implement point 1. I believe I need to import GantAssignmentMixin if I'm creating a simple subclass:
class SpsAssignmentMixin extends GanttAssignmentMixin {
static get fields() {
return [
{ name: 'startDate', type: 'date' }
];
}
};
But when I add that import
import { GanttAssignmentMixin } from '../../bryntumgantt/gantt-4.0.2/lib/Engine/quark/model/gantt/GanttAssignmentMixin.js';
I'm getting an error:
Uncaught Error: Bundle included twice, check cache-busters and file types (.js)
at Function.setVersion (VM957 VersionHelper.js:67)
at VM953 Base.js:1498
Your application probably already uses a bundle ..so you should import class from the bundle file then.
But I've just realised that those Scheduling Engine classes are not exported from the Gantt bundle. So importing them from the bundle is impossible in the current version.
I've made a ticket for that: https://github.com/bryntum/support/issues/1847
So far you can instead subclass AssignmentModel class provided by the Gantt bundle
And SchedulerProHasAssignmentsMixin mixin I mentioned ends up in TaskModel so you will need to override that model methods respectively.
I've added a startDate to my own assignmentmodel, and put an override of function forEachAvailabilityInterval in my own taskmodel and that fires, but I don't see how to look at the startDate of the assignment record. Do I need to look at the assignments in assignmentsByCalendar, each by each, and check if the assignment.startDate matches the startDate in the function?
Do I need to look at the assignments in assignmentsByCalendar, each by each, and check if the assignment.startDate matches the startDate in the function?
Yes I think so. At the moment there is workCalendars.some(...) call simply checking if some assignment calendar treats the interval as working. So you will need to change that.