Skip to content

Commit 257cbf0

Browse files
committed
4410: Cleaned up report views
1 parent 09d4cda commit 257cbf0

4 files changed

Lines changed: 95 additions & 59 deletions

File tree

.markdownlintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ LICENSE.md
66
web/*.md
77
web/core/
88
web/*/contrib/
9+
10+
# Project ignores
11+
mappings.md
12+
templates/svg/font-awesome-info.md

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ See [keep a changelog] for information about writing changes to this log.
1010

1111
* [PR-33](https://github.com/itk-dev/sysstatus/pull/33)
1212
* Inlined actions
13+
* Cleaned up report views
1314
* [PR-32](https://github.com/itk-dev/sysstatus/pull/32)
1415
3644: Cleaned up template and controller
1516
* [PR-31](https://github.com/itk-dev/sysstatus/pull/31)

src/Controller/Admin/ReportCrudController.php

Lines changed: 85 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Controller\Admin;
44

55
use App\Entity\Report;
6+
use App\Entity\UserGroup;
7+
use Doctrine\Common\Collections\Collection;
68
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
79
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
810
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
@@ -12,8 +14,10 @@
1214
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
1315
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
1416
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
17+
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
1518
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
1619
use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField;
20+
use Symfony\Component\Translation\TranslatableMessage;
1721

1822
class ReportCrudController extends AbstractCrudController
1923
{
@@ -36,68 +40,90 @@ public function configureActions(Actions $actions): Actions
3640
#[\Override]
3741
public function configureFields(string $pageName): iterable
3842
{
39-
$title = TextField::new('sys_title')->setLabel('entity.report.sys_title');
40-
$title2 = $title->setFormTypeOption('disabled', 'disabled');
41-
$internalId = IdField::new('sys_internal_id')->setLabel('entity.report.sys_internal_id');
42-
$edocUrl = UrlField::new('edoc_url')->setLabel('entity.report.edoc_url');
43-
$sys_link = UrlField::new('sys_link')->setLabel('entity.report.sys_link');
44-
$name = TextField::new('name')->setLabel('entity.report.name');
45-
$text = TextField::new('text')->setLabel('entity.report.text');
46-
$systemOwner = TextField::new('sys_system_owner')->setLabel('entity.report.sys_system_owner');
47-
$groups = AssociationField::new('groups')->setLabel('entity.report.groups');
43+
switch ($pageName) {
44+
case Crud::PAGE_INDEX:
45+
// Cf. https://github.com/itk-dev/sysstatus/blob/5383a3a566ce316c338441ed826ecf3fdcf98815/src/Controller/AdminController.php#L263-L288
46+
yield IdField::new('id')->setLabel('entity.report.sys_id');
47+
yield TextField::new('sysTitle')->setLabel('entity.report.sys_title');
48+
yield AssociationField::new('groups')->setLabel('entity.report.groups')
49+
->formatValue(static fn (Collection $groups) => implode(', ', array_map(
50+
static fn (UserGroup $group) => $group->getName(),
51+
$groups->toArray()
52+
)));
53+
yield TextField::new('sysOwnerSub')->setLabel('entity.report.sys_owner_sub');
54+
yield TextField::new('sysSystemOwner')->setLabel('entity.report.sys_system_owner');
55+
yield UrlField::new('sysLink')->setLabel('entity.report.sys_id')->setLabel('entity.report.sys_link')
56+
->formatValue(static fn ($value) => new TranslatableMessage('Link'));
57+
yield BooleanField::new('textSet')->setLabel('entity.report.text')
58+
->renderAsSwitch(false);
4859

49-
$answerarea = CollectionField::new('answerarea')->setTemplatePath('easy_admin_overrides/answers_show.html.twig')->setLabel('Smileys');
50-
$answerarea = CollectionField::new('answerarea')->setTemplatePath('easy_admin_overrides/answers_show.html.twig')->setLabel('Smileys');
60+
return;
5161

52-
$alternativeTitle = TextField::new('sys_alternative_title')->setLabel('entity.report.sys_alternative_title');
53-
$sys_updated = DateTimeField::new('sys_updated')->setLabel('entity.report.sys_updated');
54-
$owner = TextField::new('sys_owner')->setLabel('entity.report.sys_owner');
55-
$afdeling = TextField::new('sys_owner_sub')->setLabel('entity.report.sys_owner');
56-
$confidentialInformation = BooleanField::new('sys_confidential_information')->setLabel('entity.report.sys_confidential_information');
57-
$purpose = TextField::new('sys_purpose')->setLabel('entity.report.sys_purpose');
58-
$classification = TextField::new('sys_classification')->setLabel('entity.report.sys_classification');
59-
$dateForRevision = DateTimeField::new('sys_date_for_revision')->setLabel('entity.report.sys_date_for_revision');
60-
$persons = TextField::new('sys_persons')->setLabel('entity.report.sys_persons');
61-
$informationTypes = TextField::new('sys_information_types')->setLabel('entity.report.sys_information_types');
62-
$dataSentTo = TextField::new('sys_data_sent_to')->setLabel('entity.report.sys_data_sent_to');
63-
$dataComeFrom = TextField::new('sys_data_come_from')->setLabel('entity.report.sys_data_come_from');
64-
$dataLocation = TextField::new('sys_data_location')->setLabel('entity.report.sys_data_location');
65-
$deletionDate = TextField::new('sys_latest_deletion_date')->setLabel('entity.report.sys_latest_deletion_date');
66-
$dataWorthSaving = TextField::new('sys_data_worth_saving')->setLabel('entity.report.sys_data_worth_saving');
67-
$dataProcessors = TextField::new('sys_data_processors')->setLabel('entity.report.sys_data_processors');
68-
$dataProcessingAgreement = TextField::new('sys_data_processing_agreement')->setLabel('entity.report.sys_data_processing_agreement');
69-
$dataProcessingAgreementLink = TextField::new('sys_data_processing_agreement_link')->setLabel('entity.report.sys_data_processing_agreement_link');
70-
$auditorStatement = TextField::new('sys_auditor_statement')->setLabel('entity.report.sys_auditor_statement');
71-
$auditorStatementLink = TextField::new('sys_auditor_statement_link')->setLabel('entity.report.sys_auditor_statement_link');
72-
$dataToScience = TextField::new('sys_data_to_science')->setLabel('entity.report.sys_data_to_science');
73-
$usage = TextField::new('sys_usage')->setLabel('entity.report.sys_usage');
74-
$requestForInsight = TextField::new('sys_request_for_insight')->setLabel('entity.report.sys_request_for_insight');
75-
$dateUse = DateTimeField::new('sys_date_use')->setLabel('entity.report.sys_date_use');
76-
$status = TextField::new('sys_status')->setLabel('entity.report.sys_status');
77-
$remarks = TextField::new('sys_remarks')->setLabel('entity.report.sys_remarks');
78-
$internalInformation = TextField::new('sys_internal_information')->setLabel('entity.report.sys_internal_information');
79-
$obligationToInform = TextField::new('sys_obligation_to_inform')->setLabel('entity.report.sys_obligation_to_inform');
80-
$legalBasis = TextField::new('sys_legal_basis')->setLabel('entity.report.sys_legal_basis');
81-
$consent = TextField::new('sys_consent')->setLabel('entity.report.sys_consent');
82-
$impactAnalysis = TextField::new('sys_impact_analysis')->setLabel('entity.report.sys_impact_analysis');
83-
$impactAnalysisLink = TextField::new('sys_impact_analysis_link')->setLabel('entity.report.sys_impact_analysis_link');
84-
$authorizationProcedure = TextField::new('sys_authorization_procedure')->setLabel('entity.report.sys_authorization_procedure');
85-
$version = TextField::new('sys_version')->setLabel('entity.report.sys_version');
62+
case Crud::PAGE_DETAIL:
63+
// Cf. https://github.com/itk-dev/sysstatus/blob/5383a3a566ce316c338441ed826ecf3fdcf98815/config/packages/easy_admin.yaml#L100-L143
64+
yield TextField::new('sysTitle')->setLabel('entity.report.sys_title');
65+
yield IdField::new('sysInternalId')->setLabel('entity.report.sys_internal_id');
66+
yield UrlField::new('eDocUrl')->setLabel('entity.report.edoc_url');
67+
yield UrlField::new('sysLink')->setLabel('entity.report.sys_link');
68+
yield TextField::new('name')->setLabel('entity.report.name');
69+
// @toto Show raw value
70+
yield TextEditorField::new('text')->setLabel('entity.report.text')
71+
->setTemplatePath('admin/text_editor.raw.html.twig')
72+
;
73+
yield TextField::new('sys_system_owner')->setLabel('entity.report.sys_system_owner');
74+
// @todo Add links to each group
75+
yield AssociationField::new('groups')->setLabel('entity.report.groups');
76+
yield CollectionField::new('answerarea')->setTemplatePath('easy_admin_overrides/answers_show.html.twig')->setLabel('entity.report.answers');
77+
yield TextField::new('sys_alternative_title')->setLabel('entity.report.sys_alternative_title');
78+
yield DateTimeField::new('sys_updated')->setLabel('entity.report.sys_updated');
79+
yield TextField::new('sys_owner')->setLabel('entity.report.sys_owner');
80+
yield BooleanField::new('sys_confidential_information')->setLabel('entity.report.sys_confidential_information');
81+
yield TextField::new('sys_purpose')->setLabel('entity.report.sys_purpose');
82+
yield TextField::new('sys_classification')->setLabel('entity.report.sys_classification');
83+
yield DateTimeField::new('sys_date_for_revision')->setLabel('entity.report.sys_date_for_revision');
84+
yield TextField::new('sys_persons')->setLabel('entity.report.sys_persons');
85+
yield TextField::new('sys_information_types')->setLabel('entity.report.sys_information_types');
86+
yield TextField::new('sys_data_sent_to')->setLabel('entity.report.sys_data_sent_to');
87+
yield TextField::new('sys_data_come_from')->setLabel('entity.report.sys_data_come_from');
88+
yield TextField::new('sys_data_location')->setLabel('entity.report.sys_data_location');
89+
yield TextField::new('sys_latest_deletion_date')->setLabel('entity.report.sys_latest_deletion_date');
90+
yield TextField::new('sys_data_worth_saving')->setLabel('entity.report.sys_data_worth_saving');
91+
yield TextField::new('sys_data_processors')->setLabel('entity.report.sys_data_processors');
92+
yield TextField::new('sys_data_processing_agreement')->setLabel('entity.report.sys_data_processing_agreement');
93+
yield TextField::new('sys_data_processing_agreement_link')->setLabel('entity.report.sys_data_processing_agreement_link');
94+
yield TextField::new('sys_auditor_statement')->setLabel('entity.report.sys_auditor_statement');
95+
yield TextField::new('sys_auditor_statement_link')->setLabel('entity.report.sys_auditor_statement_link');
96+
yield TextField::new('sys_data_to_science')->setLabel('entity.report.sys_data_to_science');
97+
yield TextField::new('sys_usage')->setLabel('entity.report.sys_usage');
98+
yield TextField::new('sys_request_for_insight')->setLabel('entity.report.sys_request_for_insight');
99+
yield DateTimeField::new('sys_date_use')->setLabel('entity.report.sys_date_use');
100+
yield TextField::new('sys_status')->setLabel('entity.report.sys_status');
101+
yield TextField::new('sys_remarks')->setLabel('entity.report.sys_remarks');
102+
yield TextField::new('sys_internal_information')->setLabel('entity.report.sys_internal_information');
103+
yield TextField::new('sys_obligation_to_inform')->setLabel('entity.report.sys_obligation_to_inform');
104+
yield TextField::new('sys_legal_basis')->setLabel('entity.report.sys_legal_basis');
105+
yield TextField::new('sys_consent')->setLabel('entity.report.sys_consent');
106+
yield TextField::new('sys_impact_analysis')->setLabel('entity.report.sys_impact_analysis');
107+
yield TextField::new('sys_impact_analysis_link')->setLabel('entity.report.sys_impact_analysis_link');
108+
yield TextField::new('sys_authorization_procedure')->setLabel('entity.report.sys_authorization_procedure');
109+
yield TextField::new('sys_version')->setLabel('entity.report.sys_version');
86110

87-
if (Crud::PAGE_INDEX === $pageName) {
88-
return [$title, $name, $systemOwner, $afdeling, $edocUrl, $text, $sys_link, $text, $groups];
89-
} elseif (Crud::PAGE_DETAIL === $pageName) {
90-
return [$title, $internalId, $edocUrl,
91-
$name, $text, $systemOwner, $groups, $answerarea, $alternativeTitle, $sys_updated, $owner,
92-
$confidentialInformation, $purpose, $classification, $dateForRevision, $persons, $informationTypes,
93-
$dataSentTo, $dataComeFrom, $dataLocation, $deletionDate, $dataWorthSaving, $dataProcessors,
94-
$dataProcessingAgreement, $dataProcessingAgreementLink, $auditorStatement, $auditorStatementLink,
95-
$dataToScience, $usage, $requestForInsight, $dateUse, $status, $remarks, $internalInformation, $obligationToInform,
96-
$legalBasis, $consent, $impactAnalysis, $impactAnalysisLink, $authorizationProcedure, $version];
97-
} elseif (Crud::PAGE_EDIT === $pageName) {
98-
return [$title2, $edocUrl, $groups, $text];
99-
} else {
100-
throw new \Exception('Invalid page: '.$pageName);
111+
return;
112+
113+
case Crud::PAGE_NEW:
114+
case Crud::PAGE_EDIT:
115+
// Cf. https://github.com/itk-dev/sysstatus/blob/5383a3a566ce316c338441ed826ecf3fdcf98815/config/packages/easy_admin.yaml#L144-L150
116+
yield TextField::new('sysTitle')->setLabel('entity.report.sys_title')
117+
->setDisabled();
118+
yield TextEditorField::new('text');
119+
yield AssociationField::new('groups')->setLabel('entity.report.groups')
120+
->setPermission('ROLE_ADMIN');
121+
yield UrlField::new('eDocUrl')->setLabel('entity.report.edoc_url');
122+
123+
return;
124+
125+
default:
126+
throw new \Exception('Invalid page: '.$pageName);
101127
}
102128
}
103129
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
2+
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
3+
{% if 'detail' == ea.crud.currentAction %}
4+
{{ field.formattedValue|raw }}
5+
{% endif %}

0 commit comments

Comments
 (0)