v7.3.0

DependencyMenu
Feature

Displays a context menu when right-clicking dependency lines. Items are populated by other features and/or application code.

Default dependency menu items

Here is the list of menu items provided by the feature and populated by the other features:

Reference Text Weight Feature Description
edit Edit 100 DependencyEdit Edit in the dependency editor. Hidden when read-only
delete Delete 500 This feature Remove dependency. Hidden when read-only

Customizing the menu items

The menu items in the dependency menu can be customized, existing items can be changed or removed, and new items can be added. This is handled using the items config of the feature.

Add extra items for all dependencies:

const scheduler = new Scheduler({
    features : {
        dependencyMenu : {
            items : {
                extraItem : {
                    text : 'Extra',
                    icon : 'fa fa-fw fa-flag',
                    onItem({ dependencyRecord }) {
                        dependencyRecord.critical = true;
                    }
                }
            }
        }
    }
});

Remove existing items:

const scheduler = new Scheduler({
    features : {
        dependencyMenu : {
            items : {
                delete : false
            }
        }
    }
});

Customize existing item:

const scheduler = new Scheduler({
    features : {
        dependencyMenu : {
            items : {
                delete : {
                    text : 'Delete link'
                }
            },
            // Process items before menu is shown
            processItems({ dependencyRecord, items}) {
                 // Push an extra item
                 if (dependencyRecord.isCritical === 'conference') {
                     items.markAsCriticalItem = {
                         text : 'Mark as critical',
                         onItem({ dependencyRecord }) {
                             // Do cool things
                         }
                     };
                 }

// Do not show menu for secret links if (dependencyRecord.isSecret === 'secret') { return false; } } } } });

The processItems implementation may be an async function which awaits a result to mutate the items object.

Note that the menuContext is applied to the Menu's item event, so your onItem handler's single event parameter also contains the following properties:

  • source The Scheduler whose UI was right-clicked.
  • targetElement The element right-clicked on.
  • dependencyRecord The dependency record clicked on.

This feature is enabled by default from version 7.0.

Useful configs and functions

Member Description
items Menu items configuration object
dependencyMenuBeforeShow Fires before menu is shown
dependencyMenuItem Fires when a menu item is clicked
dependencyMenuShow Fires after menu is shown

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class

Properties

Properties are getters/setters or publicly accessible variables on this class

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

Type definitions

id: dependencyMenu

Source path

Scheduler/feature/DependencyMenu.js

Demo

examples/dependencies

Contents