Hi @pat,
Thank you. Yes I think I understand what the goal is.
Creating a custom modal is hard, takes a good amount of time and requires a good knowledge of angular and of the frontend extension framework.
There are 2 alternatives that you could try before going down the custom modal path.
Option 1. Add 4 buttons to re-direct to reports, each for a single report.
There is an easy way to redirect to other pages when a button is pressed. You need to return a redirect
handler in the response of your backend async action, something like
public function run(Process $process)
{
$options = $process->getOptions();
$responseData = [
'handler' => 'redirect',
'params' => [
'route' => $options['module'] . '/convert-lead/' . $options['id'],
'queryParams' => [
]
]
];
$process->setStatus('success');
$process->setMessages([]);
$process->setData($responseData);
}
There are some examples of it like:
core/backend/Process/Service/RecordActions/ConvertLeadAction.php
core/backend/Process/Service/RecordActions/DuplicateRecordAction.php
- and others
Option 2. Add button with a modal that list all reports and redirect to the selected one
This is a modal similar to the one that shows on the Print PDF
action, but instead of showing a list of templates, it would show a list of reports.
On your button definition in detailviewdefs
you can add the param
that you mentioned before, to open a list of all the existing reports (Acls should apply). You can do this like so:
'print-as-pdf' => [
'key' => 'print-as-pdf',
'labelKey' => 'LBL_PRINT_AS_PDF',
'asyncProcess' => true,
'modes' => ['detail'],
'acl' => ['view'],
'aclModule' => 'AOS_PDF_Templates',
'params' => [
'selectModal' => [
'module' => 'AOS_PDF_Templates'
]
]
]
]
Then when a user selects a record, that information will be sent to your backend handler, were you can then build a redirect url like explained on option 1.
The following is an example of to retrieve the selected record information taken from
core/backend/Process/LegacyHandler/AddRecordsToTargetListBulkActionHandler.php
/**
* @inheritDoc
*/
public function run(Process $process)
{
....
$options = $process->getOptions();
[
'module' => $baseModule,
'ids' => $baseIds
] = $options;
['modalRecord' => $modalRecord] = $options;
[
'module' => $modalModule,
'id' => $modalId
] = $modalRecord;
....
}
Hope this helps. Please let me know if you have more doubts