DependencyMenu
Feature
Displays a context menu when right-clicking dependency lines. Items are populated by other features and/or application code.
const scheduler = new Scheduler({ appendTo : targetElement, // makes scheduler as high as it needs to be to fit rows autoHeight : true, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 13), columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Bernard' }, { id : 2, name : 'Bianca' } ], events : [ { id : 1, resourceId : 1, name : 'Interview', startDate : '2018-05-06', endDate : '2018-05-07' }, { id : 2, resourceId : 1, name : 'Press meeting', startDate : '2018-05-08', endDate : '2018-05-09' }, { id : 3, resourceId : 2, name : 'Audition', startDate : '2018-05-07', endDate : '2018-05-09' }, { id : 4, resourceId : 2, name : 'Script deadline', startDate : '2018-05-11', endDate : '2018-05-11' } ], features : { dependencies : { clickWidth : 15 }, dependencyMenu : true, dependencyEdit : { editorConfig : { items : { // Custom label for the type field typeField : { label : 'Kind' } }, bbar : { items : { // Hiding save button saveButton : { hidden : true } } } } } }, dependencies : [ { id : 1, from : 1, to : 2, cls : 'dev-path' }, { id : 2, from : 2, to : 4 } ] }); 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;
}
}
}
}
});
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
- Dependencies - Dependencies feature
- EventMenu - Event context menu
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
A CSS selector targeting an element, such as an ellipsis icon that when clicked will trigger the menu to show.
-
See Keyboard shortcuts for details
-
Set to
trueto prevent the native menu from showing when there are no menu items to show, or you manually prevent the menu from showing in an event listener.Has a corresponding runtime preventNativeMenu property.
-
Event which is used to show context menu. Available options are: 'contextmenu', 'click' and 'dblclick'. Default value is used from contextMenuTriggerEvent
-
This is a type of the context menu used to generate correct names for methods and events. Should be in camel case. Required to be set in subclass.
-
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
falseto disable localization of this object.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of DependencyMenu class, or subclass thereof.
-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of ContextMenuBase class, or subclass thereof.
-
Identifies an object as an instance of DependencyMenu class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Returns the base, configured-in menu items set from the configured items, taking into account the namedItems the feature offers.
-
Set to
trueto prevent the native menu from showing when there are no menu items to show, or you manually prevent the menu from showing in an event listener.Has a corresponding preventNativeMenu config.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
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-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Hides the context menu
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
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.