Introduction
This feature is about to enable the Most Recently used. This means that we can display the last clicked entry of a grid in a tile overview.
How-to:...
Step 1:
First, set the 'MruTableNames' application setting (comma-separated list) to include the table name(s) for which you want to register a new entity.
This can be done in SWAT in the (config→ environment -> .restapplicationsettings file)
Step 2:
Customers would need to provide their own implementation of this service (either by implementing the service from scratch or overriding the default SWAT legacy implementation). Create a folder in src → backend which is called <Customer Name > create a folder <OERA> create folder <metadata> and file EntityMetadataService.cls and insert the following code and overwrite the table name.
Add the corresponding code to execute the MRU registration. For this you have to add the following code snippet:
Please create a new folder in src/backend/<Customername> and name them OERA/Metadata/ and create a file with the code below using the name EntityMetadataService.cls
USING Progress.Lang.*.
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS <your class>.OERA.Metadata.EntityMetadataService
INHERITS Akioma.Swat.OERA.Metadata.LegacyEntityMetadataService
IMPLEMENTS Akioma.Swat.OERA.Metadata.IEntityMetadataService:
CONSTRUCTOR EntityMetadataService():
SUPER().
END CONSTRUCTOR.
METHOD OVERRIDE PUBLIC CHARACTER GetDetailsScreen(pcRecordHdl AS CHARACTER):
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cContainerName AS CHARACTER NO-UNDO.
cTableName = Akioma.Swat.RecordHdlHelper:GetTableNameFromHdl(pcRecordHdl).
CASE cTableName:
WHEN "Article" THEN
RETURN "ArticleMaintenanceScreen".
END CASE.
cContainerName = SUPER:GetDetailsScreen(pcRecordHdl).
IF cContainerName > "" THEN
RETURN cContainerName.
RETURN "".
END METHOD.
METHOD OVERRIDE PUBLIC CHARACTER GetLabel(pcRecordHdl AS CHARACTER):
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cLabel AS CHARACTER NO-UNDO.
cTableName = Akioma.Swat.RecordHdlHelper:GetTableNameFromHdl(pcRecordHdl).
CASE cTableName:
WHEN "Article" THEN
RETURN "Article".
END CASE.
cLabel = SUPER:GetLabel(pcRecordHdl).
IF cLabel > "" THEN
RETURN cLabel.
RETURN "".
END METHOD.
METHOD OVERRIDE PUBLIC CHARACTER GetIcon(pcRecordHdl AS CHARACTER):
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cIcon AS CHARACTER NO-UNDO.
cTableName = Akioma.Swat.RecordHdlHelper:GetTableNameFromHdl(pcRecordHdl).
CASE cTableName:
WHEN "Article" THEN
RETURN "fad fa-shopping-cart".
END CASE.
cIcon = SUPER:GetIcon(pcRecordHdl).
IF cIcon > "" THEN
RETURN cIcon.
RETURN "".
END METHOD.
END CLASS.
Step 3:
Create a Service.xml in config/environment and declare the class in the service.xml like in the following code snippet:
<?xml version="1.0"?>
<ttServiceLoader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ttServiceLoaderRow>
<Order>0</Order>
<ServiceTypeName>Akioma.Swat.OERA.Metadata.IEntityMetadataService</ServiceTypeName>
<ServiceClassName>YOURCLASS.OERA.Metadata.EntityMetadataService</ServiceClassName>
</ttServiceLoaderRow>
</ttServiceLoader>
Step 4
Some fields used in the template get their value based on the table definition file
(e.g., TargetKey is set based on the xml table KeyFields attribute; so at runtime, for our table, the value display for the MRU entry keycomes from the field specified in the attribute).
This applies for the key (KeyFields attribute) and the MRU record description (descriptionFields attribute).
Declare the attributes you want to show in the table definitions in src/backend/DB/customer/table-definition-customerdb
Step 5:
Declare the table in the pasoe-config.xml
<tableDefinitionsDumpFile>DB/it4main/table-definitions-swatdb.xml,DB/offerdb/table-definitions-offerdb.xml,DB/customer/table-definitions-customerdb.xml</tableDefinitionsDumpFile>
Step 6:
Declare the service.xml in the startup.json
},
"applicationSettings": ".restapplicationsettings",
"inheritLoadServices": true,
"loadServices": [],
"loadServices": ["services.xml"],
"inheritManagers": true,
"managers": {},
"inheritCustomLogEntries": false,
Step 7
Declare the service.xml in the docker-compose.yml and add the following snippet
- ${GITPOD_REPO_ROOT}/config/environment/services.xml:/workspace/config/services.xml
Step 8
Registering an MRU entity should be done when a details screen is opened.
In order to launch the screen (in our case, articlemaintenancescreen) by clicking on a grid column, you need to do the following steps:
- In the source grid, on the column you click on, set the following attributes:
- SUBTYPE: LAUNCH
- VisualizationType: LINK
- KeyField: *key field of the table* (in our case, selfHdl)
- On the grid itself, set the following attribute
- FolderWindowToLaunch: *detail screen to open on click* (in our case, articlemaintenancescreen) - used to specify which screen opens on click;
- Finally, on the DSO used in the details screen, set the EventAfterFetch to the following: '$ akioma.registerMruEntryFromBE(self);'.This will call a function in the MruBT.cls which will do the registering in the MRU table. The data source needs its index to point to a valid record in order for the register to work.
The details screen should have the same PrimarySDO as the DSO used in the grid (ArticleDSO).
After those steps are followed, the new MRU entities will show up in the MRU Data View.
IMPORTANT: Double-clicking on an item from the MRU data View will only work if the data Source has one of the following fields: selfhdl, refhdl or childhdl.
Settings/Attributes
Attribute | Example/Values |
SUBTYPE | LAUNCH |
VisualizationType | LINK |
KeyField | *key field of the table* (in our case, selfHdl) |
FolderWindowToLaunch: | articlemaintenancescreen |
EventAfterFetch | $ akioma.registerMruEntryFromBE(self) |