The following features provide additional functionality for Workshop's Dynamic Scheduling capability.
The Scheduling Gantt Chart widget is backed by Scenarios, enabling the creation and comparison of what-if analyses. Changes made in the widget are therefore not directly written to the Ontology; instead, they are, effectively, "staged" or "simulated" changes. A schedule save action is needed to write the changes to the Ontology.
To write proposed changes to the Ontology, a simple modify action (which can be configured via the OMA Wizard) is usually sufficient. If further edits are required after updating the Ontology, you can use a custom save action, backed by a Function.
Sample code snippets for types and example functions are provided below.
The types below represent the serialized details of a schedule change, which includes information about both the old and new state of the given allocation.
/* Changelog types */
type ChangelogEntryType = "allocation";
interface IChangelogEntryBase {
type: ChangelogEntryType;
id: string;
touchCounter: number;
parentEntryId?: string;
}
interface IAllocationChangelogEntry extends IChangelogEntryBase {
type: "allocation";
puckId: string;
allocatedTo: string | undefined;
allocatedFrom: string | undefined;
newStartTime: number | undefined;
newEndTime: number | undefined;
previousStartTime: number | undefined;
previousEndTime: number | undefined;
id: string;
touchCounter: number;
parentEntryId?: string;
}
export interface IEnhancedChangelog extends IAllocationChangelogEntry {
fixedResourceObjectTypeId: string;
puckId: string;
}
export interface ISubmitAllocationPayload {
changelog: IEnhancedChangelog[];
comment?: string;
}
Copied!1import { IEnhancedChangelog, ISubmitAllocationPayload } from "./types"; 2 3export class MyFunctions { 4 5 6 @Edits(scheduleObjectAPI) 7 @OntologyEditFunction() 8 public functionName(submissionPayload: string): void { 9 const payload: ISubmitAllocationPayload = JSON.parse(submissionPayload) as ISubmitAllocationPayload; 10 const entries: IEnhancedChangelog[] = payload.changelog; 11 const allocations = Objects.search().objectAPI().all(); 12 entries.forEach(entry => { 13 const maybeAllocation = allocations.find(alloc => alloc.assignmentId === entry.puckId); 14 if (maybeAllocation == null) { 15 return; 16 } 17 maybeAllocation.endTimestamp = entry.newEndTime !== undefined ? Timestamp.fromJsDate(new Date(entry.newEndTime)) : undefined; 18 maybeAllocation.startTimestamp = entry.newStartTime !== undefined ? Timestamp.fromJsDate(new Date(entry.newStartTime)) : undefined; 19 if (entry.fixedResourceObjectTypeId === objectId) { 20 maybeAllocation.fixedResourceKey = entry.allocatedTo 21 } else { 22 maybeAllocation.schedulableKey = entry.allocatedTo 23 } 24 }); 25 }
Allocation behavior refers to how pucks behave after they have been moved in the drag-and-drop interface. The Scheduling Gantt Chart widget comes with five predefined options intended to cover the majority of use cases. You can also define your own custom allocation behavior using a TypeScript function, as shown in the example below.
/* Changelog types */
/* Note: these are types also used for Custom Save Actions and may already be in
your functions repo. */
type ChangelogEntryType = "allocation";
interface IChangelogEntryBase {
type: ChangelogEntryType;
id: string;
touchCounter: number;
parentEntryId?: string;
}
interface IAllocationChangelogEntry extends IChangelogEntryBase {
type: "allocation";
puckId: string;
allocatedTo: string | undefined;
allocatedFrom: string | undefined;
newStartTime: number | undefined;
newEndTime: number | undefined;
previousStartTime: number | undefined;
previousEndTime: number | undefined;
id: string;
touchCounter: number;
parentEntryId?: string;
}