From 94f065a3833d259d7a027ec5c5a0f028de3abc95 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 7 Jan 2023 19:00:33 +0100 Subject: [PATCH] l11n, unit/app and simplification fixes --- Admin/Install/db.json | 8 ++++++++ Controller/ApiController.php | 9 +++++---- Models/SupportApp.php | 8 ++++++++ Models/SupportAppMapper.php | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 6f0fa8f..0a978a0 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -13,6 +13,14 @@ "name": "support_app_name", "type": "VARCHAR(255)", "default": null + }, + "support_app_unit": { + "name": "support_app_unit", + "type": "INT", + "default": null, + "null": true, + "foreignTable": "organization_unit", + "foreignKey": "organization_unit_id" } } }, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 68c471b..76494f7 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -374,6 +374,7 @@ final class ApiController extends Controller { $app = new SupportApp(); $app->name = (string) ($request->getData('name') ?? ''); + $app->unit = $request->getData('unit', 'int'); return $app; } @@ -662,13 +663,13 @@ final class ApiController extends Controller $type = (int) ($request->getData('type') ?? 0); if ($type === AttributeValueType::_INT) { - $attrValue->valueInt = $request->hasData('value') ? (int) $request->getData('value') : null; + $attrValue->valueInt = $request->getData('value', 'int'); } elseif ($type === AttributeValueType::_STRING) { - $attrValue->valueStr = $request->hasData('value') ? (string) $request->getData('value') : null; + $attrValue->valueStr = $request->getData('value', 'string'); } elseif ($type === AttributeValueType::_FLOAT) { - $attrValue->valueDec = $request->hasData('value') ? (float) $request->getData('value') : null; + $attrValue->valueDec = $request->getData('value', 'float'); } elseif ($type === AttributeValueType::_DATETIME) { - $attrValue->valueDat = $request->hasData('value') ? new \DateTime((string) ($request->getData('value') ?? '')) : null; + $attrValue->valueDat = $request->getData('value', 'DateTime'); } $attrValue->type = $type; diff --git a/Models/SupportApp.php b/Models/SupportApp.php index 8b98ca3..ba6a053 100755 --- a/Models/SupportApp.php +++ b/Models/SupportApp.php @@ -40,6 +40,14 @@ class SupportApp implements \JsonSerializable */ public string $name = ''; + /** + * Unit + * + * @var null|int + * @since 1.0.0 + */ + public ?int $unit = null; + /** * Get id. * diff --git a/Models/SupportAppMapper.php b/Models/SupportAppMapper.php index 5bce483..7f782f3 100755 --- a/Models/SupportAppMapper.php +++ b/Models/SupportAppMapper.php @@ -35,6 +35,7 @@ final class SupportAppMapper extends DataMapperFactory public const COLUMNS = [ 'support_app_id' => ['name' => 'support_app_id', 'type' => 'int', 'internal' => 'id'], 'support_app_name' => ['name' => 'support_app_name', 'type' => 'string', 'internal' => 'name'], + 'support_app_unit' => ['name' => 'support_app_unit', 'type' => 'int', 'internal' => 'unit'], ]; /**