bug and media fixes

This commit is contained in:
Dennis Eichhorn 2021-10-29 14:49:55 +02:00
parent 9cf2887c3b
commit a710da7d2a
15 changed files with 64 additions and 80 deletions

View File

@ -15,23 +15,20 @@ declare(strict_types=1);
namespace Modules\ContractManagement\Controller; namespace Modules\ContractManagement\Controller;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\ContractManagement\Models\Contract;
use Modules\ContractManagement\Models\ContractMapper;
use Modules\ContractManagement\Models\ContractType; use Modules\ContractManagement\Models\ContractType;
use Modules\ContractManagement\Models\ContractTypeMapper;
use Modules\ContractManagement\Models\ContractTypeL11n; use Modules\ContractManagement\Models\ContractTypeL11n;
use Modules\ContractManagement\Models\ContractTypeL11nMapper; use Modules\ContractManagement\Models\ContractTypeL11nMapper;
use phpOMS\Message\Http\HttpResponse; use Modules\ContractManagement\Models\ContractTypeMapper;
use Modules\ContractManagement\Models\NullContractType;
use Modules\Media\Models\PathSettings;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\Http\RequestStatusCode; use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\NotificationLevel; use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\Model\Message\FormValidation; use phpOMS\Model\Message\FormValidation;
use phpOMS\Utils\Parser\Markdown\Markdown;
use phpOMS\Message\Http\HttpRequest;
use Modules\Media\Models\PathSettings;
use Modules\ContractManagement\Models\Contract;
use Modules\ContractManagement\Models\NullContractType;
use Modules\ContractManagement\Models\ContractMapper;
use phpOMS\Localization\ISO639x1Enum;
/** /**
* Api controller for the contracts module. * Api controller for the contracts module.
@ -143,7 +140,8 @@ final class ApiController extends Controller
} }
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles( $uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
[$request->getData('name') ?? ''], $request->getDataList('names') ?? [],
$request->getDataList('filenames') ?? [],
$uploadedFiles, $uploadedFiles,
$request->header->account, $request->header->account,
__DIR__ . '/../../../Modules/Media/Files/Modules/ContractManagement/Contracts/' . ($request->getData('contract_title') ?? '0'), __DIR__ . '/../../../Modules/Media/Files/Modules/ContractManagement/Contracts/' . ($request->getData('contract_title') ?? '0'),

View File

@ -14,17 +14,12 @@ declare(strict_types=1);
namespace Modules\ContractManagement\Controller; namespace Modules\ContractManagement\Controller;
use Modules\ContractManagement\Models\PermissionState; use Modules\ContractManagement\Models\ContractMapper;
use phpOMS\Account\PermissionType; use Modules\ContractManagement\Models\ContractTypeL11n;
use phpOMS\Asset\AssetType;
use phpOMS\Contract\RenderableInterface; use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View; use phpOMS\Views\View;
use Modules\ContractManagement\Models\ContractMapper;
use Modules\ContractManagement\Models\ContractType;
use Modules\ContractManagement\Models\ContractTypeL11n;
/** /**
* Backend controller for the contracts module. * Backend controller for the contracts module.

View File

@ -14,9 +14,9 @@ declare(strict_types=1);
namespace Modules\ContractManagement\Models; namespace Modules\ContractManagement\Models;
use Modules\Media\Models\Media;
use Modules\Admin\Models\Account; use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media;
use phpOMS\Localization\Money; use phpOMS\Localization\Money;
/** /**
@ -129,17 +129,17 @@ class Contract
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'title' => $this->title, 'title' => $this->title,
'description' => $this->description, 'description' => $this->description,
'start' => $this->start, 'start' => $this->start,
'end' => $this->end, 'end' => $this->end,
'duration' => $this->duration, 'duration' => $this->duration,
'warning' => $this->warning, 'warning' => $this->warning,
'responsible' => $this->responsible, 'responsible' => $this->responsible,
'createdAt' => $this->createdAt, 'createdAt' => $this->createdAt,
'costs' => $this->costs, 'costs' => $this->costs,
'type' => $this->type, 'type' => $this->type,
]; ];
} }

View File

@ -14,8 +14,8 @@ declare(strict_types=1);
namespace Modules\ContractManagement\Models; namespace Modules\ContractManagement\Models;
use Modules\Media\Models\MediaMapper;
use Modules\Admin\Models\AccountMapper; use Modules\Admin\Models\AccountMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract; use phpOMS\DataStorage\Database\DataMapperAbstract;
/** /**
@ -35,18 +35,18 @@ final class ContractMapper extends DataMapperAbstract
* @since 1.0.0 * @since 1.0.0
*/ */
protected static array $columns = [ protected static array $columns = [
'contractmgmt_contract_id' => ['name' => 'contractmgmt_contract_id', 'type' => 'int', 'internal' => 'id'], 'contractmgmt_contract_id' => ['name' => 'contractmgmt_contract_id', 'type' => 'int', 'internal' => 'id'],
'contractmgmt_contract_title' => ['name' => 'contractmgmt_contract_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], 'contractmgmt_contract_title' => ['name' => 'contractmgmt_contract_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
'contractmgmt_contract_description' => ['name' => 'contractmgmt_contract_description', 'type' => 'string', 'internal' => 'description'], 'contractmgmt_contract_description' => ['name' => 'contractmgmt_contract_description', 'type' => 'string', 'internal' => 'description'],
'contractmgmt_contract_account' => ['name' => 'contractmgmt_contract_account', 'type' => 'int', 'internal' => 'account'], 'contractmgmt_contract_account' => ['name' => 'contractmgmt_contract_account', 'type' => 'int', 'internal' => 'account'],
'contractmgmt_contract_costs' => ['name' => 'contractmgmt_contract_costs', 'type' => 'Serializable', 'internal' => 'costs'], 'contractmgmt_contract_costs' => ['name' => 'contractmgmt_contract_costs', 'type' => 'Serializable', 'internal' => 'costs'],
'contractmgmt_contract_duration' => ['name' => 'contractmgmt_contract_duration', 'type' => 'int', 'internal' => 'duration'], 'contractmgmt_contract_duration' => ['name' => 'contractmgmt_contract_duration', 'type' => 'int', 'internal' => 'duration'],
'contractmgmt_contract_warning' => ['name' => 'contractmgmt_contract_warning', 'type' => 'int', 'internal' => 'warning'], 'contractmgmt_contract_warning' => ['name' => 'contractmgmt_contract_warning', 'type' => 'int', 'internal' => 'warning'],
'contractmgmt_contract_start' => ['name' => 'contractmgmt_contract_start', 'type' => 'DateTime', 'internal' => 'start'], 'contractmgmt_contract_start' => ['name' => 'contractmgmt_contract_start', 'type' => 'DateTime', 'internal' => 'start'],
'contractmgmt_contract_end' => ['name' => 'contractmgmt_contract_end', 'type' => 'DateTime', 'internal' => 'end'], 'contractmgmt_contract_end' => ['name' => 'contractmgmt_contract_end', 'type' => 'DateTime', 'internal' => 'end'],
'contractmgmt_contract_responsible' => ['name' => 'contractmgmt_contract_responsible', 'type' => 'int', 'internal' => 'responsible'], 'contractmgmt_contract_responsible' => ['name' => 'contractmgmt_contract_responsible', 'type' => 'int', 'internal' => 'responsible'],
'contractmgmt_contract_type' => ['name' => 'contractmgmt_contract_type', 'type' => 'int', 'internal' => 'type'], 'contractmgmt_contract_type' => ['name' => 'contractmgmt_contract_type', 'type' => 'int', 'internal' => 'type'],
'contractmgmt_contract_created_at' => ['name' => 'contractmgmt_contract_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], 'contractmgmt_contract_created_at' => ['name' => 'contractmgmt_contract_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
]; ];
/** /**

View File

@ -105,7 +105,7 @@ class ContractType implements \JsonSerializable, ArrayableInterface
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'l11n' => $this->l11n, 'l11n' => $this->l11n,
]; ];
} }

View File

@ -119,9 +119,9 @@ class ContractTypeL11n implements \JsonSerializable, ArrayableInterface
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'title' => $this->title, 'title' => $this->title,
'type' => $this->type, 'type' => $this->type,
'language' => $this->language, 'language' => $this->language,
]; ];
} }

View File

@ -50,7 +50,7 @@ final class ContractTypeMapper extends DataMapperAbstract
'column' => 'title', 'column' => 'title',
'conditional' => true, 'conditional' => true,
'external' => null, 'external' => null,
] ],
]; ];
/** /**

View File

@ -13,8 +13,8 @@
declare(strict_types=1); declare(strict_types=1);
return ['Navigation' => [ return ['Navigation' => [
'Create' => 'Create', 'Create' => 'Create',
'Contract' => 'Contract', 'Contract' => 'Contract',
'Contracts' => 'Contracts', 'Contracts' => 'Contracts',
'List' => 'List', 'List' => 'List',
]]; ]];

View File

@ -13,7 +13,7 @@
declare(strict_types=1); declare(strict_types=1);
return ['ContractManagement' => [ return ['ContractManagement' => [
'Contract' => 'Contract', 'Contract' => 'Contract',
'Contracts' => 'Contracts', 'Contracts' => 'Contracts',
'Title' => 'Title', 'Title' => 'Title',
]]; ]];

View File

@ -12,11 +12,10 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
/** /**
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract[] $contracts * @var \Modules\ContractManagement\Models\Contract[] $contracts
*/ */
$contracts = $this->getData('contracts') ?? []; $contracts = $this->getData('contracts') ?? [];

View File

@ -12,11 +12,8 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
/** /**
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract $contract * @var \Modules\ContractManagement\Models\Contract $contract
*/ */
$contract = $this->getData('contract'); $contract = $this->getData('contract');

View File

@ -16,26 +16,22 @@ namespace Modules\ContractManagement\tests\Controller;
use Model\CoreSettings; use Model\CoreSettings;
use Modules\Admin\Models\AccountPermission; use Modules\Admin\Models\AccountPermission;
use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Account\Account; use phpOMS\Account\Account;
use phpOMS\Account\AccountManager; use phpOMS\Account\AccountManager;
use phpOMS\Account\PermissionType; use phpOMS\Account\PermissionType;
use phpOMS\Application\ApplicationAbstract; use phpOMS\Application\ApplicationAbstract;
use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Dispatcher\Dispatcher; use phpOMS\Dispatcher\Dispatcher;
use phpOMS\Event\EventManager; use phpOMS\Event\EventManager;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\Utils\TestUtils;
use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\ISO639x1Enum;
use Modules\Media\Models\MediaMapper;
use Modules\Media\Models\PathSettings;
use Modules\Media\Models\UploadStatus;
use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode; use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\System\File\Local\Directory; use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\Uri\HttpUri; use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
/** /**
* @testdox Modules\ContractManagement\tests\Controller\ApiControllerTest: ContractManagement api controller * @testdox Modules\ContractManagement\tests\Controller\ApiControllerTest: ContractManagement api controller

View File

@ -59,26 +59,26 @@ final class ContractTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->contract->title = 'Title'; $this->contract->title = 'Title';
$this->contract->description = 'Description'; $this->contract->description = 'Description';
$this->contract->duration = 123; $this->contract->duration = 123;
$this->contract->warning = 2; $this->contract->warning = 2;
$serialized = $this->contract->jsonSerialize(); $serialized = $this->contract->jsonSerialize();
unset($serialized['createdAt']); unset($serialized['createdAt']);
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'title' => 'Title', 'title' => 'Title',
'description' => 'Description', 'description' => 'Description',
'start' => null, 'start' => null,
'end' => null, 'end' => null,
'duration' => 123, 'duration' => 123,
'warning' => 2, 'warning' => 2,
'responsible' => null, 'responsible' => null,
'costs' => null, 'costs' => null,
'type' => new ContractType(), 'type' => new ContractType(),
], ],
$serialized $serialized
); );

View File

@ -70,16 +70,16 @@ final class ContractTypeL11nTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->l11n->title = 'Title'; $this->l11n->title = 'Title';
$this->l11n->type = 2; $this->l11n->type = 2;
$this->l11n->setLanguage(ISO639x1Enum::_DE); $this->l11n->setLanguage(ISO639x1Enum::_DE);
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'title' => 'Title', 'title' => 'Title',
'type' => 2, 'type' => 2,
'language' => ISO639x1Enum::_DE, 'language' => ISO639x1Enum::_DE,
], ],
$this->l11n->jsonSerialize() $this->l11n->jsonSerialize()
); );

View File

@ -16,7 +16,6 @@ namespace Modules\ContractManagement\tests\Models;
use Modules\ContractManagement\Models\ContractType; use Modules\ContractManagement\Models\ContractType;
use Modules\ContractManagement\Models\ContractTypeL11n; use Modules\ContractManagement\Models\ContractTypeL11n;
use phpOMS\Localization\ISO639x1Enum;
/** /**
* @internal * @internal
@ -67,7 +66,7 @@ final class ContractTypeTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'l11n' => new ContractTypeL11n(), 'l11n' => new ContractTypeL11n(),
], ],
$this->type->jsonSerialize() $this->type->jsonSerialize()
); );