From 5d9e9849b30c28546c50022c15373c41cda8ee81 Mon Sep 17 00:00:00 2001 From: Johan Kromhout Date: Wed, 27 Nov 2024 15:00:49 +0100 Subject: [PATCH] Temporarily hide the TypeOfService selector and allow empty values to prevent unsubmittable forms Resolves https://github.com/SURFnet/sp-dashboard/issues/1321 --- assets/scss/pages/base.scss | 4 ++++ .../Command/Entity/SaveOidcngEntityCommand.php | 7 ++++--- .../Application/Command/Entity/SaveSamlEntityCommand.php | 9 +++++---- .../DashboardBundle/Form/Entity/OidcngEntityType.php | 3 +-- .../DashboardBundle/Form/Entity/SamlEntityType.php | 3 +-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/assets/scss/pages/base.scss b/assets/scss/pages/base.scss index 1617a1ce6..6f3d31ae1 100644 --- a/assets/scss/pages/base.scss +++ b/assets/scss/pages/base.scss @@ -63,3 +63,7 @@ .hidden { display: none; } + +div.form-row:has(#dashboard_bundle_entity_type_metadata_typeOfService) { + display: none; +} \ No newline at end of file diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveOidcngEntityCommand.php b/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveOidcngEntityCommand.php index e5f0c88f1..5e4615346 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveOidcngEntityCommand.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveOidcngEntityCommand.php @@ -157,15 +157,16 @@ class SaveOidcngEntityCommand implements SaveEntityCommandInterface #[Assert\Length(max: 300)] private $applicationUrl; + /** + * // phpcs:ignore + * `new Assert\NotBlank(),` TODO enable in https://github.com/SURFnet/sp-dashboard/issues/1322 + */ /** @var TypeOfService[] */ #[Assert\All([ - new Assert\NotBlank(), new Assert\Type(type: TypeOfService::class), ])] #[Assert\Count( - min: 1, max: 3, - minMessage: 'validator.type-of-service.min', maxMessage: 'validator.type-of-service.max', )] private array $typeOfService; diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveSamlEntityCommand.php b/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveSamlEntityCommand.php index f2db4aa83..71bf41a9d 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveSamlEntityCommand.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Command/Entity/SaveSamlEntityCommand.php @@ -110,15 +110,16 @@ class SaveSamlEntityCommand implements SaveEntityCommandInterface #[Assert\Length(max: 300)] private ?string $applicationUrl = null; - /** @var TypeOfService[] */ + /** + * // phpcs:ignore + * `new Assert\NotBlank(),` TODO enable in https://github.com/SURFnet/sp-dashboard/issues/1322 + * @var TypeOfService[] + */ #[Assert\All([ - new Assert\NotBlank(), new Assert\Type(type: TypeOfService::class), ])] #[Assert\Count( - min: 1, max: 3, - minMessage: 'validator.type-of-service.min', maxMessage: 'validator.type-of-service.max', )] private array $typeOfService = []; diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/OidcngEntityType.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/OidcngEntityType.php index bc148ddb2..3b7a12f0b 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/OidcngEntityType.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/OidcngEntityType.php @@ -263,13 +263,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'typeOfService', ChoiceType::class, [ - 'required' => true, + 'required' => false, 'choices' => $this->typeOfServiceProvider->getTypesOfServiceChoices(), 'choice_value' => fn(TypeOfService $tos): string => $tos->typeEn, 'choice_label' => fn(TypeOfService $tos): string => $tos->typeEn, 'choice_attr' => fn(): array => [ 'class' => 'decorated', - 'data-parsley-mincheck' => 1, 'data-parsley-maxcheck' => 3, ], 'autocomplete' => true, // Enables the UX-Autocomplete diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/SamlEntityType.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/SamlEntityType.php index 7255df766..27784b25d 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/SamlEntityType.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/SamlEntityType.php @@ -245,13 +245,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'typeOfService', ChoiceType::class, [ - 'required' => true, + 'required' => false, 'choices' => $this->typeOfServiceProvider->getTypesOfServiceChoices(), 'choice_value' => fn(TypeOfService $tos): string => $tos->typeEn, 'choice_label' => fn(TypeOfService $tos): string => $tos->typeEn, 'choice_attr' => fn(): array => [ 'class' => 'decorated', - 'data-parsley-mincheck' => 1, 'data-parsley-maxcheck' => 3, ], 'autocomplete' => true, // Enables the UX-Autocomplete