Skip to main content
Version: 8.1

Set up module loading

Level: intermediate
Example

Load the UsrCardModulecustom visual module into the UsrModule custom module.

1. Create a class of a visual module

Create a UsrCardModule class of module that inherits from the BaseSchemaModule base class. The class must be instantiated, i. e., return a constructor function. In this case, you can pass the required parameters to a constructor when loading the module externally.

UsrCardModule
/* Module that returns an instance of a class. */
define("UsrCardModule", [...], function(...) {
Ext.define("Terrasoft.configuration.UsrCardModule", {
/* Class alias. */
alternateClassName: "Terrasoft.UsrCardModule",
/* Parent class. */
extend: "Terrasoft.BaseSchemaModule",
/* The flag that indicates that the schema parameters are set externally. */
isSchemaConfigInitialized: false,
/* The flag that indicates that the history status is used when loading the module. */
useHistoryState: true,
/* The schema name of the displayed entity. */
schemaName: "",
/* The flag that indicates that the section list is displayed in combined mode.
If set to false, the page displays SectionModule. */
isSeparateMode: true,
/* Object schema name. */
entitySchemaName: "",
/* Primary column value. */
primaryColumnValue: Terrasoft.GUID_EMPTY,
/* Record page mode. */
operation: ""
});
/* Return a class instance. */
return Terrasoft.UsrCardModule;
}

2. Create a module class to load the visual module

Create a UsrModule module class that inherits from the BaseModel base class.

UsrModule
define("UsrModule", [...], function(...) {
Ext.define("Terrasoft.configuration.UsrModule", {
alternateClassName: "Terrasoft.UsrModule",
extend: "Terrasoft.BaseModel",
Ext: null,
sandbox: null,
Terrasoft: null,
});
}

3. Load the module

You can pass parameters to the constructor of the instantiated module class when loading the module. To do this:

  1. Create a configuration object in the UsrModule class module.
  2. Specify the required values as the properties of the configuration object.
  3. Load the UsrCardModule visual module using the sandbox.loadModule() method.
  4. Add the instanceConfig property to the sandbox.loadModule() method.
  5. Pass the configuration object that contains the required values as the value of the instanceConfig property.
UsrModule
...
init: function() {
this.callParent(arguments);
/* The configuration object. Specify object properties as parameters of the constructor. */
var configObj = {
isSchemaConfigInitialized: true,
useHistoryState: false,
isSeparateMode: true,
schemaName: "QueueItemEditPage",
entitySchemaName: "QueueItem",
operation: ConfigurationEnums.CardStateV2.EDIT,
primaryColumnValue: "{3B58C589-28C1-4937-B681-2D40B312FBB6}"
};

/* Load module. */
this.sandbox.loadModule("UsrCardModule", {
renderTo: "DelayExecutionModuleContainer",
id: this.getQueueItemEditModuleId(),
keepAlive: true,
/* Specify the configuration object in the module constructor as a parameter. */
instanceConfig: configObj
}
});
...

To pass additional parameters when loading the module, use the parameters property of the configuration object. Pre-implement the same property in the module class or one of the parent classes. The parameters property is defined in the BaseModule base class. When a module instance is created, the parameters property of the module is initialized using the values passed in the parameters property of the configuration object.