fix activities and history subpanel buttons not visible

This commit is contained in:
p.kumar 2021-12-09 17:46:24 +05:30
parent 752453dd38
commit ee0840a345
5 changed files with 156 additions and 81 deletions

View file

@ -53,6 +53,7 @@ services:
$upgradeConfig: '%upgrades%'
$subpanelLineActions: '%module.subpanel.line_actions%'
$subpanelTopActions: '%module.subpanel.top_actions%'
$subpanelTopButtons: '%module.subpanel.top_buttons%'
_instanceof:
App\Process\Service\ProcessHandlerInterface:
tags: [ 'app.process.handler' ]

View file

@ -21,3 +21,13 @@ parameters:
modes:
- list
acl:
edit:
key: edit
labelKey: LBL_EDIT
action: edit
asyncProcess: true
params:
modes:
- list
acl:
- edit

View file

@ -0,0 +1,102 @@
parameters:
module.subpanel.top_buttons:
SubPanelTopSelectButton:
key: select
labelKey: LBL_LINK
action: select
asyncProcess: true
params:
modes:
- list
acl:
- edit
SubPanelTopButtonQuickCreate: &createButton
key: create
labelKey: LBL_QUICK_CREATE
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
SubPanelTopCreateButton: *createButton
SubPanelTopCreateTaskButton:
key: create
labelKey: LNK_NEW_TASK
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: tasks
SubPanelTopScheduleMeetingButton:
key: create
labelKey: LNK_NEW_MEETING
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: meetings
SubPanelTopScheduleCallButton:
key: create
labelKey: LNK_NEW_CALL
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: calls
SubPanelTopComposeEmailButton:
key: create
labelKey: LNK_NEW_EMAIL
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: emails
moduleAction:
- composeView
SubPanelTopCreateNoteButton:
key: create
labelKey: LNK_NEW_NOTE
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: notes
SubPanelTopArchiveEmailButton:
key: create
labelKey: LBL_TRACK_EMAIL_BUTTON_LABEL
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: emails
SubPanelTopCreateLeadNameButton:
key: create
labelKey: LBL_QUICK_CREATE
action: create
asyncProcess: true
params:
modes:
- list
acl:
- edit
module: leads

View file

@ -49,8 +49,9 @@ export class SubpanelCreateAction extends SubpanelActionHandler {
run(data: SubpanelActionData): void {
const moduleName = data.module;
const moduleAction = data?.action?.moduleAction ?? 'edit';
const route = `/${moduleName}/edit`;
const route = `/${moduleName}/${moduleAction}`;
const queryParams = {
// eslint-disable-next-line camelcase,@typescript-eslint/camelcase

View file

@ -40,17 +40,19 @@ class SubpanelTopActionDefinitionProvider extends ActionDefinitionProvider imple
/**
* @var array
*/
private $topButtonsMap = ['Create' => 'create', 'Select' => 'link'];
private $subpanelTopButtons;
/**
* SubpanelTopActionDefinitionProvider constructor.
* @param array $subpanelTopActions
* @param array $subpanelTopButtons
* @param ActionAvailabilityChecker $actionChecker
*/
public function __construct(array $subpanelTopActions, ActionAvailabilityChecker $actionChecker)
public function __construct(array $subpanelTopActions, array $subpanelTopButtons, ActionAvailabilityChecker $actionChecker)
{
parent::__construct($actionChecker);
$this->subpanelTopActions = $subpanelTopActions;
$this->subpanelTopButtons = $subpanelTopButtons;
}
/**
@ -109,86 +111,45 @@ class SubpanelTopActionDefinitionProvider extends ActionDefinitionProvider imple
public function getTopAction(string $module, array $topButton): array
{
$mapped = [
'SubPanelTopCreateTaskButton' => [
'key' => 'create',
'labelKey' => 'LNK_NEW_TASK',
'module' => 'tasks'
],
'SubPanelTopScheduleMeetingButton' => [
'key' => 'create',
'labelKey' => 'LNK_NEW_MEETING',
'module' => 'meetings'
],
'SubPanelTopScheduleCallButton' => [
'key' => 'create',
'labelKey' => 'LNK_NEW_CALL',
'module' => 'calls'
],
'SubPanelTopComposeEmailButton' => [
'skip' => true,
],
'SubPanelTopCreateNoteButton' => [
'key' => 'create',
'labelKey' => 'LNK_NEW_NOTE',
'module' => 'notes'
],
'SubPanelTopArchiveEmailButton' => [
'skip' => true,
],
'SubPanelTopSummaryButton' => [
'skip' => true,
],
'SubPanelTopFilterButton' => [
'skip' => true,
],
'SubPanelTopSelectUsersButton' => [
'skip' => true,
],
'SubPanelTopSelectContactsButton' => [
'skip' => true,
],
];
foreach ($this->topButtonsMap as $key => $actionKey) {
if (empty($topButton['widget_class']) || !strpos($topButton['widget_class'], $key)) {
continue;
}
if (!$this->isActionAccessible($module, $actionKey)) {
continue;
}
$mappedButton = $mapped[$topButton['widget_class']] ?? null;
if ($mappedButton !== null && !empty($mappedButton['skip'])) {
continue;
}
if ($mappedButton !== null) {
$mappedButton['additionalFields'] = $topButton['additionalFields'] ?? [];
$mappedButton['extraParams'] = $topButton['extraParams'] ?? [];
$mappedButton['widget_class'] = $topButton['widget_class'] ?? [];
$topButtons[] = $mappedButton;
continue;
}
$actions = $this->getActions($module);
return array_merge(
$actions[$actionKey],
[
'module' => $module,
'widget_class' => $topButton['widget_class'],
'additionalFields' => $topButton['additionalFields'] ?? [],
'extraParams' => $topButton['extraParams'] ?? []
]
);
if (array_key_exists($topButton['widget_class'], $this->subpanelTopButtons)) {
$widgetClass = $topButton['widget_class'];
}
return [];
}
if (empty($widgetClass)) {
//check if the button class name contains the create or select string
if (stripos($topButton['widget_class'], 'create')) {
$widgetClass = 'SubPanelTopCreateButton';
}
if (stripos($topButton['widget_class'], 'select')) {
$widgetClass = 'SubPanelTopSelectButton';
}
}
if (empty($widgetClass)) {
return [];
}
$mappedButton = $this->subpanelTopButtons[$widgetClass];
if (empty($mappedButton)) {
return [];
}
$mappedModule = $mappedButton['module'] ?? $module;
$mappedAcls = $mappedButton['acl'] ?? [];
foreach ($mappedAcls as $aclKey) {
if (!$this->isActionAccessible($mappedModule, $aclKey)) {
return [];
}
}
$mappedButton['additionalFields'] = $topButton['additionalFields'] ?? [];
$mappedButton['extraParams'] = $topButton['extraParams'] ?? [];
$mappedButton['widget_class'] = $topButton['widget_class'] ?? [];
return $mappedButton;
}
}