Global ViewModel
The global ViewModel is available in many places throughout the application and can be used in XTemplates, among other places. It contains important information such as data on the user session, the global date range filter, the selected language, the active module, the user’s roles and permissions, and maintenance mode. This centrally managed data enables consistent and efficient handling of application-wide settings and user information
Structure of the ViewModel
| Name | Description |
|---|---|
|
Contains information about the currently active module, including ID, name, etc. |
|
Defines the global date range for data filtering with properties such as value, global mode, and activity status. |
|
Stores the currently selected user interface language (e.g., "de" for German). |
|
Contains information on various licensing aspects of the application, modules, and services. |
|
A Boolean value indicating whether the application is in maintenance mode. |
|
Configuration settings for the monitor module. |
|
Defines the user’s access rights to various modules and functions. |
|
Contains the roles assigned to the user (e.g., administrator, regular user). |
|
The status attribute includes various sub-attributes that provide information about the current state of the application, including the CRUD state, active user sessions, and license details. These attributes help monitor the system status and identify issues to ensure smooth functionality. |
|
Stores information about the current user session, such as login credentials and session duration. |
|
A unique identification number for the current instance or session. |
|
This overview represents the main components of the global ViewModel; however, depending on the configuration, application context, and specific implementations, additional attributes and data structures may be present. |
Access via the browser console
To view the current contents of the global ViewModel, you can perform the following steps in the browser console:
-
Open your browser’s developer tools (F12 in most browsers)
-
Switch to the console
-
Enter the following command:
BpcCommon.Api.getGlobalViewModel().get("global")
This displays the current state of the global ViewModel.
Usage in XTemplates
When using XTemplates, you can access the global ViewModel.
Example:
new Ext.XTemplate(
'<p>Aktueller Benutzer: {global.userSession.firstName} {global.userSession.lastName} </p>'
)
Links
-
https://docs.sencha.com/extjs/7.5.0/classic/Ext.app.ViewModel.html [Official ExtJS documentation on ViewModel]
-
https://docs.sencha.com/extjs/7.5.0/classic/Ext.XTemplate.html [Official ExtJS documentation on XTemplate]