This section explains how the table of model components and their sources is rendered in the methodology page.
The methodology sources implementation is somewhat tricky due to a series of decisions influenced by limiting factors, such as the integration between AdminJS (UI and entity management) and the API entities, along with various trade-offs.
Note: AdminJS's
position: number
property, which determines field order, does not work as expected. Instead, we uselistProperties
,showProperties
, andeditProperties
for ordering.
Configuration is managed in:
api/src/modules/methodology/methodology.config.ts
This file contains all the entities that appear in the table. There are two types of relationships:
Entities in which each row can be related to one and only one source.
- Define the
@ManyToOne
and@OneToMany
TypeORM relationships between your entity andModelComponentSource
(use string-based references instead of anonymous functions for AdminJS compatibility). - Add the new entity to the configuration file:
api/src/modules/methodology/methodology.config.ts
Entities in which rows can have multiple columns, each related to different sources.
-
Import and add the following actions to an AdminJS resource options:
properties: { sources: { isVisible: { show: true, edit: true, list: true, filter: false }, components: { list: Components.Many2ManySources, show: Components.Many2ManySources, edit: Components.Many2ManySources, }, } }, actions: { fetchRelatedSourcesAction: { actionType: 'record', isVisible: false, handler: fetchRelatedSourcesActionHandler, }, addSourceAction: { actionType: 'record', isVisible: false, handler: addSourceActionHandler, }, deleteSourceAction: { actionType: 'record', isVisible: false, handler: deleteSourceActionHandler, }, fetchAvailableSourceTypesAction: { actionType: 'record', isVisible: false, handler: fetchAvailableSourceTypesActionHandler, } }
-
Add the new entity to the configuration file:
api/src/modules/methodology/methodology.config.ts
- Always ensure AdminJS compatibility by using string-based references in TypeORM relationships.
- Field ordering on AdminJS does not work as expected, rely on
listProperties
,showProperties
, andeditProperties
to order fields in the different views.