v7.3.0
SupportExamplesFree Trial

Versions
Feature

Captures versions (snapshots) of the active project, including a detailed log of the changes new in each version.

When active, the feature monitors the project for changes and appends them to the changelog. When a version is captured, the version will consist of a complete snapshot of the project data at the time of the capture, in addition to the list of changes in the changelog that have occurred since the last version was captured.

For information about the data structure representing a version and how to persist it, see VersionModel.

For information about the data structures representing the changelog and how to persist them, see ChangeLogTransactionModel.

const scheduler = new SchedulerPro({
    features : {
        versions : true
    }
});

To display versions and their changes, use a VersionGrid configured with a ProjectModel.

const scheduler = new SchedulerPro({ enableUndoRedoKeys : true, flex : 2, project : { resources : [ { id : 1, name : 'Resource 1' }, { id : 2, name : 'Resource 2' }, { id : 3, name : 'Resource 3' } ], autoHeight : true, events : [ { id : 11, name : 'Design website', startDate : new Date(2022, 10, 7), duration : 5, resourceId : 1 }, { id : 12, name : 'Lease office space', startDate : new Date(2022, 10, 9), duration : 4, resourceId : 1 }, { id : 13, name : 'Buy coffee machine', startDate : new Date(2022, 10, 13), duration : 3, resourceId : 3 }, { id : 14, name : 'Hire designer', startDate : new Date(2022, 10, 17), duration : 3, resourceId : 2 }, { id : 15, name : 'Write design handbook', startDate : new Date(2022, 10, 27), duration : 3, resourceId : 2 } ], // dependencies : [ // { // id : 1, // fromTask : 11, // toTask : 12 // }, // { // id : 2, // fromTask : 13, // toTask : 14 // }, // { // id : 3, // fromTask : 14, // toTask : 15 // } // ], stm : { autoRecord : true } }, columns : [ { field : 'name', text : 'Name', width : 250 }, { field : 'startDate', text : 'Start date' }, { field : 'duration', text : 'Duration' } ], subGridConfigs : { locked : { width : 300 } }, features : { versions : true, dependencies : true, dependencyEdit : true }, listeners : { /** * Demonstrates overriding the default transaction description to provide more detail * about which user action initiated the transaction. In this case, we set a custom * description for transactions involving a task drag event. */ taskDrop({ taskRecords }) { this.features.versions.transactionDescription = taskRecords.length === 1 ? `Dragged task ${taskRecords[0].name}` : `Dragged ${taskRecords.length} tasks`; }, taskResizeEnd({ taskRecord }) { this.features.versions.transactionDescription = `Resized task ${taskRecord.name}`; }, afterDependencyCreateDrop() { this.features.versions.transactionDescription = `Drew a link`; } } }); const app = new Container({ appendTo : targetElement, layout : 'box', height : 600, items : { scheduler, splitter : { type : 'splitter' }, versionGrid : { type : 'versiongrid', flex : 1, emptyText : 'No versions to display', project : scheduler.project, showUnattachedTransactions : true, selectionMode : { row : true, cell : false }, features : { cellMenu : { /** * Add a button to the version row context menu. */ items : { compareButton : undefined, duplicateButton : { text : 'Duplicate', icon : 'fa fa-copy', onItem : async({ record, source : grid }) => { const result = await MessageDialog.confirm({ title : 'Duplicate Version?', message : `This will create a new project from the content of the selected version. Do you want to continue?` }); if (result === MessageDialog.yesButton) { // Sample code demonstrating cloning a saved version await scheduler.features.versions.getVersionContent(record.versionModel); const clonedProject = new ProjectModel(record.versionModel.content); scheduler.project = clonedProject; } } } } } }, dateFormat : 'M/D/YY h:mm a', tbar : { items : { saveButton : { text : 'Save Version', icon : 'fa fa-plus', listeners : { click : () => { scheduler.features.versions.saveVersion(); } } }, spacer : { text : '->' }, onlyNamedToggle : { type : 'slidetoggle', text : 'Show named versions only', listeners : { change : ({ checked }) => { app.widgetMap.versionGrid.showNamedVersionsOnly = checked; } } }, showVersionsToggle : { type : 'slidetoggle', text : 'Changes only', checked : false, listeners : { change : ({ checked }) => { app.widgetMap.versionGrid.showVersions = !checked; } } } } }, listeners : { // Handle the user asking to restore a given version restore : async({ version }) => { const result = await MessageDialog.confirm({ title : 'Restore Version?', message : `Are you sure you want to restore the selected version, replacing the current project? You will lose any unsaved changes.` }); if (result === MessageDialog.yesButton) { await gantt.features.versions.restoreVersion(version); gantt.features.baselines.disabled = true; // FIXME known issue with Undo after restoring version project.stm.resetQueue(); } } } } } }); scheduler.project.stm.enable();

This feature is disabled by default. For info on enabling it, see GridFeatures.

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • autoSaveInterval : 'hourly'/Numberhourly

    The interval between autosaves, in minutes. To disable autosave, set the interval to zero. To save on the hour, use 'hourly'.

  • knownBaseTypes : Array[AssignmentModel, DependencyModel, ResourceModel, CalendarModel]

    The set of Model types whose subtypes should be recorded as the base type in the change log. For example, by default if a subclassed TaskModelEx exists and an instance of one is updated, it will be recorded in the changelog as a TaskModel.

  • Optional subclass of ChangeLogTransactionModel to use instead of ChangeLogTransactionModel. Use this to extend ChangeLogTransactionModel to add any additional fields your application needs.

  • Optional subclass of VersionModel to use instead of VersionModel. Use this to extend VersionModel to add any additional fields your application needs.

  • Internal listeners, that cannot be removed by the user.

  • The widget which this plugin is to attach to.

    Has a corresponding runtime client property.

  • Set to false to disable localization of this object.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isLocalizable : Booleantrue
    READONLY
    static
    ADVANCED
    Localizable
    Identifies an object as an instance of Localizable class, or subclass thereof.
  • isVersions : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of Versions class, or subclass thereof.
  • properties : Object
    internal
    static
    InstancePlugin

    A class property getter for the default values of internal properties for this class.

  • hasChanges : Boolean
    READONLY

    Whether a pending transaction is open with changes not yet added to the changelog.

  • isComparing : Boolean
    READONLY

    Whether a saved version is currently being compared.

  • Sets the description of the current transaction. This will override the default transaction description.

  • emptyArray : Array
    internal
    READONLY
    InstancePlugin

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    InstancePlugin

    An empty object that can be used as a default value.

  • isInstancePlugin : Booleantrue
    READONLY
    ADVANCED
    InstancePlugin
    Identifies an object as an instance of InstancePlugin class, or subclass thereof.
  • isVersions : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of Versions class, or subclass thereof.
  • config : Object
    READONLY
    ADVANCED
    InstancePlugin

    Returns a copy of the full configuration which was used to configure this object.

  • This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    InstancePlugin

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • client : Widget
    READONLY
    ADVANCED
    InstancePlugin

    The Widget which was passed into the constructor, which is the Widget we are providing extra services for.

    Has a corresponding client config.

  • Get the global LocaleHelper

  • Get the global LocaleManager

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    InstancePlugin

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    InstancePlugin

    Registers this class type with its Factory

  • When autosave is 'hourly', we check the time every 30 seconds and autosave on the hour.

  • Process the end of a remote-changes subset of a current transaction, adding to the tracked set of ranges.

  • excludeRanges( )
    private
  • Package the tracked set of project changes into an ChangeLogTransaction.

  • Track ranges of remote actions inside a single transaction, to exclude them from changelog recording later in finalizeTransaction.

  • onProjectLoad( )
    private

    This listener is used to exclude changes that occur during a project's initial load and scheduling.

  • Stops comparing a currently compared version.

  • stopTransaction( )
    private

    Force-stop a transaction immediately.

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

  • This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

Event handlers

Event handlers are callbacks called as a result of certain actions in this class
id: versions

Source path

SchedulerPro/feature/Versions.js

Contents