Menu Item Driver

The Menu Item Driver is a property of the menu item; it's an attribute or parameter linked to a menu item that efficiently structures the working interface by associating specific functionality with a defined menu item. The menu item driver provides developers with a powerful tool to logically and accessibly present the various features and options available for modules. Thus, the menu item driver represents a crucial pillar for Activator in the design and development of services.

 

Menu Item Driver

This image illustrates an example of a Menu Item Driver. The entire section containing the table of the Member list is the Menu Item Driver linked to its Menu Item (Members With Driver).

In Activator Admin, the "MENU ITEMS DRIVER" module is located within the menu container, among the items listed under </>Pages and Navigation.

✍️Note: Ensure that you are in the main module of system components.

 

Menu Item Driver Activator Admin

Menu Item Driver Activator Admin

 

To begin creating a new menu item driver, simply click on the "+ Add New" button. Once clicked, you will notice a change in the interface, with the appearance of several options allowing you to configure the properties of the newly created menu item driver.

Menu Item Driver Configuration
The different elements to define for configuring the menu item driver are:
- The Name: (Only modify the part with: newnavigationmenuitemdriver1)
- The Description: (Only modify the part with: newnavigationmenuitemdriver1).
- The Definition: which will contain all the operational logic of the driver in the form of a JavaScript file defined by:

$activator.ui.jsmodules.defines(function(){
//called to initialize the driver
this.initialize = function (context) {
	return new Promise((resolve, reject) => {
		resolve()
		});
};
//Handle items click event
this.onItemClick = function (context){
};
});
fdfda

In this content, the developer is required to place the JavaScript code they want to execute in the section.

this.onItemClick = function (context){
};

In this section, they will write all the code that will allow them to give a function to the menu item because this function is directly called when the menu item is clicked. The rendering of the function by its (context) will contain the div that displays the menu item driver.

For the other part defined as:

this.initialize = function (context) {
	return new Promise((resolve, reject) => {
		resolve()
		});
};

This method is called during the initialization of the driver or the module, and it would be used to perform driver-specific initialization operations, such as configuring parameters, registering events, or preparing data.
It takes one argument context, which can contain information or references necessary for initializing the driver.
It returns a Promise resolved immediately, indicating that the initialization has been successfully completed.