Details
Glossary Item Box
Introduction
Details are used to display supplemental data for a primary section object. The section details are displayed on the section edit page tabs in the tabs area.
Depending on the method of entering and displaying data, there are following types of details.
- Details with edit fields.
- Details with adding page.
- Details with editable list.
- Details with selection from lookup.
More information about details of different types can be found in the "Details” article.
The detail creation
A custom detail must be registered so that the detail wizard could work with it. To register a detail, add a record with detail caption, detail schema identifier DetailSchemaUid (from the UId column in the SysSchema table) and detail object schema identifier EntitySchemaUId (from the UId column in the SysSchema table) to the SysDetail table.
More information about creating details of different types can be found in the "Work with details” article.
The base schema of the BaseDetailV2 detail
All detail schemas must be inherited from the BaseDetailV2 base schema. The base logic of data initialization and communication with the edit page are implemented in the schema.
The base schema class has the following properties:
BaseDetailV2 messages
The massages are used for communication between the detail and the edit page. A full list of messages, their broadcast mode and direction are given in the table 1.
Table 1. The messages of the base detail
Name | Mode | Direction | Description |
---|---|---|---|
GetCardState | Address | Publication | Returns a state of the edit page. |
SaveRecord | Address | Publication | Tells the edit page to save the data. |
DetailChanged | Address | Publication | Tells the edit page about the changes of the detail data. |
UpdateDetail | Address | Subscription | A subscription to the edit page update. |
OpenCard | Address | Publication | Opens edit page. |
The message modes are defined in the Terrasoft.core.enums.MessageMode enumeration and message direction is defined in the Terrasoft.core.enums.MessageDirectionType. More information about them can be found in the “JavaScript API for platform core” article.
BaseDetailV2 attributes
The attributes property contains the attributes of detail view model. The attributes that are defined in base detail class are given in the table 2.
Table 2. The attributes of the base detail
- CanAdd
- BOOLEAN
-
Indicates the possibility to add data.
- CanEdit
- BOOLEAN
-
Indicates the possibility to edit data.
- CanDelete
- BOOLEAN
-
Indicates the possibility to delete data.
- Collection
- COLLECTION
-
Detail data collection.
- Filter
- CUSTOM_OBJECT
-
Detail filter. Used for filtering detail data.
- DetailColumnName
- STRING
-
The column name where the filtering is performed.
- MasterRecordId
- GUID
-
The key value of the parent record.
- IsDetailCollapsed
- BOOLEAN
-
Indicates if the detail is collapsed.
- DefaultValues
- CUSTOM_OBJECT
-
The default value of the model columns.
- Caption
- STRING
-
The detail caption.
The available attribute data types are represented by the Terrasoft.DataValueType enumeration. More information about them can be found in the “JavaScript API for platform core” article.
BaseDetailV2 methods
The methods defined in base detail class are given in the table 3.
Table 3. The methods of the base detail
- init
-
Initializes the detail page.
Parameters:
- {Function} callback — callback function;
- {Object} scope — the context of the method execution.
- initProfile
-
Initializes the schema profile. Default value is Terrasoft.emptyFn.
- initDefaultCaption
-
Sets the default caption of the detail.
- initDetailOptions
-
Initializes the list view data collection.
- subscribeSandboxEvents
-
It is subscribed to the messages necessary for the work of the detail.
- getUpdateDetailSandboxTags
-
Generates the array of tags for the UpdateDetail message.
- updateDetail
-
Updates the detail according to the parameters passed. Default value is Terrasoft.emptyFn.
Parameters:
- {Object} config — configuration object that contains the properties of the detail.
- initData
-
Initializes the list view data collection.
Parameters:
- {Function} callback — callback function;
- {Object} scope — the context of the method execution.
- getEditPageName
-
Returns the name of the edit page depending on the record type at editing or on selected record type for adding.
- onDetailCollapsedChanged
-
The handler of collapsing or expanding of the detail.
Parameters:
- {Boolean} isCollapsed — the attribute of the collapsed/expanded detail.
- getToolsVisible
-
Returns the collapse value of the detail.
- getDetailInfo
-
Publishes a message to get information about the detail.
BaseDetailV2 array of modifications
In the diff modifications array of the base detail, only a base container for detail view is defined:
diff: /**SCHEMA_DIFF*/[ // Base container for detail view. { "operation": "insert", "name": "Detail", "values": {...} } ]/**SCHEMA_DIFF*/
The “BaseGridDetailV2” base “detail with list” class
The class is a BaseDetailV2 inheritor. All details with lists must be the BaseGridDetailV2 inheritors. The list base logic (import, filtering, adding, deleting and editing the detail records) is implemented in the BaseGridDetailV2 schema.
More information about creating custom details can be found in the" Adding a detail with an editable list” article.
BaseGridDetailV2 messages
Main BaseGridDetailV2 messages are given in table 4.
Table 4. The messages of the detail with a list
Name | Mode | Direction | Description |
---|---|---|---|
getCardInfo | Address | Subscription | Returns information about the edit page: its default values, type column name and type column value. |
CardSaved | Broadcasting | Subscription | Handles a message of saving the edit page. |
UpdateFilter | Broadcasting | Subscription | Refreshes filters in the detail. |
GetColumnsValues | Address | Publication |
Receives the column values of the edit page model. |
The message modes are defined in the “Terrasoft.core.enums.MessageMode” enumeration and message direction in the “Terrasoft.core.enums.MessageDirectionType” enumeration. More information about them can be found in the “JavaScript API for platform core” article.
BaseGridDetailV2 attributes
Main BaseGridDetailV2 attributes are given in table 5.
Table 5. The attributes of the detail with a list
- ActiveRow
- GUID
-
The value of the primary column of the active record in the list.
- IsGridEmpty
- BOOLEAN
-
Indicates that the list is empty.
- MultiSelect
- BOOLEAN
-
Indicates if multiple selection is permitted.
- SelectedRows
- COLLECTION
-
An array of selected values.
- RowCount
- INTEGER
-
Number of rows in the list.
- IsPageable
- BOOLEAN
-
Indicates if the page-by-page loading is enabled.
- SortColumnIndex
- INTEGER
-
Index of the sorting column.
- CardState
- TEXT
-
Opening mode for the record edit page.
- EditPageUId
- GUID
-
A unique identifier of the edit page.
- ToolsButtonMenu
- COLLECTION
-
The collection of the functional button’s drop-down list.
- DetailFilters
- COLLECTION
-
Collection of the detail filters.
- IsDetailWizardAvailable
- BOOLEAN
-
Indicates if the detail wizard is available.
The available attribute data types are represented by the Terrasoft.DataValueType enumeration. More information about them can be found in the “JavaScript API for platform core” article.
BaseGridDetailV2 mixins
Main BaseGridDetailV2 mixins are given in the table 6.
Table 6. The mixins of the detail with a list
- GridUtilities
- Terrasoft.GridUtilities
-
Mixin for the list.
- WizardUtilities
- Terrasoft.WizardUtilities
-
Mixin for the detail wizard.
More information about the GridUtilities mixin is given below.
BaseGridDetailV2 methods
Main BaseGridDetailV2 methods are given in table 7.
Table 7. The methods of the base detail with a list
- init
-
Overrides the BaseDetailV2 method. Calls the parent’s init method logic, registers the messages, initializes the filters.
Parameters:
- {Function} callback — callback function;
- {Object} scope — the context of the method execution.
- initData
-
The override of the BaseDetailV2 method. Calls the parent’s initData method logic, initializes the data collection of the list view.
Parameters:
- {Function} callback — callback function;
- {Object} scope — the context of the method execution.
- loadGridData
-
Executes the load of the list data.
- initGridData
-
Executes the initialization of the default values for working with the list.
- getGridData
-
Returns list collection.
- getFilters
-
Returns the detail filter collection.
- getActiveRow
-
Returns the identifier of the selected record in the list.
- addRecord
-
Adds the new record to the list. Saves the edit page, if needed.
Parameters:
- {String} editPageUId — identifier of typed edit page.
- copyRecord
-
Copies the record and opens the edit page.
Parameters:
- {String} editPageUId — identifier of typed edit page.
- editRecord
-
Opens edit page of the selected record.
Parameters:
- {Object} record — record model for editing.
- subscribeSandboxEvents
-
It is subscribed to the messages necessary for the detail operation.
- updateDetail
-
The override of the BaseDetailV2 method. Calls the parent’s updateDetail method logic, updates the detail.
Parameters:
- {Object} config — configuration object that contains the properties of the detail.
- openCard
-
Opens edit page.
Parameters:
- {String} operation — operation type (creating/modifying);
- {String} typeColumnValue — the value of record typing column;
- {String} recordId — record identifier.
- onCardSaved
-
Handles the save event of the edit page where the detail is located.
- addToolsButtonMenuItems
-
Adds elements to the collection of the functional button drop-down list.
Parameters:
- {Terrasoft.BaseViewModelCollection} toolsButtonMenu — the collection of the functional button drop-down list.
- initDetailFilterCollection
-
Initializes the detail filter.
- setFilter
-
Sets the detail filter value.
Parameters:
- {String} key — filter type;
- {Object} value — filter value.
- loadQuickFilter
-
Loads the quick filter.
Parameters:
- {Object} config — parameters of the filters module load.
- destroy
-
Clears the data, exports the detail.
BaseGridDetailV2 array of modifications
In the diff modifications array of the base detail, only a base container for detail view is defined:
diff: /**SCHEMA_DIFF*/ [ { // Element for displaying the list. "operation": "insert", "name": "DataGrid", "parentName": "Detail", "propertyName": "items", "values": { "itemType": Terrasoft.ViewItemType.GRID, … } }, { // List reloading button. "operation": "insert", "parentName": "Detail", "propertyName": "items", "name": "loadMore", "values": { "itemType": Terrasoft.ViewItemType.BUTTON, … } }, { // Record adding button. "operation": "insert", "name": "AddRecordButton", "parentName": "Detail", "propertyName": "tools", "values": { "itemType": Terrasoft.ViewItemType.BUTTON, … } }, { // Typed record adding button. "operation": "insert", "name": "AddTypedRecordButton", "parentName": "Detail", "propertyName": "tools", "values": { "itemType": Terrasoft.ViewItemType.BUTTON, … } }, { // Detail menu. "operation": "insert", "name": "ToolsButton", "parentName": "Detail", "propertyName": "tools", "values": { "itemType": Terrasoft.ViewItemType.BUTTON, … } } ] /**SCHEMA_DIFF*/
The GridUtilitiesV2 mixin
GridUtilitiesV2 is a mixin that implements the logic of the “list” control. Features that are implemented in the Terrasoft.configuration.mixins.GridUtilities class:
- Message subscription
- Data load.
- Working with the list:
- selection of the records (the search of the active records)
- adding, deleting and modifying the records
- setting up the filters
- sorting
- exporting to the file
- checking the access permissions to the list records
GridUtilitiesV2 methods
Main GridUtilitiesV2 methods are given in table 8.
Table 8. The methods of the base detail with a list
- init
-
Subscribes to the events.
- destroy
-
Deletes event subscriptions.
- loadGridData
-
Executes the load of the list data.
- beforeLoadGridData
-
Prepares the view model to the data load.
- afterLoadGridData
-
Prepares the view model after the data load.
- onGridDataLoaded
-
A handler of the data load event. Executes when the server returns the data.
Parameters:
- {Object} response — the result of fetching the data from the database.
- addItemsToGridData
-
Adds a collection of new elements to the list collection.
Parameters:
- {Object} dataCollection — collection of new elements;
- {Object} options — adding parameters.
- reloadGridData
-
Reloads the list.
- initQueryOptions
-
Initializes the settings of the query instance, such as pagination and hierarchy.
Parameters:
- {Terrasoft.EntitySchemaQuery} esq — in this query the necessary settings will be initialized.
- initQuerySorting
-
Initializes the sorting column.
Parameters:
- {Terrasoft.EntitySchemaQuery} esq — in this query the necessary settings will be initialized.
- prepareResponseCollection
-
Modifies the data collection before loading it to the list.
Parameters:
- {Object} collection — list elements collection.
- getFilters
-
Returns filters that are applied to current schema. It is overridden in the inheritors.
- exportToFile
-
Exports the contents of the list into a file.
- sortGrid
-
Performs list sorting.
Parameters:
- {String} tag — a key that shows how to sort the list.
- deleteRecords
-
Initiates the deletion of the selected records.
- checkCanDelete
-
Checks the ability to delete a record.
Parameters:
- {Array} items — the identifiers of the selected records;
- {Function} callback — callback function;
- {Object} scope — the context of the method execution.
- onDeleteAccept
-
Performs the deletion after the confirmation of the user.
- getSelectedItems
-
Returns the selected records in the list.
- removeGridRecords
-
Removes the deleted records from the list.
Parameters:
- {Array} records — deleted records.
A detail with editable list
A detail with editable list enables editing records directly in the list without going to the record editing page. To make a detail list editable, you need to modify its schema the following way:
- Add the dependencies from the ConfigurationGrid, ConfigurationGridGenerator and ConfigurationGridUtilities modules.
- Connect the ConfigurationGridUtilites and OrderUtilities mixins.
- Set the IsEditable attribute to “true”.
- Add a configuration object in the modification array where the properties will be set and the methods that handle the detail list events will be bound.
The development case of creating a detail with an editable list can be found in the "Adding a detail with an editable list” article.
The “ConfigurationGrid” module
The ConfigurationGrid module contains the implementation of the “Configuration Grid” control. The Terrasoft.ConfigurationGrid class is the inheritor of the Terrasoft.Grid class. Main Terrasoft.ConfigurationGrid methods are given in table 9.
Table 9. Configuration grid methods
- init
-
Initializes a component. Subscribes to the events.
- activateRow
-
Selects the string and adds edit elements.
Parameters:
- {String|Number} id — the identifier of the list string.
- deactivateRow
-
Removes selection of a string and removes edit elements.
Parameters:
- {String|Number} id — the identifier of the list string.
- formatCellContent
-
Formats the data of a string cell.
Parameters:
- {Object} cell — the cell;
- {Object} data — the data;
- {Object} column — the cell configuration.
- onUpdateItem
-
The handler of the record update event.
Parameters:
- {Terrasoft.BaseViewModel} item — collection element.
- onDestroy
-
Destroys the list and its components.
ConfigurationGridGenerator module
The Terrasoft.ConfigurationGridGenerator generates list configuration and is an inheritor of the Terrasoft.ViewGenerator class. The methods that are implemented in the Terrasoft.ConfigurationGridGenerator class are given in table 10.
Table 10. The methods of the configuration grid generator
- addLinks
-
Overridden method of the Terrasoft.ViewGenerator class. No links will be added to the editable list.
- generateGridCellValue
-
Overridden method of the Terrasoft.ViewGenerator class. Generates a value configuration in the cell.
Parameters:
- {Object} config — column configuration.
The ConfigurationGridUtilities module
The Terrasoft.ConfigurationGridUtilities class contains methods that initialize a view model of the list string, process the active record actions and handle “hotkeys”.
The main properties of the Terrasoft.ConfigurationGridUtilities class are given in table 11 and its methods are provided in table 12.
Table 11. The Terrasoft.ConfigurationGridUtilities class properties
- currentActiveColumnName
- String
-
The name of the currently selected column.
- columnsConfig
- Object
-
Column configuration.
- systemColumns
- Array
-
Collection of the system column names.
Table 12. The Terrasoft.ConfigurationGridUtilities class methods
- onActiveRowAction
-
Handles clicking an action of the active record.
Parameters:
- {String} buttonTag — a tag of the selected action;
- {String} primaryColumnValue — active record identifier.
- saveRowChanges
-
Saves the record.
Parameters:
- {Object} row — list string;
- {Function} [callback] — callback function;
- {Object} scope — the callback function context.
- activeRowSaved
-
Handles the result of saving the record.
Parameters:
- {Object} row — list string;
- {Function} [callback] — callback function;
- {Object} scope — the callback function context.
- initActiveRowKeyMap
-
Initializes the subscription to the button events in the active string.
Parameters:
- {Array} keyMap — events description.
- getCellControlsConfig
-
Returns the configuration of the list cell edit items.
Parameters:
- {Terrasoft.EntitySchemaColumn} entitySchemaColumn — the column of the list cell.
- copyRow
-
Copies and adds a record to the list.
Parameters:
- {String} recordId — the identifier of a copying record.
- initEditableGridRowViewModel
-
Initializes the classes of the collection elements of the edited list.
Parameters:
- {Function} [callback] — callback function;
- {Object} scope — the callback function context.