diff --git a/public/api-spec-v1.json b/public/api-spec-v1.json
index c32a38d..6322468 100644
--- a/public/api-spec-v1.json
+++ b/public/api-spec-v1.json
@@ -442,6 +442,7 @@
"type": "string"
},
"proximityToUnlock": {
+ "description": "Proximity to unlock in meters.",
"type": [
"integer",
"null"
@@ -542,6 +543,7 @@
"type": "string"
},
"proximityToUnlock": {
+ "description": "Proximity to unlock in meters.",
"type": [
"integer",
"null"
diff --git a/public/api-spec-v1.yaml b/public/api-spec-v1.yaml
index edeaf49..cf7d8d5 100644
--- a/public/api-spec-v1.yaml
+++ b/public/api-spec-v1.yaml
@@ -208,6 +208,7 @@ components:
longitude:
type: string
proximityToUnlock:
+ description: 'Proximity to unlock in meters.'
type:
- integer
- 'null'
@@ -278,6 +279,7 @@ components:
longitude:
type: string
proximityToUnlock:
+ description: 'Proximity to unlock in meters.'
type:
- integer
- 'null'
diff --git a/src/Controller/Admin/PointOfInterestCrudController.php b/src/Controller/Admin/PointOfInterestCrudController.php
index 60ad309..0d9077a 100644
--- a/src/Controller/Admin/PointOfInterestCrudController.php
+++ b/src/Controller/Admin/PointOfInterestCrudController.php
@@ -3,10 +3,12 @@
namespace App\Controller\Admin;
use App\Admin\Field\LocationField;
+use App\Admin\Field\ValueWithUnitField;
use App\Entity\PointOfInterest;
use App\Entity\Role;
use App\Entity\Route;
use App\Field\VichImageField;
+use App\Form\ValueWithUnitType;
use App\Service\EasyAdminHelper;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
@@ -91,8 +93,15 @@ public function configureFields(string $pageName): iterable
->setRequired(true)
->setVirtual(true)->setColumns(12);
- yield NumberField::new('proximityToUnlock', new TranslatableMessage('Proximity to unlock', [], 'admin'))
- ->setHelp(new TranslatableMessage('The proximity that allows unlocking this point of interest (in m).', [], 'admin'))->setColumns(12);
+ yield ValueWithUnitField::new('proximityToUnlock', new TranslatableMessage('Proximity to unlock', [], 'admin'))
+ ->setFormTypeOption('units', [
+ 'm' => [
+ ValueWithUnitType::OPTION_LABEL => new TranslatableMessage('meter', [], 'admin'),
+ ValueWithUnitType::OPTION_SCALE => 1,
+ ValueWithUnitType::OPTION_LOCALIZED_UNIT => new TranslatableMessage('unit.m', [], 'admin'),
+ ],
+ ])
+ ->setHelp(new TranslatableMessage('The proximity that allows unlocking this point of interest.', [], 'admin'))->setColumns(12);
yield DateField::new('createdAt', new TranslatableMessage('Created at', [], 'admin'))->hideOnForm();
yield DateField::new('updatedAt', new TranslatableMessage('Updated at', [], 'admin'))->hideOnForm();
diff --git a/src/Entity/PointOfInterest.php b/src/Entity/PointOfInterest.php
index 4e5b144..798a2de 100644
--- a/src/Entity/PointOfInterest.php
+++ b/src/Entity/PointOfInterest.php
@@ -81,6 +81,9 @@ class PointOfInterest implements BlameableInterface, \JsonSerializable
#[Groups(['read'])]
private ?string $longitude = null;
+ /**
+ * Proximity to unlock in meters.
+ */
#[ORM\Column(length: 255, nullable: true)]
#[Assert\NotBlank]
#[Groups(['read'])]
diff --git a/src/Form/ValueWithUnitType.php b/src/Form/ValueWithUnitType.php
index 7884872..d8bb7b6 100644
--- a/src/Form/ValueWithUnitType.php
+++ b/src/Form/ValueWithUnitType.php
@@ -62,7 +62,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
;
}
- public function transform(int $value, array $options): array
+ public function transform(?int $value, array $options): array
{
try {
return $this->getMatchingUnit($value, $options);
@@ -118,14 +118,14 @@ private function getUnits(array $options): array
return $units;
}
- public function getMatchingUnit(int $value, array $options): array
+ public function getMatchingUnit(?int $value, array $options): array
{
$units = $this->getUnits($options);
foreach ($units as $unit => $info) {
$scale = $info[self::OPTION_SCALE];
if ($value >= $scale || array_key_last($units) === $unit) {
return [
- self::FIELD_VALUE => $scale > 1 ? $value / $scale : $value,
+ self::FIELD_VALUE => null === $value ? null : ($scale > 1 ? $value / $scale : $value),
self::FIELD_UNIT => $unit,
self::OPTION_LOCALIZED_UNIT => $info[self::OPTION_LOCALIZED_UNIT],
];
diff --git a/translations/admin+intl-icu.da.xlf b/translations/admin+intl-icu.da.xlf
index 5952eb3..50faeb7 100644
--- a/translations/admin+intl-icu.da.xlf
+++ b/translations/admin+intl-icu.da.xlf
@@ -21,10 +21,6 @@
En tekstuel udgave af podcasten til mennesker med hørenedsættelse.
-
-
- Nærheden for at afspille seværdigheden (i meter).
-
E-mailadresse som også bruges som brugernavn
@@ -89,7 +85,7 @@
Linket udløber om {expire_info}.
-
+
prøv igen.]]>
@@ -205,7 +201,7 @@
E-mail
-
+
breddegrad, længdegrad, fx. 56.153244272970866, 10.213798100000005
. Bemærk: de to tal skal altid adskilles af et komma og skal bruge punktum som decimalseparator.
Tip: Åbn Google Maps og højreklik på kortet for at få koordinaterne.]]>
@@ -341,6 +337,10 @@
minutter
+
+
+ Nærheden for at afspille seværdigheden.
+