From a2545dfb62062a51f46e0ed7f0174b22a4ed0926 Mon Sep 17 00:00:00 2001 From: David mattei Date: Fri, 26 Jul 2024 10:15:58 +0200 Subject: [PATCH] refactor(admin/dataTable): filter & analyzer overview (#966) --- .../views/bootstrap5/analyzer/add.html.twig | 2 +- .../views/bootstrap5/analyzer/edit.html.twig | 2 +- .../views/bootstrap5/analyzer/index.html.twig | 109 --------------- .../views/bootstrap5/filter/add.html.twig | 2 +- .../views/bootstrap5/filter/edit.html.twig | 2 +- .../views/bootstrap5/filter/index.html.twig | 109 --------------- .../ContentManagement/AnalyzerController.php | 124 +++++++++++------- .../ContentManagement/FilterController.php | 104 +++++++++------ .../src/Controller/TwigElementsController.php | 4 +- .../src/Core/Mapping/AnalyzerManager.php | 101 ++++++++++---- .../src/Core/Mapping/FilterManager.php | 101 ++++++++++---- .../src/DataTable/Type/DataTableTypeTrait.php | 23 ++++ .../Type/Mapping/AnalyzerDataTableType.php | 64 +++++++++ .../Type/Mapping/FilterDataTableType.php | 64 +++++++++ EMS/core-bundle/src/Entity/Analyzer.php | 2 +- EMS/core-bundle/src/Entity/Filter.php | 2 +- .../src/Repository/AnalyzerRepository.php | 76 +++++------ .../src/Repository/FilterRepository.php | 66 +++++----- .../src/Resources/config/controllers.xml | 8 +- .../src/Resources/config/datatable.xml | 8 ++ .../config/routing/{ => admin}/analyzer.xml | 10 +- .../config/routing/{ => admin}/filter.xml | 10 +- .../src/Resources/config/routing/all.xml | 8 +- .../translations/emsco-core+intl-icu.en.yml | 13 ++ .../Resources/views/analyzer/add.html.twig | 2 +- .../Resources/views/analyzer/edit.html.twig | 2 +- .../Resources/views/analyzer/index.html.twig | 109 --------------- .../src/Resources/views/filter/add.html.twig | 2 +- .../src/Resources/views/filter/edit.html.twig | 2 +- .../Resources/views/filter/index.html.twig | 109 --------------- EMS/core-bundle/src/Routes.php | 10 ++ 31 files changed, 568 insertions(+), 682 deletions(-) delete mode 100644 EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/index.html.twig delete mode 100644 EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/index.html.twig create mode 100644 EMS/core-bundle/src/DataTable/Type/DataTableTypeTrait.php create mode 100644 EMS/core-bundle/src/DataTable/Type/Mapping/AnalyzerDataTableType.php create mode 100644 EMS/core-bundle/src/DataTable/Type/Mapping/FilterDataTableType.php rename EMS/core-bundle/src/Resources/config/routing/{ => admin}/analyzer.xml (78%) rename EMS/core-bundle/src/Resources/config/routing/{ => admin}/filter.xml (79%) delete mode 100644 EMS/core-bundle/src/Resources/views/analyzer/index.html.twig delete mode 100644 EMS/core-bundle/src/Resources/views/filter/index.html.twig diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/add.html.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/add.html.twig index 72b8f8e3d..86f518ade 100644 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/add.html.twig +++ b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/add.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/edit.html.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/edit.html.twig index 86ce41dec..df0d72c54 100644 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/edit.html.twig +++ b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/edit.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/index.html.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/index.html.twig deleted file mode 100644 index 7a0bd2140..000000000 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/analyzer/index.html.twig +++ /dev/null @@ -1,109 +0,0 @@ -{% extends '@EMSAdminUI/bootstrap5/base/admin.html.twig' %} -{% trans_default_domain 'EMSCoreBundle' %} - -{% block title %}{{ 'Analyzers'|trans }}{% endblock %} -{% block pagetitle %}{{ 'Analyzers'|trans }}{% endblock %} -{% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} - -{% block breadcrumb %} - -{% endblock %} - - -{% block body %} - -
-
-
-
- -

{{ 'Analyzers'|trans }}

- - {{ 'Add analyzer'|trans }} - -
- -
- {% if paging.lastPage > 1 %} -
- {% include '@EMSAdminUI/bootstrap5/elements/pagination.html.twig' with { - 'paging': paging, - 'currentFilters': app.request.query, - 'paginationPath': paginationPath, - 'showAlwaysFirstAndLast': false - } %} -
- {% endif %} - -
- - - - - {% include '@EMSAdminUI/bootstrap5/elements/sortable-th.html.twig' with { - 'title': 'Name'|trans, - 'field': 'name', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {% include '@EMSAdminUI/bootstrap5/elements/sortable-th.html.twig' with { - 'title': 'Label'|trans, - 'field': 'label', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {# {% include '@EMSAdminUI/bootstrap5/elements/sortable-th.html.twig' with {#} -{# 'title': 'Dirty'|trans,#} -{# 'field': 'dirty',#} -{# 'orderField': paging.orderField,#} -{# 'orderDirection': paging.orderDirection,#} -{# 'paginationPath': paging.paginationPath,#} -{# } %}#} - - - - - {% for analyzer in paging.data %} - - - - -{# #} - - - {% endfor %} - -
{{ '#'|trans }}{{ 'Action'|trans }}
{{ loop.index }}{{ analyzer.name }}{{ analyzer.label }} -
- {% include '@EMSAdminUI/bootstrap5/elements/get-button.html.twig' with { - 'url': path('ems_analyzer_edit', {'analyzer': analyzer.id}), - 'label': 'Edit', - 'icon': 'pencil' - }%} - {% include '@EMSAdminUI/bootstrap5/elements/get-button.html.twig' with { - 'url': path('emsco_analyzer_export', {'analyzer': analyzer.id}), - 'label': 'Export', - 'icon': 'sign-out' - }%} - {% include '@EMSAdminUI/bootstrap5/elements/post-button.html.twig' with { - 'url': path('ems_analyzer_delete', {'analyzer': analyzer.id}), - 'message': 'Delete the analyzer ' ~ analyzer.name ~ ' ?', - 'label': 'Delete', - 'icon': 'trash' - }%} -
-
-
-
- -
-
-
- - -{% endblock %} diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/add.html.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/add.html.twig index babaee2c0..4d2989e6e 100644 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/add.html.twig +++ b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/add.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/edit.html.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/edit.html.twig index 2e324b8bb..fcf003c75 100644 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/edit.html.twig +++ b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/edit.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/index.html.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/index.html.twig deleted file mode 100644 index 21aa62d6f..000000000 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/filter/index.html.twig +++ /dev/null @@ -1,109 +0,0 @@ -{% extends '@EMSAdminUI/bootstrap5/base/admin.html.twig' %} -{% trans_default_domain 'EMSCoreBundle' %} - -{% block title %}{{ 'Filters'|trans }}{% endblock %} -{% block pagetitle %}{{ 'Filters'|trans }}{% endblock %} -{% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} - -{% block breadcrumb %} - -{% endblock %} - - -{% block body %} - -
-
-
-
- -

{{ 'Filters'|trans }}

- - {{ 'Add a Filter'|trans }} - -
- -
- {% if paging.lastPage > 1 %} -
- {% include '@EMSAdminUI/bootstrap5/elements/pagination.html.twig' with { - 'paging': paging, - 'currentFilters': app.request.query, - 'paginationPath': paginationPath, - 'showAlwaysFirstAndLast': false - } %} -
- {% endif %} - -
- - - - - {% include '@EMSAdminUI/bootstrap5/elements/sortable-th.html.twig' with { - 'title': 'Name'|trans, - 'field': 'name', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {% include '@EMSAdminUI/bootstrap5/elements/sortable-th.html.twig' with { - 'title': 'Label'|trans, - 'field': 'label', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {# {% include '@EMSAdminUI/bootstrap5/elements/sortable-th.html.twig' with {#} -{# 'title': 'Dirty'|trans,#} -{# 'field': 'dirty',#} -{# 'orderField': paging.orderField,#} -{# 'orderDirection': paging.orderDirection,#} -{# 'paginationPath': paging.paginationPath,#} -{# } %}#} - - - - - {% for filter in paging.data %} - - - - -{# #} - - - {% endfor %} - -
{{ '#'|trans }}{{ 'Action'|trans }}
{{ loop.index }}{{ filter.name }}{{ filter.label }} -
- {% include '@EMSAdminUI/bootstrap5/elements/get-button.html.twig' with { - 'url': path('ems_filter_edit', {'filter': filter.id}), - 'label': 'Edit', - 'icon': 'pencil' - }%} - {% include '@EMSAdminUI/bootstrap5/elements/get-button.html.twig' with { - 'url': path('emsco_filter_export', {'filter': filter.id}), - 'label': 'Export', - 'icon': 'sign-out' - }%} - {% include '@EMSAdminUI/bootstrap5/elements/post-button.html.twig' with { - 'url': path('ems_filter_delete', {'filter': filter.id}), - 'message': 'Delete the filter ' ~ filter.name ~ ' ?', - 'label': 'Delete', - 'icon': 'trash' - }%} -
-
-
-
- -
-
-
- - -{% endblock %} diff --git a/EMS/core-bundle/src/Controller/ContentManagement/AnalyzerController.php b/EMS/core-bundle/src/Controller/ContentManagement/AnalyzerController.php index af4a1154d..e5eb080ae 100644 --- a/EMS/core-bundle/src/Controller/ContentManagement/AnalyzerController.php +++ b/EMS/core-bundle/src/Controller/ContentManagement/AnalyzerController.php @@ -1,13 +1,20 @@ render("@$this->templateNamespace/analyzer/index.html.twig", [ - 'paging' => $this->helperService->getPagingTool(Analyzer::class, 'ems_analyzer_index', 'name'), - ]); - } + $analyzer = new Analyzer(); - public function edit(Analyzer $analyzer, Request $request): Response - { $form = $this->createForm(AnalyzerType::class, $analyzer); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $analyzer = $form->getData(); - $this->analyzerRepository->update($analyzer); + $this->analyzerManager->update($analyzer); - $this->logger->notice('log.analyzer.updated', [ + $this->logger->notice('log.analyzer.created', [ 'analyzer_name' => $analyzer->getName(), 'analyzer_id' => $analyzer->getId(), - EmsFields::LOG_OPERATION_FIELD => EmsFields::LOG_OPERATION_UPDATE, + EmsFields::LOG_OPERATION_FIELD => EmsFields::LOG_OPERATION_CREATE, ]); - return $this->redirectToRoute('ems_analyzer_index', [ - ]); + return $this->redirectToRoute(Routes::ANALYZER_INDEX); } - return $this->render("@$this->templateNamespace/analyzer/edit.html.twig", [ - 'form' => $form->createView(), + return $this->render("@$this->templateNamespace/analyzer/add.html.twig", [ + 'form' => $form->createView(), ]); } public function delete(Analyzer $analyzer): RedirectResponse { - $id = $analyzer->getId(); - $name = $analyzer->getName(); - $this->analyzerRepository->delete($analyzer); + $this->analyzerManager->delete($analyzer); $this->logger->notice('log.analyzer.deleted', [ - 'analyzer_name' => $name, - 'analyzer_id' => $id, + 'analyzer_name' => $analyzer->getName(), + 'analyzer_id' => $analyzer->getId(), EmsFields::LOG_OPERATION_FIELD => EmsFields::LOG_OPERATION_DELETE, ]); - return $this->redirectToRoute('ems_analyzer_index', [ - ]); + return $this->redirectToRoute(Routes::ANALYZER_INDEX); } - public function add(Request $request): Response + public function edit(Analyzer $analyzer, Request $request): Response { - $analyzer = new Analyzer(); $form = $this->createForm(AnalyzerType::class, $analyzer); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $analyzer = $form->getData(); - if ($analyzer instanceof Analyzer) { - $this->analyzerRepository->update($analyzer); - - $this->logger->notice('log.analyzer.created', [ - 'analyzer_name' => $analyzer->getName(), - 'analyzer_id' => $analyzer->getId(), - EmsFields::LOG_OPERATION_FIELD => EmsFields::LOG_OPERATION_CREATE, - ]); - - return $this->redirectToRoute('ems_analyzer_index', [ - ]); - } + $this->analyzerManager->update($analyzer); + + $this->logger->notice('log.analyzer.updated', [ + 'analyzer_name' => $analyzer->getName(), + 'analyzer_id' => $analyzer->getId(), + EmsFields::LOG_OPERATION_FIELD => EmsFields::LOG_OPERATION_UPDATE, + ]); + + return $this->redirectToRoute(Routes::ANALYZER_INDEX); } - return $this->render("@$this->templateNamespace/analyzer/add.html.twig", [ - 'form' => $form->createView(), + return $this->render("@$this->templateNamespace/analyzer/edit.html.twig", [ + 'form' => $form->createView(), ]); } @@ -106,11 +100,43 @@ public function export(Analyzer $analyzer): Response $response = new JsonResponse($analyzer); $response->setEncodingOptions(JSON_PRETTY_PRINT); $disposition = $response->headers->makeDisposition( - ResponseHeaderBag::DISPOSITION_ATTACHMENT, - $analyzer->getName().'.json' + disposition: ResponseHeaderBag::DISPOSITION_ATTACHMENT, + filename: $analyzer->getName().'.json' ); $response->headers->set('Content-Disposition', $disposition); return $response; } + + public function index(Request $request): Response + { + $table = $this->dataTableFactory->create(AnalyzerDataTableType::class); + + $form = $this->createForm(TableType::class, $table, [ + 'reorder_label' => t('type.reorder', ['type' => 'analyzer'], 'emsco-core'), + ]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + match ($this->getClickedButtonName($form)) { + TableAbstract::DELETE_ACTION => $this->analyzerManager->deleteByIds(...$table->getSelected()), + TableType::REORDER_ACTION => $this->analyzerManager->reorderByIds( + ...TableType::getReorderedKeys($form->getName(), $request) + ), + default => $this->logger->messageError(t('log.error.invalid_table_action', [], 'emsco-core')) + }; + + return $this->redirectToRoute(Routes::ANALYZER_INDEX); + } + + return $this->render("@$this->templateNamespace/crud/overview.html.twig", [ + 'form' => $form->createView(), + 'icon' => 'fa fa-signal', + 'title' => t('type.title_overview', ['type' => 'analyzer'], 'emsco-core'), + 'breadcrumb' => [ + 'admin' => t('key.admin', [], 'emsco-core'), + 'page' => t('key.analyzers', [], 'emsco-core'), + ], + ]); + } } diff --git a/EMS/core-bundle/src/Controller/ContentManagement/FilterController.php b/EMS/core-bundle/src/Controller/ContentManagement/FilterController.php index fb0d6c598..be0f067aa 100644 --- a/EMS/core-bundle/src/Controller/ContentManagement/FilterController.php +++ b/EMS/core-bundle/src/Controller/ContentManagement/FilterController.php @@ -1,83 +1,77 @@ render("@$this->templateNamespace/filter/index.html.twig", [ - 'paging' => $this->helperService->getPagingTool(Filter::class, 'ems_filter_index', 'name'), - ]); - } - - public function editAction(Filter $filter, Request $request): Response + public function addAction(Request $request): Response { + $filter = new Filter(); $form = $this->createForm(FilterType::class, $filter); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $filter = $form->getData(); - $this->filterRepository->update($filter); + $this->filterManager->update($filter); - return $this->redirectToRoute('ems_filter_index', [ - ]); + return $this->redirectToRoute(Routes::FILTER_INDEX); } - return $this->render("@$this->templateNamespace/filter/edit.html.twig", [ - 'form' => $form->createView(), + return $this->render("@$this->templateNamespace/filter/add.html.twig", [ + 'form' => $form->createView(), ]); } public function deleteAction(Filter $filter): Response { - $name = $filter->getName(); - $this->filterRepository->delete($filter); - $this->logger->notice('log.filter.deleted', [ - 'filter_name' => $name, - ]); + $this->filterManager->delete($filter); + $this->logger->notice('log.filter.deleted', ['filter_name' => $filter->getName()]); - return $this->redirectToRoute('ems_filter_index', [ - ]); + return $this->redirectToRoute(Routes::FILTER_INDEX); } - public function addAction(Request $request): Response + public function editAction(Filter $filter, Request $request): Response { - $filter = new Filter(); $form = $this->createForm(FilterType::class, $filter); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $filter = $form->getData(); - $this->filterRepository->update($filter); + $this->filterManager->update($filter); - return $this->redirectToRoute('ems_filter_index', [ - ]); + return $this->redirectToRoute(Routes::FILTER_INDEX); } - return $this->render("@$this->templateNamespace/filter/add.html.twig", [ - 'form' => $form->createView(), + return $this->render("@$this->templateNamespace/filter/edit.html.twig", [ + 'form' => $form->createView(), ]); } @@ -86,11 +80,43 @@ public function export(Filter $filter): Response $response = new JsonResponse($filter); $response->setEncodingOptions(JSON_PRETTY_PRINT); $disposition = $response->headers->makeDisposition( - ResponseHeaderBag::DISPOSITION_ATTACHMENT, - $filter->getName().'.json' + disposition: ResponseHeaderBag::DISPOSITION_ATTACHMENT, + filename: $filter->getName().'.json' ); $response->headers->set('Content-Disposition', $disposition); return $response; } + + public function indexAction(Request $request): Response + { + $table = $this->dataTableFactory->create(FilterDataTableType::class); + + $form = $this->createForm(TableType::class, $table, [ + 'reorder_label' => t('type.reorder', ['type' => 'filter'], 'emsco-core'), + ]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + match ($this->getClickedButtonName($form)) { + TableAbstract::DELETE_ACTION => $this->filterManager->deleteByIds(...$table->getSelected()), + TableType::REORDER_ACTION => $this->filterManager->reorderByIds( + ...TableType::getReorderedKeys($form->getName(), $request) + ), + default => $this->logger->messageError(t('log.error.invalid_table_action', [], 'emsco-core')) + }; + + return $this->redirectToRoute(Routes::FILTER_INDEX); + } + + return $this->render("@$this->templateNamespace/crud/overview.html.twig", [ + 'form' => $form->createView(), + 'icon' => 'fa fa-filter', + 'title' => t('type.title_overview', ['type' => 'filter'], 'emsco-core'), + 'breadcrumb' => [ + 'admin' => t('key.admin', [], 'emsco-core'), + 'page' => t('key.filters', [], 'emsco-core'), + ], + ]); + } } diff --git a/EMS/core-bundle/src/Controller/TwigElementsController.php b/EMS/core-bundle/src/Controller/TwigElementsController.php index f7aa0bac6..08eb63c26 100644 --- a/EMS/core-bundle/src/Controller/TwigElementsController.php +++ b/EMS/core-bundle/src/Controller/TwigElementsController.php @@ -122,8 +122,8 @@ private function getAdminMenu(): Menu $jobMenu->addChild('views.elements.side-menu-html.create-job', 'fa fa-plus', 'job.add')->setTranslation([]); $jobMenu->addChild('views.elements.side-menu-html.logs', 'fa fa-file-text-o', 'job.index')->setTranslation([]); $jobMenu->addChild('views.elements.side-menu-html.schedule', 'fa fa-calendar-o', Routes::SCHEDULE_INDEX)->setTranslation([]); - $menu->addChild('views.elements.side-menu-html.analyzers', 'fa fa-signal', 'ems_analyzer_index')->setTranslation([]); - $menu->addChild('views.elements.side-menu-html.filters', 'fa fa-filter', 'ems_filter_index')->setTranslation([]); + $menu->addChild('views.elements.side-menu-html.analyzers', 'fa fa-signal', Routes::ANALYZER_INDEX)->setTranslation([]); + $menu->addChild('views.elements.side-menu-html.filters', 'fa fa-filter', Routes::FILTER_INDEX)->setTranslation([]); $menu->addChild('views.elements.side-menu-html.audit-logs', 'fa fa-file-text', Routes::LOG_INDEX)->setTranslation([]); $menu->addChild('views.elements.side-menu-html.uploaded-files-logs', 'fa fa-upload', Routes::UPLOAD_ASSET_ADMIN_OVERVIEW)->setTranslation([]); diff --git a/EMS/core-bundle/src/Core/Mapping/AnalyzerManager.php b/EMS/core-bundle/src/Core/Mapping/AnalyzerManager.php index 897378442..f926dc83b 100644 --- a/EMS/core-bundle/src/Core/Mapping/AnalyzerManager.php +++ b/EMS/core-bundle/src/Core/Mapping/AnalyzerManager.php @@ -1,5 +1,7 @@ analyzerRepository->makeQueryBuilder(searchValue: $searchValue) + ->select('count(a.id)') + ->getQuery() + ->getSingleScalarResult(); } - public function get(int $from, int $size, ?string $orderField, string $orderDirection, string $searchValue, $context = null): array + public function createEntityFromJson(string $json, ?string $name = null): EntityInterface { - return $this->analyzerRepository->get($from, $size, $orderField, $orderDirection, $searchValue); + $analyzer = Analyzer::fromJson($json); + if (null !== $name && $analyzer->getName() !== $name) { + throw new \RuntimeException(\sprintf('Analyzer name mismatched: %s vs %s', $analyzer->getName(), $name)); + } + $this->analyzerRepository->update($analyzer); + + return $analyzer; } - public function getEntityName(): string + public function delete(Analyzer $analyzer): void { - return 'analyzer'; + $this->analyzerRepository->delete($analyzer); + } + + public function deleteByIds(string ...$ids): void + { + $analyzers = $this->analyzerRepository->getByIds(...$ids); + foreach ($analyzers as $analyzer) { + $this->analyzerRepository->delete($analyzer); + } + } + + public function deleteByItemName(string $name): string + { + $analyzer = $this->analyzerRepository->findByName($name); + if (null === $analyzer) { + throw new \RuntimeException(\sprintf('Analyzer %s not found', $name)); + } + $id = $analyzer->getId(); + $this->analyzerRepository->delete($analyzer); + + return \strval($id); + } + + public function get(int $from, int $size, ?string $orderField, string $orderDirection, string $searchValue, $context = null): array + { + $qb = $this->analyzerRepository->makeQueryBuilder(searchValue: $searchValue); + $qb->setFirstResult($from)->setMaxResults($size); + + if (null !== $orderField) { + $qb->orderBy(\sprintf('a.%s', $orderField), $orderDirection); + } + + return $qb->getQuery()->execute(); } public function getAliasesName(): array @@ -41,44 +84,46 @@ public function getAliasesName(): array ]; } - public function count(string $searchValue = '', $context = null): int + public function getByItemName(string $name): ?EntityInterface { - return $this->analyzerRepository->counter($searchValue); + return $this->analyzerRepository->findByName($name); } - public function getByItemName(string $name): ?EntityInterface + public function getEntityName(): string { - return $this->analyzerRepository->findByName($name); + return 'analyzer'; } - public function updateEntityFromJson(EntityInterface $entity, string $json): EntityInterface + public function isSortable(): bool { - $analyzer = Analyzer::fromJson($json, $entity); - $this->analyzerRepository->update($analyzer); + return true; + } - return $analyzer; + public function reorderByIds(string ...$ids): void + { + $counter = 1; + + foreach ($ids as $id) { + $analyzer = $this->analyzerRepository->getById($id); + $analyzer->setOrderKey($counter++); + $this->analyzerRepository->update($analyzer); + } } - public function createEntityFromJson(string $json, ?string $name = null): EntityInterface + public function update(Analyzer $analyzer): void { - $analyzer = Analyzer::fromJson($json); - if (null !== $name && $analyzer->getName() !== $name) { - throw new \RuntimeException(\sprintf('Analyzer name mismatched: %s vs %s', $analyzer->getName(), $name)); + if (0 === $analyzer->getOrderKey()) { + $analyzer->setOrderKey($this->count() + 1); } - $this->analyzerRepository->update($analyzer); - return $analyzer; + $this->analyzerRepository->update($analyzer); } - public function deleteByItemName(string $name): string + public function updateEntityFromJson(EntityInterface $entity, string $json): EntityInterface { - $analyzer = $this->analyzerRepository->findByName($name); - if (null === $analyzer) { - throw new \RuntimeException(\sprintf('Analyzer %s not found', $name)); - } - $id = $analyzer->getId(); - $this->analyzerRepository->delete($analyzer); + $analyzer = Analyzer::fromJson($json, $entity); + $this->analyzerRepository->update($analyzer); - return \strval($id); + return $analyzer; } } diff --git a/EMS/core-bundle/src/Core/Mapping/FilterManager.php b/EMS/core-bundle/src/Core/Mapping/FilterManager.php index 421c5ea17..61c1d0c36 100644 --- a/EMS/core-bundle/src/Core/Mapping/FilterManager.php +++ b/EMS/core-bundle/src/Core/Mapping/FilterManager.php @@ -1,5 +1,7 @@ filterRepository->makeQueryBuilder(searchValue: $searchValue) + ->select('count(f.id)') + ->getQuery() + ->getSingleScalarResult(); } - public function get(int $from, int $size, ?string $orderField, string $orderDirection, string $searchValue, $context = null): array + public function createEntityFromJson(string $json, ?string $name = null): EntityInterface { - return $this->filterRepository->get($from, $size, $orderField, $orderDirection, $searchValue); + $filter = Filter::fromJson($json); + if (null !== $name && $filter->getName() !== $name) { + throw new \RuntimeException(\sprintf('Filter name mismatched: %s vs %s', $filter->getName(), $name)); + } + $this->filterRepository->update($filter); + + return $filter; } - public function getEntityName(): string + public function delete(Filter $filter): void { - return 'filter'; + $this->filterRepository->delete($filter); + } + + public function deleteByIds(string ...$ids): void + { + $filters = $this->filterRepository->getByIds(...$ids); + foreach ($filters as $filter) { + $this->filterRepository->delete($filter); + } + } + + public function deleteByItemName(string $name): string + { + $filter = $this->filterRepository->findByName($name); + if (null === $filter) { + throw new \RuntimeException(\sprintf('Filter %s not found', $name)); + } + $id = $filter->getId(); + $this->filterRepository->delete($filter); + + return \strval($id); + } + + public function get(int $from, int $size, ?string $orderField, string $orderDirection, string $searchValue, $context = null): array + { + $qb = $this->filterRepository->makeQueryBuilder(searchValue: $searchValue); + $qb->setFirstResult($from)->setMaxResults($size); + + if (null !== $orderField) { + $qb->orderBy(\sprintf('f.%s', $orderField), $orderDirection); + } + + return $qb->getQuery()->execute(); } public function getAliasesName(): array @@ -37,44 +80,46 @@ public function getAliasesName(): array ]; } - public function count(string $searchValue = '', $context = null): int + public function getByItemName(string $name): ?EntityInterface { - return $this->filterRepository->counter($searchValue); + return $this->filterRepository->findByName($name); } - public function getByItemName(string $name): ?EntityInterface + public function getEntityName(): string { - return $this->filterRepository->findByName($name); + return 'filter'; } - public function updateEntityFromJson(EntityInterface $entity, string $json): EntityInterface + public function isSortable(): bool { - $filter = Filter::fromJson($json, $entity); - $this->filterRepository->update($filter); + return true; + } - return $filter; + public function reorderByIds(string ...$ids): void + { + $counter = 1; + + foreach ($ids as $id) { + $filter = $this->filterRepository->getById($id); + $filter->setOrderKey($counter++); + $this->filterRepository->update($filter); + } } - public function createEntityFromJson(string $json, ?string $name = null): EntityInterface + public function update(Filter $filter): void { - $filter = Filter::fromJson($json); - if (null !== $name && $filter->getName() !== $name) { - throw new \RuntimeException(\sprintf('Filter name mismatched: %s vs %s', $filter->getName(), $name)); + if (0 === $filter->getOrderKey()) { + $filter->setOrderKey($this->count() + 1); } - $this->filterRepository->update($filter); - return $filter; + $this->filterRepository->update($filter); } - public function deleteByItemName(string $name): string + public function updateEntityFromJson(EntityInterface $entity, string $json): EntityInterface { - $filter = $this->filterRepository->findByName($name); - if (null === $filter) { - throw new \RuntimeException(\sprintf('Filter %s not found', $name)); - } - $id = $filter->getId(); - $this->filterRepository->delete($filter); + $filter = Filter::fromJson($json, $entity); + $this->filterRepository->update($filter); - return \strval($id); + return $filter; } } diff --git a/EMS/core-bundle/src/DataTable/Type/DataTableTypeTrait.php b/EMS/core-bundle/src/DataTable/Type/DataTableTypeTrait.php new file mode 100644 index 000000000..778d3e23f --- /dev/null +++ b/EMS/core-bundle/src/DataTable/Type/DataTableTypeTrait.php @@ -0,0 +1,23 @@ +setDefaultOrder('orderKey') + ->setLabelAttribute('label'); + + $table->addColumn(t('key.loop_count', [], 'emsco-core'), 'orderKey'); + $table->addColumn(t('field.label', [], 'emsco-core'), 'label'); + $table->addColumn(t('field.name', [], 'emsco-core'), 'name'); + } +} diff --git a/EMS/core-bundle/src/DataTable/Type/Mapping/AnalyzerDataTableType.php b/EMS/core-bundle/src/DataTable/Type/Mapping/AnalyzerDataTableType.php new file mode 100644 index 000000000..e58b50415 --- /dev/null +++ b/EMS/core-bundle/src/DataTable/Type/Mapping/AnalyzerDataTableType.php @@ -0,0 +1,64 @@ +addColumnsOrderLabelName($table); + + $table->addItemGetAction( + route: Routes::ANALYZER_EDIT, + labelKey: t('action.edit', [], 'emsco-core'), + icon: 'pencil' + ); + $table->addItemGetAction( + route: Routes::ANALYZER_EXPORT, + labelKey: t('action.export', [], 'emsco-core'), + icon: 'sign-out' + ); + $table->addItemPostAction( + route: Routes::ANALYZER_DELETE, + labelKey: t('action.delete', [], 'emsco-core'), + icon: 'trash', + messageKey: t('type.delete_confirm', ['type' => 'analyzer'], 'emsco-core') + )->setButtonType('outline-danger'); + + $table->addToolbarAction( + label: t('action.add', [], 'emsco-core'), + icon: 'fa fa-plus', + routeName: Routes::ANALYZER_ADD + ); + $table->addTableAction( + name: TableAbstract::DELETE_ACTION, + icon: 'fa fa-trash', + labelKey: t('action.delete_selected', [], 'emsco-core'), + confirmationKey: t('type.delete_selected_confirm', ['type' => 'analyzer'], 'emsco-core') + )->setCssClass('btn btn-outline-danger'); + } + + public function getRoles(): array + { + return [Roles::ROLE_ADMIN]; + } +} diff --git a/EMS/core-bundle/src/DataTable/Type/Mapping/FilterDataTableType.php b/EMS/core-bundle/src/DataTable/Type/Mapping/FilterDataTableType.php new file mode 100644 index 000000000..c43438cf1 --- /dev/null +++ b/EMS/core-bundle/src/DataTable/Type/Mapping/FilterDataTableType.php @@ -0,0 +1,64 @@ +addColumnsOrderLabelName($table); + + $table->addItemGetAction( + route: Routes::FILTER_EDIT, + labelKey: t('action.edit', [], 'emsco-core'), + icon: 'pencil' + ); + $table->addItemGetAction( + route: Routes::FILTER_EXPORT, + labelKey: t('action.export', [], 'emsco-core'), + icon: 'sign-out' + ); + $table->addItemPostAction( + route: Routes::FILTER_DELETE, + labelKey: t('action.delete', [], 'emsco-core'), + icon: 'trash', + messageKey: t('type.delete_confirm', ['type' => 'filter'], 'emsco-core') + )->setButtonType('outline-danger'); + + $table->addToolbarAction( + label: t('action.add', [], 'emsco-core'), + icon: 'fa fa-plus', + routeName: Routes::FILTER_ADD + ); + $table->addTableAction( + name: TableAbstract::DELETE_ACTION, + icon: 'fa fa-trash', + labelKey: t('action.delete_selected', [], 'emsco-core'), + confirmationKey: t('type.delete_selected_confirm', ['type' => 'filter'], 'emsco-core') + )->setCssClass('btn btn-outline-danger'); + } + + public function getRoles(): array + { + return [Roles::ROLE_ADMIN]; + } +} diff --git a/EMS/core-bundle/src/Entity/Analyzer.php b/EMS/core-bundle/src/Entity/Analyzer.php index b76e36d9e..e4b3da0a6 100644 --- a/EMS/core-bundle/src/Entity/Analyzer.php +++ b/EMS/core-bundle/src/Entity/Analyzer.php @@ -63,7 +63,7 @@ class Analyzer extends JsonDeserializer implements \JsonSerializable, EntityInte * * @ORM\Column(name="order_key", type="integer", nullable=true) */ - protected $orderKey; + protected $orderKey = 0; public function __construct() { diff --git a/EMS/core-bundle/src/Entity/Filter.php b/EMS/core-bundle/src/Entity/Filter.php index ebee339d3..ad16c7aad 100644 --- a/EMS/core-bundle/src/Entity/Filter.php +++ b/EMS/core-bundle/src/Entity/Filter.php @@ -61,7 +61,7 @@ class Filter extends JsonDeserializer implements \JsonSerializable, EntityInterf * * @ORM\Column(name="order_key", type="integer", nullable=true) */ - protected $orderKey; + protected $orderKey = 0; public function __construct() { diff --git a/EMS/core-bundle/src/Repository/AnalyzerRepository.php b/EMS/core-bundle/src/Repository/AnalyzerRepository.php index 5fb41afbc..ca82982aa 100644 --- a/EMS/core-bundle/src/Repository/AnalyzerRepository.php +++ b/EMS/core-bundle/src/Repository/AnalyzerRepository.php @@ -1,5 +1,7 @@ findOneBy(['name' => $name]); - } - - public function update(Analyzer $analyzer): void + public function delete(Analyzer $analyzer): void { - $this->getEntityManager()->persist($analyzer); + $this->getEntityManager()->remove($analyzer); $this->getEntityManager()->flush(); } /** * @return Analyzer[] */ - public function findAll() + public function findAll(): array { return $this->findBy([], ['orderKey' => 'asc']); } - /** - * @return Analyzer[] - */ - public function get(int $from, int $size, ?string $orderField, string $orderDirection, string $searchValue): array + public function findByName(string $name): ?Analyzer { - $qb = $this->createQueryBuilder('analyzer') - ->setFirstResult($from) - ->setMaxResults($size); - $this->addSearchFilters($qb, $searchValue); + return $this->findOneBy(['name' => $name]); + } - if (\in_array($orderField, ['label', 'name'])) { - $qb->orderBy(\sprintf('analyzer.%s', $orderField), $orderDirection); - } else { - $qb->orderBy('analyzer.orderKey', $orderDirection); + public function getById(string $id): Analyzer + { + if (null === $analyzer = $this->find($id)) { + throw new \RuntimeException('Analyzer not found'); } - return $qb->getQuery()->execute(); + return $analyzer; } - public function counter(string $searchValue = ''): int + /** + * @return Analyzer[] + */ + public function getByIds(string ...$ids): array { - $qb = $this->createQueryBuilder('analyzer'); - $qb->select('count(analyzer.id)'); - $this->addSearchFilters($qb, $searchValue); + $qb = $this->createQueryBuilder('a'); + $qb + ->andWhere($qb->expr()->in('a.id', ':ids')) + ->setParameter('ids', $ids); - return \intval($qb->getQuery()->getSingleScalarResult()); + return $qb->getQuery()->getResult(); } - public function delete(Analyzer $analyzer): void + public function makeQueryBuilder(string $searchValue = ''): QueryBuilder { - $this->getEntityManager()->remove($analyzer); - $this->getEntityManager()->flush(); + $qb = $this->createQueryBuilder('a'); + + if ('' !== $searchValue) { + $qb + ->andWhere($qb->expr()->orX( + $qb->expr()->like('a.label', ':term'), + $qb->expr()->like('a.name', ':term'), + )) + ->setParameter(':term', '%'.\strtolower($searchValue).'%'); + } + + return $qb; } - private function addSearchFilters(QueryBuilder $qb, string $searchValue): void + public function update(Analyzer $analyzer): void { - if (\strlen($searchValue) > 0) { - $or = $qb->expr()->orX( - $qb->expr()->like('analyzer.label', ':term'), - $qb->expr()->like('analyzer.name', ':term'), - ); - $qb->andWhere($or) - ->setParameter(':term', '%'.$searchValue.'%'); - } + $this->getEntityManager()->persist($analyzer); + $this->getEntityManager()->flush(); } } diff --git a/EMS/core-bundle/src/Repository/FilterRepository.php b/EMS/core-bundle/src/Repository/FilterRepository.php index 8f45db0d9..3a58dc923 100644 --- a/EMS/core-bundle/src/Repository/FilterRepository.php +++ b/EMS/core-bundle/src/Repository/FilterRepository.php @@ -21,60 +21,58 @@ public function __construct(Registry $registry) parent::__construct($registry, Filter::class); } + public function delete(Filter $filter): void + { + $this->getEntityManager()->remove($filter); + $this->getEntityManager()->flush(); + } + public function findByName(string $name): ?Filter { return $this->findOneBy(['name' => $name]); } - public function update(Filter $filter): void + public function getById(string $id): Filter { - $this->getEntityManager()->persist($filter); - $this->getEntityManager()->flush(); + if (null === $filter = $this->find($id)) { + throw new \RuntimeException('Filter not found'); + } + + return $filter; } /** * @return Filter[] */ - public function get(int $from, int $size, ?string $orderField, string $orderDirection, string $searchValue): array + public function getByIds(string ...$ids): array { - $qb = $this->createQueryBuilder('filter') - ->setFirstResult($from) - ->setMaxResults($size); - $this->addSearchFilters($qb, $searchValue); + $qb = $this->createQueryBuilder('f'); + $qb + ->andWhere($qb->expr()->in('f.id', ':ids')) + ->setParameter('ids', $ids); - if (\in_array($orderField, ['label', 'name'])) { - $qb->orderBy(\sprintf('filter.%s', $orderField), $orderDirection); - } else { - $qb->orderBy('filter.orderKey', $orderDirection); - } - - return $qb->getQuery()->execute(); + return $qb->getQuery()->getResult(); } - public function counter(string $searchValue = ''): int + public function makeQueryBuilder(string $searchValue = ''): QueryBuilder { - $qb = $this->createQueryBuilder('filter'); - $qb->select('count(filter.id)'); - $this->addSearchFilters($qb, $searchValue); + $qb = $this->createQueryBuilder('f'); - return \intval($qb->getQuery()->getSingleScalarResult()); - } + if ('' !== $searchValue) { + $qb + ->andWhere($qb->expr()->orX( + $qb->expr()->like('f.label', ':term'), + $qb->expr()->like('f.name', ':term'), + )) + ->setParameter(':term', '%'.\strtolower($searchValue).'%'); + } - public function delete(Filter $filter): void - { - $this->getEntityManager()->remove($filter); - $this->getEntityManager()->flush(); + return $qb; } - private function addSearchFilters(QueryBuilder $qb, string $searchValue): void + public function update(Filter $filter): void { - if (\strlen($searchValue) > 0) { - $or = $qb->expr()->orX( - $qb->expr()->like('filter.label', ':term'), - $qb->expr()->like('filter.name', ':term'), - ); - $qb->andWhere($or) - ->setParameter(':term', '%'.$searchValue.'%'); - } + $this->getEntityManager()->persist($filter); + $this->getEntityManager()->flush(); } } diff --git a/EMS/core-bundle/src/Resources/config/controllers.xml b/EMS/core-bundle/src/Resources/config/controllers.xml index a1de23f16..81356deae 100644 --- a/EMS/core-bundle/src/Resources/config/controllers.xml +++ b/EMS/core-bundle/src/Resources/config/controllers.xml @@ -81,9 +81,9 @@ + + - - %ems_core.template_namespace% @@ -184,9 +184,9 @@ + + - - %ems_core.template_namespace% diff --git a/EMS/core-bundle/src/Resources/config/datatable.xml b/EMS/core-bundle/src/Resources/config/datatable.xml index c1911e50d..a923e0bc1 100644 --- a/EMS/core-bundle/src/Resources/config/datatable.xml +++ b/EMS/core-bundle/src/Resources/config/datatable.xml @@ -18,6 +18,14 @@ %ems_core.template_namespace% + + + + + + + + diff --git a/EMS/core-bundle/src/Resources/config/routing/analyzer.xml b/EMS/core-bundle/src/Resources/config/routing/admin/analyzer.xml similarity index 78% rename from EMS/core-bundle/src/Resources/config/routing/analyzer.xml rename to EMS/core-bundle/src/Resources/config/routing/admin/analyzer.xml index 65aa26fbd..8748e994f 100644 --- a/EMS/core-bundle/src/Resources/config/routing/analyzer.xml +++ b/EMS/core-bundle/src/Resources/config/routing/admin/analyzer.xml @@ -4,16 +4,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd"> - - + - - - - + - - - + + - {{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/core-bundle/src/Resources/views/analyzer/edit.html.twig b/EMS/core-bundle/src/Resources/views/analyzer/edit.html.twig index edd742fd5..f9414d438 100644 --- a/EMS/core-bundle/src/Resources/views/analyzer/edit.html.twig +++ b/EMS/core-bundle/src/Resources/views/analyzer/edit.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/core-bundle/src/Resources/views/analyzer/index.html.twig b/EMS/core-bundle/src/Resources/views/analyzer/index.html.twig deleted file mode 100644 index d11c5623c..000000000 --- a/EMS/core-bundle/src/Resources/views/analyzer/index.html.twig +++ /dev/null @@ -1,109 +0,0 @@ -{% extends '@EMSCore/base.html.twig' %} -{% trans_default_domain 'EMSCoreBundle' %} - -{% block title %}{{ 'Analyzers'|trans }}{% endblock %} -{% block pagetitle %}{{ 'Analyzers'|trans }}{% endblock %} -{% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} - -{% block breadcrumb %} - -{% endblock %} - - -{% block body %} - -
-
-
-
- -

{{ 'Analyzers'|trans }}

- - {{ 'Add analyzer'|trans }} - -
- -
- {% if paging.lastPage > 1 %} -
- {% include '@EMSCore/elements/pagination.html.twig' with { - 'paging': paging, - 'currentFilters': app.request.query, - 'paginationPath': paginationPath, - 'showAlwaysFirstAndLast': false - } %} -
- {% endif %} - -
- - - - - {% include '@EMSCore/elements/sortable-th.html.twig' with { - 'title': 'Name'|trans, - 'field': 'name', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {% include '@EMSCore/elements/sortable-th.html.twig' with { - 'title': 'Label'|trans, - 'field': 'label', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {# {% include '@EMSCore/elements/sortable-th.html.twig' with {#} -{# 'title': 'Dirty'|trans,#} -{# 'field': 'dirty',#} -{# 'orderField': paging.orderField,#} -{# 'orderDirection': paging.orderDirection,#} -{# 'paginationPath': paging.paginationPath,#} -{# } %}#} - - - - - {% for analyzer in paging.data %} - - - - -{# #} - - - {% endfor %} - -
{{ '#'|trans }}{{ 'Action'|trans }}
{{ loop.index }}{{ analyzer.name }}{{ analyzer.label }} -
- {% include '@EMSCore/elements/get-button.html.twig' with { - 'url': path('ems_analyzer_edit', {'analyzer': analyzer.id}), - 'label': 'Edit', - 'icon': 'pencil' - }%} - {% include '@EMSCore/elements/get-button.html.twig' with { - 'url': path('emsco_analyzer_export', {'analyzer': analyzer.id}), - 'label': 'Export', - 'icon': 'sign-out' - }%} - {% include '@EMSCore/elements/post-button.html.twig' with { - 'url': path('ems_analyzer_delete', {'analyzer': analyzer.id}), - 'message': 'Delete the analyzer ' ~ analyzer.name ~ ' ?', - 'label': 'Delete', - 'icon': 'trash' - }%} -
-
-
-
- -
-
-
- - -{% endblock %} \ No newline at end of file diff --git a/EMS/core-bundle/src/Resources/views/filter/add.html.twig b/EMS/core-bundle/src/Resources/views/filter/add.html.twig index 0d2c3f28d..31256cfd6 100644 --- a/EMS/core-bundle/src/Resources/views/filter/add.html.twig +++ b/EMS/core-bundle/src/Resources/views/filter/add.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/core-bundle/src/Resources/views/filter/edit.html.twig b/EMS/core-bundle/src/Resources/views/filter/edit.html.twig index 30b4fd73c..7c3e18ace 100644 --- a/EMS/core-bundle/src/Resources/views/filter/edit.html.twig +++ b/EMS/core-bundle/src/Resources/views/filter/edit.html.twig @@ -6,7 +6,7 @@ {% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} {% block breadcrumb %} {% endblock %} diff --git a/EMS/core-bundle/src/Resources/views/filter/index.html.twig b/EMS/core-bundle/src/Resources/views/filter/index.html.twig deleted file mode 100644 index bb17bdbd8..000000000 --- a/EMS/core-bundle/src/Resources/views/filter/index.html.twig +++ /dev/null @@ -1,109 +0,0 @@ -{% extends '@EMSCore/base.html.twig' %} -{% trans_default_domain 'EMSCoreBundle' %} - -{% block title %}{{ 'Filters'|trans }}{% endblock %} -{% block pagetitle %}{{ 'Filters'|trans }}{% endblock %} -{% block subtitle %}{{ 'expert mode'|trans }}{% endblock %} - -{% block breadcrumb %} - -{% endblock %} - - -{% block body %} - -
-
-
-
- -

{{ 'Filters'|trans }}

- - {{ 'Add a Filter'|trans }} - -
- -
- {% if paging.lastPage > 1 %} -
- {% include '@EMSCore/elements/pagination.html.twig' with { - 'paging': paging, - 'currentFilters': app.request.query, - 'paginationPath': paginationPath, - 'showAlwaysFirstAndLast': false - } %} -
- {% endif %} - -
- - - - - {% include '@EMSCore/elements/sortable-th.html.twig' with { - 'title': 'Name'|trans, - 'field': 'name', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {% include '@EMSCore/elements/sortable-th.html.twig' with { - 'title': 'Label'|trans, - 'field': 'label', - 'orderField': paging.orderField, - 'orderDirection': paging.orderDirection, - 'paginationPath': paging.paginationPath, - } %} - {# {% include '@EMSCore/elements/sortable-th.html.twig' with {#} -{# 'title': 'Dirty'|trans,#} -{# 'field': 'dirty',#} -{# 'orderField': paging.orderField,#} -{# 'orderDirection': paging.orderDirection,#} -{# 'paginationPath': paging.paginationPath,#} -{# } %}#} - - - - - {% for filter in paging.data %} - - - - -{# #} - - - {% endfor %} - -
{{ '#'|trans }}{{ 'Action'|trans }}
{{ loop.index }}{{ filter.name }}{{ filter.label }} -
- {% include '@EMSCore/elements/get-button.html.twig' with { - 'url': path('ems_filter_edit', {'filter': filter.id}), - 'label': 'Edit', - 'icon': 'pencil' - }%} - {% include '@EMSCore/elements/get-button.html.twig' with { - 'url': path('emsco_filter_export', {'filter': filter.id}), - 'label': 'Export', - 'icon': 'sign-out' - }%} - {% include '@EMSCore/elements/post-button.html.twig' with { - 'url': path('ems_filter_delete', {'filter': filter.id}), - 'message': 'Delete the filter ' ~ filter.name ~ ' ?', - 'label': 'Delete', - 'icon': 'trash' - }%} -
-
-
-
- -
-
-
- - -{% endblock %} \ No newline at end of file diff --git a/EMS/core-bundle/src/Routes.php b/EMS/core-bundle/src/Routes.php index f87320571..0160187ef 100644 --- a/EMS/core-bundle/src/Routes.php +++ b/EMS/core-bundle/src/Routes.php @@ -22,6 +22,16 @@ class Routes final public const DASHBOARD_ADMIN_UNDEFINE = 'emsco_dashboard_admin_undefine'; final public const DASHBOARD = 'emsco_dashboard'; final public const DASHBOARD_HOME = 'emsco_dashboard_home'; + final public const ANALYZER_INDEX = 'emsco_analyzer_index'; + final public const ANALYZER_EDIT = 'emsco_analyzer_edit'; + final public const ANALYZER_DELETE = 'emsco_analyzer_delete'; + final public const ANALYZER_ADD = 'emsco_analyzer_add'; + final public const ANALYZER_EXPORT = 'emsco_analyzer_export'; + final public const FILTER_INDEX = 'emsco_filter_index'; + final public const FILTER_EDIT = 'emsco_filter_edit'; + final public const FILTER_DELETE = 'emsco_filter_delete'; + final public const FILTER_ADD = 'emsco_filter_add'; + final public const FILTER_EXPORT = 'emsco_filter_export'; final public const FORM_ADMIN_INDEX = 'emsco_form_admin_index'; final public const FORM_ADMIN_ADD = 'emsco_form_admin_add'; final public const FORM_ADMIN_EDIT = 'emsco_form_admin_edit';