Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -12,7 +12,7 @@ namespace App\EventSubscriber\Actions;
use App\Entity\Customer;
use App\Event\PageActionsEvent;
class CustomerSubscriber extends AbstractActionsSubscriber
final class CustomerSubscriber extends AbstractActionsSubscriber
{
public static function getActionName(): string
{
@@ -30,18 +30,35 @@ class CustomerSubscriber extends AbstractActionsSubscriber
return;
}
if (!$event->isView('customer_details') && $this->isGranted('view', $customer)) {
$event->addAction('details', ['url' => $this->path('customer_details', ['id' => $customer->getId()])]);
$canView = $this->isGranted('view', $customer);
$isListingView = $event->isIndexView() || $event->isCustomView();
if (!$event->isView('customer_details') && $canView) {
$event->addAction('details', ['title' => 'details', 'translation_domain' => 'actions', 'url' => $this->path('customer_details', ['id' => $customer->getId()])]);
}
if ($this->isGranted('edit', $customer)) {
$class = $event->isView('edit') ? '' : 'modal-ajax-form';
$event->addAction('edit', ['url' => $this->path('admin_customer_edit', ['id' => $customer->getId()]), 'class' => $class]);
$event->addAction('edit', ['title' => 'edit', 'translation_domain' => 'actions', 'url' => $this->path('admin_customer_edit', ['id' => $customer->getId()]), 'class' => $class]);
}
if ($this->isGranted('permissions', $customer)) {
$class = $event->isView('permissions') ? '' : 'modal-ajax-form';
$event->addAction('permissions', ['url' => $this->path('admin_customer_permissions', ['id' => $customer->getId()]), 'class' => $class]);
$event->addAction('permissions', ['title' => 'permissions', 'translation_domain' => 'actions', 'url' => $this->path('admin_customer_permissions', ['id' => $customer->getId()]), 'class' => $class]);
}
if ($canView && $event->isIndexView()) {
$event->addAction('vcard', ['title' => 'vcard', 'translation_domain' => 'actions', 'icon' => 'far fa-address-card', 'url' => $this->path('customer_vcard', ['id' => $customer->getId()])]);
}
if ($isListingView) {
if ($customer->isVisible() && $this->isGranted('create_project')) {
$event->addAction('create-project', [
'icon' => 'create',
'url' => $this->path('admin_project_create_with_customer', ['customer' => $customer->getId()]),
'class' => 'modal-ajax-form'
]);
}
}
if ($event->countActions() > 0) {
@@ -64,22 +81,17 @@ class CustomerSubscriber extends AbstractActionsSubscriber
$event->addDivider();
}
if (!$event->isView('customer_details')) {
if ($customer->isVisible() && $this->isGranted('create_project')) {
$event->addAction('create-project', [
'icon' => 'create',
'url' => $this->path('admin_project_create_with_customer', ['customer' => $customer->getId()]),
'class' => 'modal-ajax-form'
]);
}
}
if ($event->isIndexView() && $this->isGranted('delete', $customer)) {
$event->addDelete($this->path('admin_customer_delete', ['id' => $customer->getId()]));
}
if ($this->isGranted('view_reporting') && $this->isGranted('budget_any', 'project')) {
$event->addAction('report_project_view', ['url' => $this->path('report_project_view', ['customer' => $customer->getId()]), 'icon' => 'reporting', 'translation_domain' => 'reporting']);
if ($this->isGranted('report:customer') && $this->isGranted('report:other')) {
$event->addActionToSubmenu('report', 'report_customer_monthly_projects', ['title' => 'report_customer_monthly_projects', 'url' => $this->path('report_customer_monthly_projects', ['customer' => $customer->getId()]), 'translation_domain' => 'reporting']);
}
if ($this->isGranted('report:project') && $this->isGranted('budget_any', 'project')) {
$event->addActionToSubmenu('report', 'daterange_projects', ['title' => 'report_project_daterange', 'url' => $this->path('report_project_daterange', ['customer' => $customer->getId()]), 'translation_domain' => 'reporting']);
$event->addActionToSubmenu('report', 'report_project_view', ['title' => 'report_project_view', 'url' => $this->path('report_project_view', ['customer' => $customer->getId()]), 'translation_domain' => 'reporting']);
}
}
}