auto fixes + some impl.

This commit is contained in:
Dennis Eichhorn 2024-01-26 22:54:00 +00:00
parent 1952b38b5a
commit aa76b13b6b
51 changed files with 1230 additions and 2037 deletions

View File

@ -33,7 +33,7 @@
"type": 0,
"subtype": 1,
"name": "Tasks",
"uri": "{/base}/task/single?{?}",
"uri": "{/base}/task/view?{?}",
"target": "self",
"icon": null,
"order": 1,

View File

@ -17,7 +17,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^:tag .*$' => [
'^:tag (\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\SearchController:searchTag',
'verb' => RouteVerb::ANY,

View File

@ -1,5 +1,5 @@
[
{
{
"name": "category",
"l11n": {
"en": "Category",

View File

@ -97,6 +97,14 @@
"foreignTable": "account",
"foreignKey": "account_id"
},
"task_for": {
"name": "task_for",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "account",
"foreignKey": "account_id"
},
"task_created_at": {
"name": "task_created_at",
"type": "DATETIME",
@ -119,6 +127,11 @@
"type": "VARCHAR(255)",
"null": false
},
"task_attr_type_datatype": {
"name": "task_attr_type_datatype",
"type": "INT(11)",
"null": false
},
"task_attr_type_fields": {
"name": "task_attr_type_fields",
"type": "INT(11)",
@ -134,6 +147,11 @@
"type": "TINYINT(1)",
"null": false
},
"task_attr_type_internal": {
"name": "task_attr_type_internal",
"type": "TINYINT(1)",
"null": false
},
"task_attr_type_required": {
"description": "Every task must have this attribute type if set to true.",
"name": "task_attr_type_required",
@ -222,6 +240,22 @@
"name": "task_attr_value_unit",
"type": "VARCHAR(255)",
"null": false
},
"task_attr_value_deptype": {
"name": "task_attr_value_deptype",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "task_attr_type",
"foreignKey": "task_attr_type_id"
},
"task_attr_value_depvalue": {
"name": "task_attr_value_depvalue",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "task_attr_value",
"foreignKey": "task_attr_value_id"
}
}
},
@ -386,6 +420,11 @@
"type": "TINYINT",
"null": false
},
"task_element_duration": {
"name": "task_element_duration",
"type": "INT",
"null": false
},
"task_element_due": {
"name": "task_element_due",
"type": "DATETIME",

View File

@ -20,7 +20,6 @@ use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo;
use phpOMS\Uri\HttpUri;
/**
* Installer class.
@ -74,21 +73,24 @@ final class Installer extends InstallerAbstract
/** @var array<string, array> $taskAttrType */
$taskAttrType = [];
/** @var \Modules\Tasks\Controller\ApiController $module */
$module = $app->moduleManager->getModuleInstance('Tasks');
/** @var \Modules\Tasks\Controller\ApiAttributeController $module */
$module = $app->moduleManager->getModuleInstance('Tasks', 'ApiAttribute');
/** @var array $attribute */
foreach ($attributes as $attribute) {
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('name', $attribute['name'] ?? '');
$request->setData('title', \reset($attribute['l11n']));
$request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en');
$request->setData('repeatable', $attribute['repeatable'] ?? false);
$request->setData('internal', $attribute['internal'] ?? false);
$request->setData('is_required', $attribute['is_required'] ?? false);
$request->setData('custom', $attribute['is_custom_allowed'] ?? false);
$request->setData('validation_pattern', $attribute['validation_pattern'] ?? '');
$request->setData('datatype', (int) $attribute['value_type']);
$module->apiTaskAttributeTypeCreate($request, $response);
@ -109,7 +111,7 @@ final class Installer extends InstallerAbstract
}
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', $l11n);
@ -139,8 +141,8 @@ final class Installer extends InstallerAbstract
/** @var array<string, array> $taskAttrValue */
$taskAttrValue = [];
/** @var \Modules\Tasks\Controller\ApiController $module */
$module = $app->moduleManager->getModuleInstance('Tasks');
/** @var \Modules\Tasks\Controller\ApiAttributeController $module */
$module = $app->moduleManager->getModuleInstance('Tasks', 'ApiAttribute');
foreach ($attributes as $attribute) {
$taskAttrValue[$attribute['name']] = [];
@ -148,14 +150,13 @@ final class Installer extends InstallerAbstract
/** @var array $value */
foreach ($attribute['values'] as $value) {
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('value', $value['value'] ?? '');
$request->setData('value_type', $attribute['value_type'] ?? 0);
$request->setData('unit', $value['unit'] ?? '');
$request->setData('default', isset($attribute['values']) && !empty($attribute['values']));
$request->setData('attributetype', $taskAttrType[$attribute['name']]['id']);
$request->setData('default',true);
$request->setData('type', $taskAttrType[$attribute['name']]['id']);
if (isset($value['l11n']) && !empty($value['l11n'])) {
$request->setData('title', \reset($value['l11n']));
@ -183,7 +184,7 @@ final class Installer extends InstallerAbstract
}
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', $l11n);

View File

@ -58,7 +58,7 @@ return [
],
],
],
'^.*/task/element.*$' => [
'^.*/task/element(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\ApiController:apiTaskElementCreate',
'verb' => RouteVerb::PUT,

View File

@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/task/dashboard.*$' => [
'^.*/task/dashboard(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskDashboard',
'verb' => RouteVerb::GET,
@ -29,7 +29,7 @@ return [
],
],
],
'^.*/task/single.*$' => [
'^.*/task/view(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskView',
'verb' => RouteVerb::GET,
@ -40,7 +40,7 @@ return [
],
],
],
'^.*/task/create.*$' => [
'^.*/task/create(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskCreate',
'verb' => RouteVerb::GET,
@ -51,7 +51,7 @@ return [
],
],
],
'^.*/task/analysis.*$' => [
'^.*/task/analysis(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskAnalysis',
'verb' => RouteVerb::GET,

View File

@ -1,12 +1,16 @@
# Development
## Development environment
The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md).
The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md).
## Code of conduct
Every organization member and contributor to the organization must follow the [code of conduct](../Policies & Guidelines/Code of conduct.md).
Every organization member and contributor to the organization must follow the [Code of Conduct](../Policies%20&%20Guidelines/Code%20of%20Conduct.md).
## Becoming a contributor
For public repositories you can immediately start by creating forks and pull requests. For private repositories which are necessary to setup the complete developer environment, feel free to request access. Please not that we may not immediately give you access to private repositories and instead will give you smaller tasks regarding public repositories. Please contact info@jingga.app for more details. (**R1**)
For all contributions our [Contributor License Agreement "CLA"](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/HR/Hiring/Individual%20Contributor%20License%20Agreement.md) comes into effect. (**R2**)
## Code changes
@ -14,58 +18,106 @@ Every organization member and contributor to the organization must follow the [c
Generally, the development philosophy is result orientated. This means that anyone can propose tasks, pick up existing tasks or right away implement their code changes. However, implementing code changes without consulting with a senior developer in advance has a much higher risk of code changes not getting admitted. The easiest way to discuss a code change idea in advance are the github [issues](https://github.com/Karaka-Management/Karaka/issues) or [discussions](https://github.com/Karaka-Management/Karaka/discussions).
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
Open tasks can be found in the project overview: [PROJECT.md](https://github.com/orgs/Karaka-Management/projects/10)
Open tasks can be found in the project overview: [Todos](https://github.com/orgs/Karaka-Management/projects/10)
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis.
The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis.
### Code style
### Quality
Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review.
#### Code style
In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be changes in the programming language, special cases which cannot, are difficult or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review.
Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards) (**R3**). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R4**)
Automated checks which are run during the review process:
In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be for example special cases which are difficult automatize or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. (**R5**)
Automated checks which are run during the review process (**R4**):
```sh
php ./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/php-cs-fixer fix ./ --config=Build/Config/.php-cs-fixer.php --allow-risky=yes
php ./vendor/bin/phpcbf --standard=Build/Config/phpcs.xml ./
php ./vendor/bin/rector process --dry-run --config Build/Config/rector.php ./
npx eslint ./ -c ./Build/Config/.eslintrc.json
```
### Tests
#### Tests
Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md). Developers should check if the code changes comply with the inspection guidelines before submitting them.
Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) (**R6**). Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R7**)
In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted.
In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. (**R8**)
Automated tests which are run during the review process:
Automated tests which are run during the review process (**R7**):
```sh
php ./vendor/bin/phpunit -c tests/PHPUnit/phpunit_default.xml
php ./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./
php ./vendor/bin/phpstan analyse --no-progress -l 9 -c Build/Config/phpstan.neon ./
npx jasmine-node ./
./cOMS/tests/test.sh
```
Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks.
Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. (**R7**)
### Demo
#### Performance
Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically.
Developers should occasionaly check performance statistics. At this point no target metrics are defined.
### Code review
Since the primary application is a web based application a similar tool as the Google lighthouse tool can be used to inspect the application for best practicies which can significantly improve the application performance. The sitespeed.io tool shows potential performance improvements and slow pages. With the php trace and profiler enabled in the `php.ini` file the VM automatically generates profiling and trace reports for every web request. These can be found in the webgrind logs directory and inspected in webgrind and dropped into the trace visualizer for a flame chart visualization. With mysqldumpslow you can inspect slow sql queries which may need optimization.
1. Automatic trace and benchmark generation with every web request in `/var/www/html/webgrind/Logs`
2. Webgrind view `http://vm_ip:82`
3. Trace visualization `http://vm_ip:81`
1. Download the latest trace from `http://vm_ip:82/Logs`
2. Drag and drop that downloaded `*.xt` file in the trace visualizer
4. `sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFolder /var/www/html/sitespeed`
5. Slow query inspection.
```sh
mysqldumpslow -t 10 /var/log/mysql/mysql-slow.log
mysqldumpslow -t 10 -s l /var/log/mysql/mysql-slow.log
```
#### Code review
In addition to the automatic code review performed by the various inspection tools such as (phpcs, phpstan, phpunit, eslint and custom scripts) a senior developer must check the proposed code change before it is merged with the respective `develop` branch. Only upon the approval by the reviewer a code change requests gets merged as no other developers have permission in the software to make such code merges.
In case a code change request is not approved the reviewer states the reason for the decision, this may include some tips and requests which will allow the contributor to make improvements so that the code change may get approved.
If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning.
If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. (**R5**+**R8**)
#### Demo
Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. (**R9**)
```sh
sudo -u www-data php -dxdebug.remote_enable=1 -dxdebug.start_with_request=yes -dxdebug.mode=coverage,develop,debug demoSetup/setup.php
```
#### Documentation
Occasionally new code or code changes also require new documentation or documentation changes. Developers should make sure that the new code is also reflected in the existing documentation ([Developer-Guide](), [User-Guide]() and/or module documentation) or if additional documentation is necessary.
#### Improvements, features, bugs
If a developer (or employee in general) has an idea for an improvement, feature or finds a potential bug it should be reported at https://github.com/Karaka-Management/Karaka/issues. A senior developer has to check these issues and decide how to proceed with them. The decision how to proceed with the issue must be explained by the senior developer as a response in the issue. Possible steps are:
* Accept the issue and put the task into the [Todos](https://github.com/orgs/Karaka-Management/projects/10)
* Dismiss the issue with an explanation
### Release flow
In case SCSS/CSS or JS files got changed they must get re-built locally before comitting the code change:
```sh
npx esbuild Web/Backend/js/backend.js --bundle --outfile=Install/Application/Backend/js/backend.min.js --minify
scss cssOMS/styles.scss > cssOMS/styles.css
```
For JS you may also use the shorthand command `npm run build`.
Code changes must be performed in a new branch. A new branch can be created with:
```sh
@ -75,8 +127,70 @@ git checkout -b new-branch-name
The name of the branch can be chosen freely however it is recommended to follow the following branch naming conventions:
* `feature-*` for feature implementations
* `hotfix-*` for security related fixes/improvements
* `bug-*` for bug fixes
* `security-*` for security related fixes/improvements
* `general-*` for general improvements (i.e. code documentation improvements, code style improvements)
* `general-*` for general improvements (i.e. documentation, code style & performance improvements)
The senior developer who performs the code review merges the change request into the `develop` branch upon approval.
```mermaid
%%{init: { 'gitGraph': {'mainBranchName': 'master'}} }%%
gitGraph
commit
branch hotfix-xxx
commit
checkout master
branch develop
checkout master
merge hotfix-xxx
checkout develop
branch bug-xxx
commit
commit
checkout hotfix-xxx
commit
checkout master
merge hotfix-xxx
checkout develop
merge bug-xxx
commit
checkout develop
branch feature-xxx
commit
commit
commit
checkout develop
merge feature-xxx
checkout master
merge develop
checkout develop
branch general-xxx
commit
checkout develop
merge general-xxx
branch security-xxx
commit
commit
checkout develop
merge security-xxx
checkout master
merge develop
```
The senior developer who performs the code review merges the change request into the `develop` branch after their successful code review. Unsuccessful reviews lead to change requests by the original developer, other developers who can make the requested changes, changes by the senior developer who performed the review, or dismissal of the changed code. (**R10**)
## Approved dependencies
### Customer dependencies
Developers may only rely on the dependencies defined in [Approved Customer Software]() when developing a solution. If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. (**R11**)
### Developer dependencies
Developers may only rely on the dependencies defined in [IT Equipment & Software](). If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. Changing the package managers such as `composer.json` or `package.json` is not allowed by anyone else than the CTO. (**R12**)
## Other related documents
* [Confidentiality Policy](../Policies%20&%20Guidelines/Confidentiality%20Policy.md)
* [Organization Activity Policy](../Policies%20&%20Guidelines/Organization%20Activity%20Policy.md)
* [Tutorials](./Development/Tutorials)

View File

@ -0,0 +1,550 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Controller;
use Modules\Attribute\Models\Attribute;
use Modules\Attribute\Models\AttributeType;
use Modules\Attribute\Models\AttributeValue;
use Modules\Tasks\Models\Attribute\TaskAttributeMapper;
use Modules\Tasks\Models\Attribute\TaskAttributeTypeL11nMapper;
use Modules\Tasks\Models\Attribute\TaskAttributeTypeMapper;
use Modules\Tasks\Models\Attribute\TaskAttributeValueL11nMapper;
use Modules\Tasks\Models\Attribute\TaskAttributeValueMapper;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
/**
* Tasks class.
*
* @package Modules\Tasks
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class ApiAttributeController extends Controller
{
use \Modules\Attribute\Controller\ApiAttributeTraitController;
/**
* Api method to create task attribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$type = TaskAttributeTypeMapper::get()
->with('defaults')
->where('id', (int) $request->getData('type'))
->execute();
if (!$type->repeatable) {
$attr = TaskAttributeMapper::count()
->with('type')
->where('type/id', $type->id)
->where('ref', (int) $request->getData('ref'))
->execute();
if ($attr > 0) {
$response->header->status = RequestStatusCode::R_409;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
}
$attribute = $this->createAttributeFromRequest($request, $type);
$this->createModel($request->header->account, $attribute, TaskAttributeMapper::class, 'attribute', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attribute);
}
/**
* Api method to create task attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeTypeL11nCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrL11n = $this->createAttributeTypeL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, TaskAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrL11n);
}
/**
* Api method to create task attribute type
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeTypeCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrType = $this->createAttributeTypeFromRequest($request);
$this->createModel($request->header->account, $attrType, TaskAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrType);
}
/**
* Api method to create task attribute value
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeValueCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
/** @var \Modules\Attribute\Models\AttributeType $type */
$type = TaskAttributeTypeMapper::get()
->where('id', $request->getDataInt('type') ?? 0)
->execute();
if ($type->isInternal) {
$response->header->status = RequestStatusCode::R_403;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrValue = $this->createAttributeValueFromRequest($request, $type);
$this->createModel($request->header->account, $attrValue, TaskAttributeValueMapper::class, 'attr_value', $request->getOrigin());
if ($attrValue->isDefault) {
$this->createModelRelation(
$request->header->account,
$type->id,
$attrValue->id,
TaskAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
);
}
$this->createStandardCreateResponse($request, $response, $attrValue);
}
/**
* Api method to create task attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeValueL11nCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrL11n = $this->createAttributeValueL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, TaskAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrL11n);
}
/**
* Api method to update TaskAttribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var Attribute $old */
$old = TaskAttributeMapper::get()
->with('type')
->with('type/defaults')
->with('value')
->where('id', (int) $request->getData('id'))
->execute();
$new = $this->updateAttributeFromRequest($request, clone $old);
if ($new->id === 0) {
// Set response header to invalid request because of invalid data
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $new);
return;
}
$this->updateModel($request->header->account, $old, $new, TaskAttributeMapper::class, 'task_attribute', $request->getOrigin());
if ($new->value->getValue() !== $old->value->getValue()
&& $new->type->custom
) {
$this->updateModel($request->header->account, $old->value, $new->value, TaskAttributeValueMapper::class, 'attribute_value', $request->getOrigin());
}
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete TaskAttribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
$taskAttribute = TaskAttributeMapper::get()
->with('type')
->where('id', (int) $request->getData('id'))
->execute();
if ($taskAttribute->type->isRequired) {
$this->createInvalidDeleteResponse($request, $response, []);
return;
}
$this->deleteModel($request->header->account, $taskAttribute, TaskAttributeMapper::class, 'task_attribute', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $taskAttribute);
}
/**
* Api method to update TaskAttributeTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeTypeL11nUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $old */
$old = TaskAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateAttributeTypeL11nFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, TaskAttributeTypeL11nMapper::class, 'task_attribute_type_l11n', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete TaskAttributeTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeTypeL11nDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $taskAttributeTypeL11n */
$taskAttributeTypeL11n = TaskAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $taskAttributeTypeL11n, TaskAttributeTypeL11nMapper::class, 'task_attribute_type_l11n', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $taskAttributeTypeL11n);
}
/**
* Api method to update TaskAttributeType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeTypeUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var AttributeType $old */
$old = TaskAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateAttributeTypeFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, TaskAttributeTypeMapper::class, 'task_attribute_type', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete TaskAttributeType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @todo Implement API function
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeTypeDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var AttributeType $taskAttributeType */
$taskAttributeType = TaskAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $taskAttributeType, TaskAttributeTypeMapper::class, 'task_attribute_type', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $taskAttributeType);
}
/**
* Api method to update TaskAttributeValue
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeValueUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var AttributeValue $old */
$old = TaskAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
/** @var \Modules\Attribute\Models\Attribute $attr */
$attr = TaskAttributeMapper::get()
->with('type')
->where('id', $request->getDataInt('attribute') ?? 0)
->execute();
$new = $this->updateAttributeValueFromRequest($request, clone $old, $attr);
$this->updateModel($request->header->account, $old, $new, TaskAttributeValueMapper::class, 'task_attribute_value', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete TaskAttributeValue
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
// @todo I don't think values can be deleted? Only Attributes
// However, It should be possible to remove UNUSED default values
// either here or other function?
// if (!empty($val = $this->validateAttributeValueDelete($request))) {
// $response->header->status = RequestStatusCode::R_400;
// $this->createInvalidDeleteResponse($request, $response, $val);
// return;
// }
// /** @var \Modules\Tasks\Models\TaskAttributeValue $taskAttributeValue */
// $taskAttributeValue = TaskAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
// $this->deleteModel($request->header->account, $taskAttributeValue, TaskAttributeValueMapper::class, 'task_attribute_value', $request->getOrigin());
// $this->createStandardDeleteResponse($request, $response, $taskAttributeValue);
}
/**
* Api method to update TaskAttributeValueL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeValueL11nUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $old */
$old = TaskAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'));
$new = $this->updateAttributeValueL11nFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, TaskAttributeValueL11nMapper::class, 'task_attribute_value_l11n', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete TaskAttributeValueL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAttributeValueL11nDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $taskAttributeValueL11n */
$taskAttributeValueL11n = TaskAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $taskAttributeValueL11n, TaskAttributeValueL11nMapper::class, 'task_attribute_value_l11n', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $taskAttributeValueL11n);
}
}

View File

@ -22,28 +22,15 @@ use Modules\Media\Models\NullMedia;
use Modules\Media\Models\PathSettings;
use Modules\Media\Models\Reference;
use Modules\Media\Models\ReferenceMapper;
use Modules\Tag\Models\NullTag;
use Modules\Tasks\Models\NullTaskAttributeType;
use Modules\Tasks\Models\NullTaskAttributeValue;
use Modules\Tasks\Models\Task;
use Modules\Tasks\Models\TaskAttribute;
use Modules\Tasks\Models\TaskAttributeMapper;
use Modules\Tasks\Models\TaskAttributeType;
use Modules\Tasks\Models\TaskAttributeTypeL11nMapper;
use Modules\Tasks\Models\TaskAttributeTypeMapper;
use Modules\Tasks\Models\TaskAttributeValue;
use Modules\Tasks\Models\TaskAttributeValueL11nMapper;
use Modules\Tasks\Models\TaskAttributeValueMapper;
use Modules\Tasks\Models\TaskElement;
use Modules\Tasks\Models\TaskElementMapper;
use Modules\Tasks\Models\TaskMapper;
use Modules\Tasks\Models\TaskPriority;
use Modules\Tasks\Models\TaskSeen;
use Modules\Tasks\Models\TaskSeenMapper;
use Modules\Tasks\Models\TaskStatus;
use Modules\Tasks\Models\TaskType;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
@ -358,45 +345,28 @@ final class ApiController extends Controller
$task->title = $request->getDataString('title') ?? '';
$task->description = Markdown::parse($request->getDataString('plain') ?? '');
$task->descriptionRaw = $request->getDataString('plain') ?? '';
$task->setCreatedBy(new NullAccount($request->header->account));
$task->setStatus(TaskStatus::OPEN);
$task->setType($request->getDataInt('type') ?? TaskType::SINGLE);
$task->redirect = $request->getDataString('redirect') ?? '';
$task->createdBy = new NullAccount($request->header->account);
$task->for = $request->hasData('for') ? new NullAccount((int) $request->getData('for')) : null;
$task->status = TaskStatus::OPEN;
$task->type = TaskType::tryFromValue($request->getDataInt('type')) ?? TaskType::SINGLE;
$task->redirect = $request->getDataString('redirect') ?? '';
if ($request->hasData('due')) {
$task->due = $request->getDataDateTime('due');
} else {
$task->setPriority((int) $request->getData('priority'));
$task->priority = (int) $request->getData('priority');
}
if (!empty($tags = $request->getDataJson('tags'))) {
foreach ($tags as $tag) {
if (!isset($tag['id'])) {
$request->setData('title', $tag['title'], true);
$request->setData('color', $tag['color'], true);
$request->setData('icon', $tag['icon'] ?? null, true);
$request->setData('language', $tag['language'], true);
$internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse);
if (!\is_array($data = $internalResponse->getDataArray($request->uri->__toString()))) {
continue;
}
$task->addTag($data['response']);
} else {
$task->addTag(new NullTag((int) $tag['id']));
}
}
if ($request->hasData('tags')) {
$task->tags = $this->app->moduleManager->get('Tag', 'Api')->createTagsFromRequest($request);
}
$element = new TaskElement();
$element->addTo(new NullAccount($request->getDataInt('forward') ?? $request->header->account));
$element->createdBy = $task->getCreatedBy();
$element->createdBy = $task->createdBy;
$element->due = $task->due;
$element->setPriority($task->getPriority());
$element->setStatus(TaskStatus::OPEN);
$element->priority = $task->priority;
$element->status = TaskStatus::OPEN;
$task->addElement($element);
@ -467,10 +437,10 @@ final class ApiController extends Controller
$task->description = Markdown::parse($request->getDataString('plain') ?? $task->descriptionRaw);
$task->descriptionRaw = $request->getDataString('plain') ?? $task->descriptionRaw;
$task->due = $request->hasData('due') ? new \DateTime($request->getDataString('due') ?? 'now') : $task->due;
$task->setStatus($request->getDataInt('status') ?? $task->getStatus());
$task->setType($request->getDataInt('type') ?? $task->getType());
$task->setPriority($request->getDataInt('priority') ?? $task->getPriority());
$task->completion = $request->getDataInt('completion') ?? $task->completion;
$task->status = TaskStatus::tryFromValue($request->getDataInt('status')) ?? $task->status;
$task->type = TaskType::tryFromValue($request->getDataInt('type')) ?? $task->type;
$task->priority = TaskPriority::tryFromValue($request->getDataInt('priority')) ?? $task->priority;
$task->completion = $request->getDataInt('completion') ?? $task->completion;
return $task;
}
@ -526,14 +496,14 @@ final class ApiController extends Controller
$task->due = $element->due;
$task->completion = $request->getDataInt('completion') ?? $task->completion;
$task->setPriority($element->getPriority());
$task->setStatus($element->getStatus());
$task->priority = $element->priority;
$task->status = $element->status;
if ($task->getStatus() === TaskStatus::DONE) {
if ($task->status === TaskStatus::DONE) {
$task->completion = 100;
}
$this->createModel($request->header->account, $element, TaskElementMapper::class, 'taskelement', $request->getOrigin());
$this->createModel($request->header->account, $element, TaskElementMapper::class, 'task_element', $request->getOrigin());
if (!empty($request->files)
|| !empty($request->getDataJson('media'))
@ -685,14 +655,15 @@ final class ApiController extends Controller
*/
public function createTaskElementFromRequest(RequestAbstract $request, Task $task) : TaskElement
{
$element = new TaskElement();
$element->createdBy = new NullAccount($request->header->account);
$element->due = $request->getDataDateTime('due') ?? $task->due;
$element->setPriority($request->getDataInt('priority') ?? $task->getPriority());
$element->setStatus((int) ($request->getData('status')));
$element = new TaskElement();
$element->createdBy = new NullAccount($request->header->account);
$element->due = $request->getDataDateTime('due') ?? $task->due;
$element->priority = TaskPriority::tryFromValue($request->getDataInt('priority')) ?? $task->priority;
$element->status = TaskStatus::tryFromValue($request->getDataInt('status')) ?? TaskStatus::OPEN;
$element->task = $task->id;
$element->description = Markdown::parse($request->getDataString('plain') ?? '');
$element->descriptionRaw = $request->getDataString('plain') ?? '';
$element->duration = $request->getDataInt('duration') ?? 0;
$tos = $request->getData('to') ?? $request->header->account;
if (!\is_array($tos)) {
@ -755,18 +726,18 @@ final class ApiController extends Controller
/** @var TaskElement $new */
$new = $this->updateTaskElementFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, TaskElementMapper::class, 'taskelement', $request->getOrigin());
$this->updateModel($request->header->account, $old, $new, TaskElementMapper::class, 'task_element', $request->getOrigin());
if ($old->getStatus() !== $new->getStatus()
|| $old->getPriority() !== $new->getPriority()
if ($old->status !== $new->status
|| $old->priority !== $new->priority
|| $old->due !== $new->due
) {
/** @var Task $task */
$task = TaskMapper::get()->where('id', $new->task)->execute();
$task->setStatus($new->getStatus());
$task->setPriority($new->getPriority());
$task->due = $new->due;
$task->status = $new->status;
$task->priority = $new->priority;
$task->due = $new->due;
$this->updateModel($request->header->account, $task, $task, TaskMapper::class, 'task', $request->getOrigin());
@ -789,8 +760,8 @@ final class ApiController extends Controller
*/
private function updateTaskElementFromRequest(RequestAbstract $request, TaskElement $element) : TaskElement
{
$element->due = $request->getDataDateTime('due') ?? $element->due;
$element->setStatus($request->getDataInt('status') ?? $element->getStatus());
$element->due = $request->getDataDateTime('due') ?? $element->due;
$element->status = TaskStatus::tryFromValue($request->getDataInt('status')) ?? $element->status;
$element->description = Markdown::parse($request->getDataString('plain') ?? $element->descriptionRaw);
$element->descriptionRaw = $request->getDataString('plain') ?? $element->descriptionRaw;
@ -814,377 +785,4 @@ final class ApiController extends Controller
return $element;
}
/**
* Api method to create task attribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateTaskAttributeCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attribute = $this->createTaskAttributeFromRequest($request);
$this->createModel($request->header->account, $attribute, TaskAttributeMapper::class, 'attribute', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attribute);
}
/**
* Method to create task attribute from request.
*
* @param RequestAbstract $request Request
*
* @return TaskAttribute
*
* @since 1.0.0
*/
private function createTaskAttributeFromRequest(RequestAbstract $request) : TaskAttribute
{
$attribute = new TaskAttribute();
$attribute->task = (int) $request->getData('task');
$attribute->type = new NullTaskAttributeType((int) $request->getData('type'));
if ($request->hasData('value_id')) {
$attribute->value = new NullTaskAttributeValue((int) $request->getData('value_id'));
} else {
$newRequest = clone $request;
$newRequest->setData('value', $request->getData('value'), true);
$value = $this->createTaskAttributeValueFromRequest($request);
$attribute->value = $value;
}
return $attribute;
}
/**
* Validate task attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateTaskAttributeCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['type'] = !$request->hasData('type'))
|| ($val['value'] = (!$request->hasData('value') && !$request->hasData('custom')))
|| ($val['task'] = !$request->hasData('task'))
) {
return $val;
}
return [];
}
/**
* Api method to create task attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateTaskAttributeTypeL11nCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrL11n = $this->createTaskAttributeTypeL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, TaskAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrL11n);
}
/**
* Method to create task attribute l11n from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
private function createTaskAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
{
$attrL11n = new BaseStringL11n();
$attrL11n->ref = $request->getDataInt('type') ?? 0;
$attrL11n->setLanguage(
$request->getDataString('language') ?? $request->header->l11n->language
);
$attrL11n->content = $request->getDataString('title') ?? '';
return $attrL11n;
}
/**
* Validate task attribute l11n create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateTaskAttributeTypeL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = !$request->hasData('title'))
|| ($val['type'] = !$request->hasData('type'))
) {
return $val;
}
return [];
}
/**
* Api method to create task attribute type
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateTaskAttributeTypeCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrType = $this->createTaskAttributeTypeFromRequest($request);
$this->createModel($request->header->account, $attrType, TaskAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrType);
}
/**
* Method to create task attribute from request.
*
* @param RequestAbstract $request Request
*
* @return TaskAttributeType
*
* @since 1.0.0
*/
private function createTaskAttributeTypeFromRequest(RequestAbstract $request) : TaskAttributeType
{
$attrType = new TaskAttributeType($request->getDataString('name') ?? '');
$attrType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
$attrType->setFields($request->getDataInt('fields') ?? 0);
$attrType->custom = $request->getDataBool('custom') ?? false;
$attrType->isRequired = $request->getDataBool('is_required') ?? false;
$attrType->validationPattern = $request->getDataString('validation_pattern') ?? '';
return $attrType;
}
/**
* Validate task attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateTaskAttributeTypeCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = !$request->hasData('title'))
|| ($val['name'] = !$request->hasData('name'))
) {
return $val;
}
return [];
}
/**
* Api method to create task attribute value
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateTaskAttributeValueCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrValue = $this->createTaskAttributeValueFromRequest($request);
$this->createModel($request->header->account, $attrValue, TaskAttributeValueMapper::class, 'attr_value', $request->getOrigin());
if ($attrValue->isDefault) {
$this->createModelRelation(
$request->header->account,
(int) $request->getData('attributetype'),
$attrValue->id,
TaskAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
);
}
$this->createStandardCreateResponse($request, $response, $attrValue);
}
/**
* Method to create task attribute value from request.
*
* @param RequestAbstract $request Request
*
* @return TaskAttributeValue
*
* @since 1.0.0
*/
private function createTaskAttributeValueFromRequest(RequestAbstract $request) : TaskAttributeValue
{
/** @var TaskAttributeType $type */
$type = TaskAttributeTypeMapper::get()
->where('id', $request->getDataInt('type') ?? 0)
->execute();
$attrValue = new TaskAttributeValue();
$attrValue->isDefault = $request->getDataBool('default') ?? false;
$attrValue->setValue($request->getDataString('value'), $type->datatype);
if ($request->hasData('title')) {
$attrValue->setL11n(
$request->getDataString('title') ?? '',
$request->getDataString('language') ?? ISO639x1Enum::_EN
);
}
return $attrValue;
}
/**
* Validate task attribute value create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateTaskAttributeValueCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['attributetype'] = !$request->hasData('attributetype'))
|| ($val['value'] = !$request->hasData('value'))
) {
return $val;
}
return [];
}
/**
* Api method to create task attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiTaskAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateTaskAttributeValueL11nCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$attrL11n = $this->createTaskAttributeValueL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, TaskAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrL11n);
}
/**
* Method to create task attribute l11n from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
private function createTaskAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n
{
$attrL11n = new BaseStringL11n();
$attrL11n->ref = $request->getDataInt('value') ?? 0;
$attrL11n->setLanguage(
$request->getDataString('language') ?? $request->header->l11n->language
);
$attrL11n->content = $request->getDataString('title') ?? '';
return $attrL11n;
}
/**
* Validate task attribute l11n create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateTaskAttributeValueL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = !$request->hasData('title'))
|| ($val['value'] = !$request->hasData('value'))
) {
return $val;
}
return [];
}
}

View File

@ -95,7 +95,7 @@ final class BackendController extends Controller implements DashboardElementInte
$view->data['task_media'] = [];
foreach ($view->data['tasks'] as $task) {
$view->data['task_media'][$task->id] = TaskMapper::has()
->with('media')
->with('files')
->where('id', $task->id)
->where('type', TaskType::SINGLE)
->execute();
@ -124,7 +124,7 @@ final class BackendController extends Controller implements DashboardElementInte
foreach ($view->data['open'] as $task) {
$view->data['task_media'][$task->id] = TaskMapper::has()
->with('media')
->with('files')
->where('id', $task->id)
->execute();
}
@ -147,7 +147,7 @@ final class BackendController extends Controller implements DashboardElementInte
foreach ($view->data['given'] as $task) {
$view->data['task_media'][$task->id] = TaskMapper::has()
->with('media')
->with('files')
->where('id', $task->id)
->where('type', TaskType::SINGLE)
->execute();
@ -172,7 +172,7 @@ final class BackendController extends Controller implements DashboardElementInte
foreach ($view->data['unread'] as $task) {
$view->data['task_media'][$task->id] = TaskMapper::has()
->with('media')
->with('files')
->where('id', $task->id)
->where('type', TaskType::SINGLE)
->execute();
@ -253,7 +253,7 @@ final class BackendController extends Controller implements DashboardElementInte
/** @var \Modules\Tasks\Models\Task $task */
$task = TaskMapper::get()
->with('createdBy')
->with('media')
->with('files')
->with('tags')
->with('tags/title')
->with('taskElements')
@ -318,7 +318,7 @@ final class BackendController extends Controller implements DashboardElementInte
$view->data['reminder'] = $reminderStatus;
$view->setTemplate('/Modules/Tasks/Theme/Backend/task-single');
$view->setTemplate('/Modules/Tasks/Theme/Backend/task-view');
$view->data['task'] = $task;
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response);

View File

@ -27,7 +27,7 @@ Version 2.0
Subject to the terms and conditions of this License, each Contributor grants to You after purchase a perpetual, worldwide, non-exclusive, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform the Work and such Derivative Works in Source or Object form. You are not allowed to sublicense, reproduce, or distribute the Work and such Derivative Works in Source or Object form.
3. Redistribution.
3. Redistribution
You may not reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form.

View File

@ -43,7 +43,7 @@ class AccountRelation extends RelationAbstract
*
* @since 1.0.0
*/
public function __construct(Account $account = null, int $duty = DutyType::TO)
public function __construct(?Account $account = null, int $duty = DutyType::TO)
{
$this->relation = $account ?? new NullAccount();
$this->duty = $duty;

View File

@ -51,8 +51,8 @@ final class AccountRelationMapper extends DataMapperFactory
*/
public const OWNS_ONE = [
'relation' => [
'mapper' => AccountMapper::class,
'external' => 'task_account_account',
'mapper' => AccountMapper::class,
'external' => 'task_account_account',
],
];

View File

@ -4,7 +4,7 @@
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
@ -12,19 +12,20 @@
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
namespace Modules\Tasks\Models\Attribute;
use Modules\Attribute\Models\Attribute;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Task mapper class.
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of TaskAttribute
* @template T of Attribute
* @extends DataMapperFactory<T>
*/
final class TaskAttributeMapper extends DataMapperFactory
@ -37,7 +38,7 @@ final class TaskAttributeMapper extends DataMapperFactory
*/
public const COLUMNS = [
'task_attr_id' => ['name' => 'task_attr_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_task' => ['name' => 'task_attr_task', 'type' => 'int', 'internal' => 'task'],
'task_attr_item' => ['name' => 'task_attr_item', 'type' => 'int', 'internal' => 'ref'],
'task_attr_type' => ['name' => 'task_attr_type', 'type' => 'int', 'internal' => 'type'],
'task_attr_value' => ['name' => 'task_attr_value', 'type' => 'int', 'internal' => 'value'],
];
@ -59,6 +60,14 @@ final class TaskAttributeMapper extends DataMapperFactory
],
];
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = Attribute::class;
/**
* Primary table.
*

View File

@ -4,7 +4,7 @@
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
@ -12,7 +12,7 @@
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
namespace Modules\Tasks\Models\Attribute;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
@ -20,7 +20,7 @@ use phpOMS\Localization\BaseStringL11n;
/**
* Task mapper class.
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0

View File

@ -4,7 +4,7 @@
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
@ -12,19 +12,20 @@
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
namespace Modules\Tasks\Models\Attribute;
use Modules\Attribute\Models\AttributeType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Task mapper class.
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of TaskAttributeType
* @template T of AttributeType
* @extends DataMapperFactory<T>
*/
final class TaskAttributeTypeMapper extends DataMapperFactory
@ -36,12 +37,15 @@ final class TaskAttributeTypeMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'task_attr_type_id' => ['name' => 'task_attr_type_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_type_name' => ['name' => 'task_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'task_attr_type_fields' => ['name' => 'task_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
'task_attr_type_custom' => ['name' => 'task_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
'task_attr_type_pattern' => ['name' => 'task_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
'task_attr_type_required' => ['name' => 'task_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
'task_attr_type_id' => ['name' => 'task_attr_type_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_type_name' => ['name' => 'task_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'task_attr_type_datatype' => ['name' => 'task_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'],
'task_attr_type_fields' => ['name' => 'task_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
'task_attr_type_custom' => ['name' => 'task_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
'task_attr_type_repeatable' => ['name' => 'task_attr_type_repeatable', 'type' => 'bool', 'internal' => 'repeatable'],
'task_attr_type_internal' => ['name' => 'task_attr_type_internal', 'type' => 'bool', 'internal' => 'isInternal'],
'task_attr_type_pattern' => ['name' => 'task_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
'task_attr_type_required' => ['name' => 'task_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
];
/**
@ -66,6 +70,14 @@ final class TaskAttributeTypeMapper extends DataMapperFactory
],
];
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = AttributeType::class;
/**
* Primary table.
*

View File

@ -4,7 +4,7 @@
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
@ -12,7 +12,7 @@
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
namespace Modules\Tasks\Models\Attribute;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
@ -20,7 +20,7 @@ use phpOMS\Localization\BaseStringL11n;
/**
* Task mapper class.
*
* @package Modules\Tasks\Models
* @package Modules\Tasks\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
@ -37,10 +37,10 @@ final class TaskAttributeValueL11nMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'task_attr_value_l11n_id' => ['name' => 'task_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_value_l11n_title' => ['name' => 'task_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'task_attr_value_l11n_value' => ['name' => 'task_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
'task_attr_value_l11n_lang' => ['name' => 'task_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
'task_attr_value_l11n_id' => ['name' => 'task_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_value_l11n_title' => ['name' => 'task_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'task_attr_value_l11n_value' => ['name' => 'task_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
'task_attr_value_l11n_lang' => ['name' => 'task_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**

View File

@ -0,0 +1,90 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models\Attribute;
use Modules\Attribute\Models\AttributeValue;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Task mapper class.
*
* @package Modules\Tasks\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of AttributeValue
* @extends DataMapperFactory<T>
*/
final class TaskAttributeValueMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'task_attr_value_id' => ['name' => 'task_attr_value_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_value_default' => ['name' => 'task_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
'task_attr_value_valueStr' => ['name' => 'task_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
'task_attr_value_valueInt' => ['name' => 'task_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
'task_attr_value_valueDec' => ['name' => 'task_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
'task_attr_value_valueDat' => ['name' => 'task_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
'task_attr_value_unit' => ['name' => 'task_attr_value_unit', 'type' => 'string', 'internal' => 'unit'],
'task_attr_value_deptype' => ['name' => 'task_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'],
'task_attr_value_depvalue' => ['name' => 'task_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [
'l11n' => [
'mapper' => TaskAttributeValueL11nMapper::class,
'table' => 'task_attr_value_l11n',
'self' => 'task_attr_value_l11n_value',
'column' => 'content',
'external' => null,
],
];
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = AttributeValue::class;
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'task_attr_value';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'task_attr_value_id';
}

View File

@ -1,40 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Attribute value type enum.
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class AttributeValueType extends Enum
{
public const _INT = 1;
public const _STRING = 2;
public const _FLOAT = 3;
public const _DATETIME = 4;
public const _BOOL = 5;
public const _FLOAT_INT = 6;
}

View File

@ -43,7 +43,7 @@ class GroupRelation extends RelationAbstract
*
* @since 1.0.0
*/
public function __construct(Group $group = null, int $duty = DutyType::TO)
public function __construct(?Group $group = null, int $duty = DutyType::TO)
{
$this->relation = $group ?? new NullGroup();
$this->duty = $duty;

View File

@ -51,8 +51,8 @@ final class GroupRelationMapper extends DataMapperFactory
*/
public const OWNS_ONE = [
'relation' => [
'mapper' => GroupMapper::class,
'external' => 'task_group_group',
'mapper' => GroupMapper::class,
'external' => 'task_group_group',
],
];

View File

@ -1,47 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
/**
* Null model
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullTaskAttribute extends TaskAttribute
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
parent::__construct();
$this->id = $id;
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
}

View File

@ -1,46 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
/**
* Null model
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullTaskAttributeType extends TaskAttributeType
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
}

View File

@ -1,46 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
/**
* Null model
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullTaskAttributeValue extends TaskAttributeValue
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
}

View File

@ -51,18 +51,6 @@ abstract class RelationAbstract implements \JsonSerializable
*/
public int $element = 0;
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set the duty (TO or CC)
*

View File

@ -17,10 +17,7 @@ namespace Modules\Tasks\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use Modules\Calendar\Models\Schedule;
use Modules\Media\Models\Media;
use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
/**
* Task class.
@ -124,14 +121,6 @@ class Task implements \JsonSerializable
*/
public int $completion = -1;
/**
* Attributes.
*
* @var TaskAttribute[]
* @since 1.0.0
*/
public array $attributes = [];
/**
* Task can be closed by user.
*
@ -209,12 +198,15 @@ class Task implements \JsonSerializable
public int $priority = TaskPriority::NONE;
/**
* Media files
* Account this ticket is for
*
* @var array
* This is not the person who is working on the ticket but the person who needs help.
* This can be different from the person who created it.
*
* @var null|Account
* @since 1.0.0
*/
public array $media = [];
public ?Account $for = null;
/**
* Constructor.
@ -271,32 +263,6 @@ class Task implements \JsonSerializable
return $key;
}
/**
* Get all media
*
* @return Media[]
*
* @since 1.0.0
*/
public function getMedia() : array
{
return $this->media;
}
/**
* Add media
*
* @param Media $media Media to add
*
* @return void
*
* @since 1.0.0
*/
public function addMedia(Media $media) : void
{
$this->media[] = $media;
}
/**
* Check if user is in to
*
@ -404,70 +370,6 @@ class Task implements \JsonSerializable
$this->schedule->createdBy = $account;
}
/**
* Get status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set status
*
* @param int $status Task status
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
if (!TaskStatus::isValidValue($status)) {
throw new InvalidEnumValue((string) $status);
}
$this->status = $status;
}
/**
* Get priority
*
* @return int
*
* @since 1.0.0
*/
public function getPriority() : int
{
return $this->priority;
}
/**
* Set priority
*
* @param int $priority Task priority
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setPriority(int $priority) : void
{
if (!TaskPriority::isValidValue($priority)) {
throw new InvalidEnumValue((string) $priority);
}
$this->priority = $priority;
}
/**
* Remove Element from list.
*
@ -488,52 +390,6 @@ class Task implements \JsonSerializable
return false;
}
/**
* Remove Tag from list.
*
* @param int $id Tag
*
* @return bool
*
* @since 1.0.0
*/
public function removeTag($id) : bool
{
if (isset($this->tags[$id])) {
unset($this->tags[$id]);
return true;
}
return false;
}
/**
* Get task elements.
*
* @return Tag[]
*
* @since 1.0.0
*/
public function getTags() : array
{
return $this->tags;
}
/**
* Get task elements.
*
* @param int $id Element id
*
* @return Tag
*
* @since 1.0.0
*/
public function getTag(int $id) : Tag
{
return $this->tags[$id] ?? new NullTag();
}
/**
* Get task elements.
*
@ -572,99 +428,6 @@ class Task implements \JsonSerializable
return $this->taskElements[$id] ?? new NullTaskElement();
}
/**
* Get task type.
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Set task type.
*
* @param int $type Task type
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type = TaskType::SINGLE) : void
{
$this->type = $type;
}
/**
* Add attribute to item
*
* @param TaskAttribute $attribute Note
*
* @return void
*
* @since 1.0.0
*/
public function addAttribute(TaskAttribute $attribute) : void
{
$this->attributes[] = $attribute;
}
/**
* Get attributes
*
* @return TaskAttribute[]
*
* @since 1.0.0
*/
public function getAttributes() : array
{
return $this->attributes;
}
/**
* Has attribute value
*
* @param string $attrName Attribute name
* @param mixed $attrValue Attribute value
*
* @return bool
*
* @since 1.0.0
*/
public function hasAttributeValue(string $attrName, mixed $attrValue) : bool
{
foreach ($this->attributes as $attribute) {
if ($attribute->type->name === $attrName && $attribute->value->getValue() === $attrValue) {
return true;
}
}
return false;
}
/**
* Get attribute
*
* @param string $attrName Attribute name
*
* @return null|TaskAttributeValue
*
* @since 1.0.0
*/
public function getAttribute(string $attrName) : ?TaskAttributeValue
{
foreach ($this->attributes as $attribute) {
if ($attribute->type->name === $attrName) {
return $attribute->value;
}
}
return null;
}
/**
* {@inheritdoc}
*/
@ -693,4 +456,7 @@ class Task implements \JsonSerializable
{
return $this->toArray();
}
use \Modules\Media\Models\MediaListTrait;
use \Modules\Attribute\Models\AttributeHolderTrait;
}

View File

@ -1,90 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
/**
* Task class.
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class TaskAttribute implements \JsonSerializable
{
/**
* Id.
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Task this attribute belongs to
*
* @var int
* @since 1.0.0
*/
public int $task = 0;
/**
* Attribute type the attribute belongs to
*
* @var TaskAttributeType
* @since 1.0.0
*/
public TaskAttributeType $type;
/**
* Attribute value the attribute belongs to
*
* @var TaskAttributeValue
* @since 1.0.0
*/
public TaskAttributeValue $value;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->type = new NullTaskAttributeType();
$this->value = new NullTaskAttributeValue();
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'task' => $this->task,
'type' => $this->type,
'value' => $this->value,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

View File

@ -1,193 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum;
/**
* Task Attribute Type class.
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class TaskAttributeType implements \JsonSerializable
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Name/string identifier by which it can be found/categorized
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* Which field data type is required (string, int, ...) in the value
*
* @var int
* @since 1.0.0
*/
public int $fields = 0;
/**
* Is a custom value allowed (e.g. custom string)
*
* @var bool
* @since 1.0.0
*/
public bool $custom = false;
public string $validationPattern = '';
public bool $isRequired = false;
/**
* Datatype of the attribute
*
* @var int
* @since 1.0.0
*/
public int $datatype = AttributeValueType::_STRING;
/**
* Localization
*
* @var BaseStringL11n
*/
public string | BaseStringL11n $l11n = '';
/**
* Possible default attribute values
*
* @var array
*/
public array $defaults = [];
/**
* Default attribute value
*
* @var int
* @since 1.0.0
*/
public int $default = 0;
/**
* Constructor.
*
* @param string $name Name/identifier of the attribute type
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
}
/**
* Set l11n
*
* @param string|BaseStringL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof BaseStringL11n) {
$this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
} else {
$this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
if (!isset($this->l11n)) {
return '';
}
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
}
/**
* Set fields
*
* @param int $fields Fields
*
* @return void
*
* @since 1.0.0
*/
public function setFields(int $fields) : void
{
$this->fields = $fields;
}
/**
* Get default values
*
* @return array
*
* @sicne 1.0.0
*/
public function getDefaults() : array
{
return $this->defaults;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'validationPattern' => $this->validationPattern,
'custom' => $this->custom,
'isRequired' => $this->isRequired,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

View File

@ -1,217 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum;
/**
* Task attribute value class.
*
* The relation with the type/task is defined in the TaskAttribute class.
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class TaskAttributeValue implements \JsonSerializable
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Depending attribute type
*
* @var null|int
* @since 1.0.0
*/
public ?int $dependingAttributeType = null;
/**
* Depending attribute value
*
* @var null|int
* @since 1.0.0
*/
public ?int $dependingAttributeValue = null;
/**
* Int value
*
* @var null|int
* @since 1.0.0
*/
public ?int $valueInt = null;
/**
* String value
*
* @var null|string
* @since 1.0.0
*/
public ?string $valueStr = null;
/**
* Decimal value
*
* @var null|float
* @since 1.0.0
*/
public ?float $valueDec = null;
/**
* DateTime value
*
* @var null|\DateTimeInterface
* @since 1.0.0
*/
public ?\DateTimeInterface $valueDat = null;
/**
* Is a default value which can be selected
*
* @var bool
* @since 1.0.0
*/
public bool $isDefault = false;
/**
* Unit of the value
*
* @var string
* @since 1.0.0
*/
public string $unit = '';
/**
* Localization
*
* @var string|BaseStringL11n
*/
public string | BaseStringL11n $l11n = '';
/**
* Set l11n
*
* @param string|BaseStringL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof BaseStringL11n) {
$this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
} else {
$this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n;
$this->l11n->ref = $this->id;
$this->l11n->setLanguage($lang);
}
}
/**
* Get localization
*
* @return null|string
*
* @since 1.0.0
*/
public function getL11n() : ?string
{
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
}
/**
* Set value
*
* @param null|int|string|float $value Value
*
* @return void
*
* @since 1.0.0
*/
public function setValue(mixed $value, int $datatype) : void
{
if ($datatype === AttributeValueType::_STRING) {
$this->valueStr = (string) $value;
} elseif ($datatype === AttributeValueType::_INT
|| $datatype === AttributeValueType::_FLOAT_INT
|| $datatype === AttributeValueType::_BOOL
) {
$this->valueInt = (int) $value;
} elseif ($datatype === AttributeValueType::_FLOAT) {
$this->valueDec = (float) $value;
} elseif ($datatype === AttributeValueType::_DATETIME) {
$this->valueDat = new \DateTime((string) $value);
}
}
/**
* Get value
*
* @return null|int|string|float|\DateTimeInterface
*
* @since 1.0.0
*/
public function getValue() : mixed
{
if (!empty($this->valueStr)) {
return $this->valueStr;
} elseif (!empty($this->valueInt)) {
return $this->valueInt;
} elseif (!empty($this->valueDec)) {
return $this->valueDec;
} elseif ($this->valueDat instanceof \DateTimeInterface) {
return $this->valueDat;
}
return null;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'valueInt' => $this->valueInt,
'valueStr' => $this->valueStr,
'valueDec' => $this->valueDec,
'valueDat' => $this->valueDat,
'isDefault' => $this->isDefault,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

View File

@ -1,79 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Task mapper class.
*
* @package Modules\Tasks\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of TaskAttributeValue
* @extends DataMapperFactory<T>
*/
final class TaskAttributeValueMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'task_attr_value_id' => ['name' => 'task_attr_value_id', 'type' => 'int', 'internal' => 'id'],
'task_attr_value_default' => ['name' => 'task_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
'task_attr_value_valueStr' => ['name' => 'task_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
'task_attr_value_valueInt' => ['name' => 'task_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
'task_attr_value_valueDec' => ['name' => 'task_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
'task_attr_value_valueDat' => ['name' => 'task_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
'task_attr_value_unit' => ['name' => 'task_attr_value_unit', 'type' => 'string', 'internal' => 'unit'],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [
'l11n' => [
'mapper' => TaskAttributeValueL11nMapper::class,
'table' => 'task_attr_value_l11n',
'self' => 'task_attr_value_l11n_value',
'column' => 'content',
'external' => null,
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'task_attr_value';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'task_attr_value_id';
}

View File

@ -17,8 +17,6 @@ namespace Modules\Tasks\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\Group;
use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media;
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
/**
* Task element class.
@ -102,14 +100,6 @@ class TaskElement implements \JsonSerializable
*/
public int $priority = TaskPriority::NONE;
/**
* Media.
*
* @var Media[]
* @since 1.0.0
*/
public array $media = [];
/**
* Accounts who received this task element.
*
@ -126,6 +116,8 @@ class TaskElement implements \JsonSerializable
*/
public array $grpRelation = [];
public int $duration = 0;
/**
* Constructor.
*
@ -139,64 +131,6 @@ class TaskElement implements \JsonSerializable
$this->createdBy = new NullAccount();
}
/**
* Get all media
*
* @return Media[]
*
* @since 1.0.0
*/
public function getMedia() : array
{
return $this->media;
}
/**
* Add media
*
* @param Media $media Media to add
*
* @return void
*
* @since 1.0.0
*/
public function addMedia(Media $media) : void
{
$this->media[] = $media;
}
/**
* Get priority
*
* @return int
*
* @since 1.0.0
*/
public function getPriority() : int
{
return $this->priority;
}
/**
* Set priority
*
* @param int $priority Task priority
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setPriority(int $priority) : void
{
if (!TaskPriority::isValidValue($priority)) {
throw new InvalidEnumValue((string) $priority);
}
$this->priority = $priority;
}
/**
* Get to
*
@ -469,38 +403,6 @@ class TaskElement implements \JsonSerializable
$this->accRelation[] = new AccountRelation($account, DutyType::CC);
}
/**
* Get status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set Status
*
* @param int $status Task element status
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
if (!TaskStatus::isValidValue($status)) {
throw new InvalidEnumValue((string) $status);
}
$this->status = $status;
}
/**
* {@inheritdoc}
*/
@ -527,4 +429,6 @@ class TaskElement implements \JsonSerializable
{
return $this->toArray();
}
use \Modules\Media\Models\MediaListTrait;
}

View File

@ -56,23 +56,23 @@ final class TaskElementMapper extends DataMapperFactory
* @since 1.0.0
*/
public const HAS_MANY = [
'media' => [
'files' => [
'mapper' => MediaMapper::class,
'table' => 'task_element_media',
'external' => 'task_element_media_dst',
'self' => 'task_element_media_src',
],
'accRelation' => [
'mapper' => AccountRelationMapper::class,
'table' => 'task_account',
'self' => 'task_account_task_element',
'external' => null,
'accRelation' => [
'mapper' => AccountRelationMapper::class,
'table' => 'task_account',
'self' => 'task_account_task_element',
'external' => null,
],
'grpRelation' => [
'mapper' => GroupRelationMapper::class,
'table' => 'task_group',
'self' => 'task_group_task_element',
'external' => null,
'grpRelation' => [
'mapper' => GroupRelationMapper::class,
'table' => 'task_group',
'self' => 'task_group_task_element',
'external' => null,
],
];
@ -84,8 +84,8 @@ final class TaskElementMapper extends DataMapperFactory
*/
public const BELONGS_TO = [
'createdBy' => [
'mapper' => AccountMapper::class,
'external' => 'task_element_created_by',
'mapper' => AccountMapper::class,
'external' => 'task_element_created_by',
],
];

View File

@ -18,6 +18,7 @@ use Modules\Admin\Models\AccountMapper;
use Modules\Calendar\Models\ScheduleMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Tag\Models\TagMapper;
use Modules\Tasks\Models\Attribute\TaskAttributeMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Mapper\ReadMapper;
use phpOMS\DataStorage\Database\Query\Builder;
@ -43,24 +44,25 @@ final class TaskMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'task_id' => ['name' => 'task_id', 'type' => 'int', 'internal' => 'id'],
'task_title' => ['name' => 'task_title', 'type' => 'string', 'internal' => 'title'],
'task_desc' => ['name' => 'task_desc', 'type' => 'string', 'internal' => 'description'],
'task_desc_raw' => ['name' => 'task_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'task_type' => ['name' => 'task_type', 'type' => 'int', 'internal' => 'type'],
'task_status' => ['name' => 'task_status', 'type' => 'int', 'internal' => 'status'],
'task_completion' => ['name' => 'task_completion', 'type' => 'int', 'internal' => 'completion'],
'task_closable' => ['name' => 'task_closable', 'type' => 'bool', 'internal' => 'isClosable'],
'task_editable' => ['name' => 'task_editable', 'type' => 'bool', 'internal' => 'isEditable'],
'task_priority' => ['name' => 'task_priority', 'type' => 'int', 'internal' => 'priority'],
'task_due' => ['name' => 'task_due', 'type' => 'DateTime', 'internal' => 'due'],
'task_done' => ['name' => 'task_done', 'type' => 'DateTime', 'internal' => 'done'],
'task_schedule' => ['name' => 'task_schedule', 'type' => 'int', 'internal' => 'schedule'],
'task_start' => ['name' => 'task_start', 'type' => 'DateTime', 'internal' => 'start'],
'task_redirect' => ['name' => 'task_redirect', 'type' => 'string', 'internal' => 'redirect'],
'task_trigger' => ['name' => 'task_trigger', 'type' => 'string', 'internal' => 'trigger'],
'task_created_by' => ['name' => 'task_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'task_created_at' => ['name' => 'task_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
'task_id' => ['name' => 'task_id', 'type' => 'int', 'internal' => 'id'],
'task_title' => ['name' => 'task_title', 'type' => 'string', 'internal' => 'title'],
'task_desc' => ['name' => 'task_desc', 'type' => 'string', 'internal' => 'description'],
'task_desc_raw' => ['name' => 'task_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'task_type' => ['name' => 'task_type', 'type' => 'int', 'internal' => 'type'],
'task_status' => ['name' => 'task_status', 'type' => 'int', 'internal' => 'status'],
'task_completion' => ['name' => 'task_completion', 'type' => 'int', 'internal' => 'completion'],
'task_closable' => ['name' => 'task_closable', 'type' => 'bool', 'internal' => 'isClosable'],
'task_editable' => ['name' => 'task_editable', 'type' => 'bool', 'internal' => 'isEditable'],
'task_priority' => ['name' => 'task_priority', 'type' => 'int', 'internal' => 'priority'],
'task_due' => ['name' => 'task_due', 'type' => 'DateTime', 'internal' => 'due'],
'task_done' => ['name' => 'task_done', 'type' => 'DateTime', 'internal' => 'done'],
'task_schedule' => ['name' => 'task_schedule', 'type' => 'int', 'internal' => 'schedule'],
'task_start' => ['name' => 'task_start', 'type' => 'DateTime', 'internal' => 'start'],
'task_redirect' => ['name' => 'task_redirect', 'type' => 'string', 'internal' => 'redirect'],
'task_trigger' => ['name' => 'task_trigger', 'type' => 'string', 'internal' => 'trigger'],
'task_created_by' => ['name' => 'task_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'task_for' => ['name' => 'task_for', 'type' => 'int', 'internal' => 'for'],
'task_created_at' => ['name' => 'task_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**
@ -71,18 +73,18 @@ final class TaskMapper extends DataMapperFactory
*/
public const HAS_MANY = [
'taskElements' => [
'mapper' => TaskElementMapper::class,
'table' => 'task_element',
'self' => 'task_element_task',
'external' => null,
'mapper' => TaskElementMapper::class,
'table' => 'task_element',
'self' => 'task_element_task',
'external' => null,
],
'media' => [
'files' => [
'mapper' => MediaMapper::class,
'table' => 'task_media',
'external' => 'task_media_dst',
'self' => 'task_media_src',
],
'tags' => [
'tags' => [
'mapper' => TagMapper::class,
'table' => 'task_tag',
'external' => 'task_tag_dst',
@ -104,8 +106,8 @@ final class TaskMapper extends DataMapperFactory
*/
public const BELONGS_TO = [
'createdBy' => [
'mapper' => AccountMapper::class,
'external' => 'task_created_by',
'mapper' => AccountMapper::class,
'external' => 'task_created_by',
],
];
@ -117,8 +119,12 @@ final class TaskMapper extends DataMapperFactory
*/
public const OWNS_ONE = [
'schedule' => [
'mapper' => ScheduleMapper::class,
'external' => 'task_schedule',
'mapper' => ScheduleMapper::class,
'external' => 'task_schedule',
],
'for' => [
'mapper' => AccountMapper::class,
'external' => 'task_for',
],
];

View File

@ -40,13 +40,13 @@ final class TaskSeenMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'task_seen_id' => ['name' => 'task_seen_id', 'type' => 'int', 'internal' => 'id'],
'task_seen_at' => ['name' => 'task_seen_at', 'type' => 'DateTime', 'internal' => 'seenAt'],
'task_seen_task' => ['name' => 'task_seen_task', 'type' => 'int', 'internal' => 'task'],
'task_seen_by' => ['name' => 'task_seen_by', 'type' => 'int', 'internal' => 'seenBy'],
'task_seen_reminder' => ['name' => 'task_seen_reminder', 'type' => 'bool', 'internal' => 'isRemindered'],
'task_seen_reminder_at' => ['name' => 'task_seen_reminder_at', 'type' => 'DateTime', 'internal' => 'reminderAt'],
'task_seen_reminder_by' => ['name' => 'task_seen_reminder_by', 'type' => 'int', 'internal' => 'reminderBy'],
'task_seen_id' => ['name' => 'task_seen_id', 'type' => 'int', 'internal' => 'id'],
'task_seen_at' => ['name' => 'task_seen_at', 'type' => 'DateTime', 'internal' => 'seenAt'],
'task_seen_task' => ['name' => 'task_seen_task', 'type' => 'int', 'internal' => 'task'],
'task_seen_by' => ['name' => 'task_seen_by', 'type' => 'int', 'internal' => 'seenBy'],
'task_seen_reminder' => ['name' => 'task_seen_reminder', 'type' => 'bool', 'internal' => 'isRemindered'],
'task_seen_reminder_at' => ['name' => 'task_seen_reminder_at', 'type' => 'DateTime', 'internal' => 'reminderAt'],
'task_seen_reminder_by' => ['name' => 'task_seen_reminder_by', 'type' => 'int', 'internal' => 'reminderBy'],
];
/**
@ -57,8 +57,8 @@ final class TaskSeenMapper extends DataMapperFactory
*/
public const BELONGS_TO = [
'reminderBy' => [
'mapper' => AccountMapper::class,
'external' => 'task_seen_reminder_by',
'mapper' => AccountMapper::class,
'external' => 'task_seen_reminder_by',
],
];

View File

@ -31,21 +31,21 @@ use phpOMS\Uri\UriFactory;
<?php
$c = 0;
foreach ($this->tasks as $key => $task) : ++$c;
$url = UriFactory::build(empty($task->redirect) ? 'task/single?{?}&id=' . $task->id : ($task->redirect));
$url = UriFactory::build(empty($task->redirect) ? 'task/view?{?}&id=' . $task->id : ($task->redirect));
$color = 'darkred';
if ($task->getStatus() === TaskStatus::DONE) { $color = 'green'; }
elseif ($task->getStatus() === TaskStatus::OPEN) { $color = 'darkblue'; }
elseif ($task->getStatus() === TaskStatus::WORKING) { $color = 'purple'; }
elseif ($task->getStatus() === TaskStatus::CANCELED) { $color = 'red'; }
elseif ($task->getStatus() === TaskStatus::SUSPENDED) { $color = 'yellow'; } ?>
$color = 'darkred';
if ($task->status === TaskStatus::DONE) { $color = 'green'; }
elseif ($task->status === TaskStatus::OPEN) { $color = 'darkblue'; }
elseif ($task->status === TaskStatus::WORKING) { $color = 'purple'; }
elseif ($task->status === TaskStatus::CANCELED) { $color = 'red'; }
elseif ($task->status === TaskStatus::SUSPENDED) { $color = 'yellow'; } ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('S' . $task->getStatus(), 'Tasks'); ?></span></a>
<td><a href="<?= $url; ?>"><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('S' . $task->status, 'Tasks'); ?></span></a>
<td><a href="<?= $url; ?>">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->printHtml($task->due->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($task->title); ?></a>
@ -56,4 +56,4 @@ use phpOMS\Uri\UriFactory;
</table>
<div class="portlet-foot"></div>
</div>
</div>
</div>

View File

@ -1,3 +1,8 @@
<?php declare(strict_types=1);
use Modules\Tasks\Models\TaskStatus;
?>
<div class="ipt-wrap">
<div class="ipt-first">
<span class="input">
@ -7,7 +12,7 @@
data-src="api/admin/find/accgrp?search={!#i<?= $this->id; ?>}">
<template><!-- Template for the selected element --></template>
</div>
<div id="<?= $this->id; ?>-popup" class="popup" data-active="true" data-selected="<?= $task->getStatus(); ?>">
<div id="<?= $this->id; ?>-popup" class="popup" data-active="true" data-selected="<?= $task->status; ?>">
<template class="rowTemplate"><!-- Template for remote data or data manually to be added --></template>
<tr><td data-value="<?= TaskStatus::OPEN; ?>"><?= $this->getHtml('S1'); ?>
<tr><td data-value="<?= TaskStatus::WORKING; ?>"><?= $this->getHtml('S2'); ?>

View File

@ -51,6 +51,7 @@ return ['Tasks' => [
'Status' => 'Status',
'Tag' => 'Tag',
'Task' => 'Task',
'Tasks' => 'Tasks',
'Title' => 'Title',
'To' => 'To',
'Unread' => 'Unread',

View File

@ -33,20 +33,20 @@ $tasksList = $this->data['tasks'] ?? [];
$c = 0;
foreach ($tasksList as $key => $task) : ++$c;
$url = UriFactory::build(empty($task->redirect)
? '{/base}/task/single?{?}&id=' . $task->id
? '{/base}/task/view?{?}&id=' . $task->id
: ($task->redirect)
);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>">
<span class="tag <?= $this->printHtml('task-status-' . $task->getStatus()); ?>">
<?= $this->getHtml('S' . $task->getStatus(), 'Tasks'); ?>
<span class="tag <?= $this->printHtml('task-status-' . $task->status); ?>">
<?= $this->getHtml('S' . $task->status, 'Tasks'); ?>
</span></a>
<td><a href="<?= $url; ?>">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->printHtml($task->due->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($task->title); ?></a>

View File

@ -55,7 +55,7 @@ echo $this->data['nav']->render(); ?>
$c = 0;
foreach ($open as $key => $task) : ++$c;
$url = UriFactory::build(empty($task->redirect)
? '{/base}/task/single?{?}&id=' . $task->id
? '{/base}/task/view?{?}&id=' . $task->id
: ('{/app}/' . $task->redirect),
['$id' => $task->id]
);
@ -63,23 +63,23 @@ echo $this->data['nav']->render(); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Status'); ?>">
<a href="<?= $url; ?>">
<span class="tag <?= $this->printHtml('task-status-' . $task->getStatus()); ?>">
<?= $this->getHtml('S' . $task->getStatus()); ?>
<span class="tag <?= $this->printHtml('task-status-' . $task->status); ?>">
<?= $this->getHtml('S' . $task->status); ?>
</span>
</a>
<td data-label="<?= $this->getHtml('Due/Priority'); ?>">
<a href="<?= $url; ?>">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->printHtml($task->due->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</a>
<td><?= ($this->data['task_media'][$task->id] ?? false) === true ? '<i class="g-icon">attachment</i>' : ''; ?>
<td data-label="<?= $this->getHtml('Title'); ?>">
<a href="<?= $url; ?>"><?= $this->printHtml($task->title); ?></a>
<td data-label="<?= $this->getHtml('Tag'); ?>">
<?php $tags = $task->getTags(); foreach ($tags as $tag) : ?>
<?php foreach ($task->tags as $tag) : ?>
<a href="<?= $url; ?>">
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
<?= empty($tag->icon) ? '' : ''; ?>
@ -88,7 +88,7 @@ echo $this->data['nav']->render(); ?>
</a>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Creator'); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $task->createdBy->id); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $task->createdBy->id); ?>">
<?= $this->printHtml($this->renderUserName(
'%3$s %2$s %1$s',
[
@ -129,7 +129,7 @@ echo $this->data['nav']->render(); ?>
$c = 0;
foreach ($this->data['given'] as $key => $task) : ++$c;
$url = UriFactory::build(empty($task->redirect)
? '{/base}/task/single?{?}&id=' . $task->id
? '{/base}/task/view?{?}&id=' . $task->id
: ('{/app}/' . $task->redirect),
['$id' => $task->id]
);
@ -137,23 +137,23 @@ echo $this->data['nav']->render(); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Status'); ?>">
<a href="<?= $url; ?>">
<span class="tag <?= $this->printHtml('task-status-' . $task->getStatus()); ?>">
<?= $this->getHtml('S' . $task->getStatus()); ?>
<span class="tag <?= $this->printHtml('task-status-' . $task->status); ?>">
<?= $this->getHtml('S' . $task->status); ?>
</span>
</a>
<td data-label="<?= $this->getHtml('Due/Priority'); ?>">
<a href="<?= $url; ?>">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->printHtml($task->due->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</a>
<td><?= ($this->data['task_media'][$task->id] ?? false) === true ? '<i class="g-icon">attachment</i>' : ''; ?>
<td data-label="<?= $this->getHtml('Title'); ?>">
<a href="<?= $url; ?>"><?= $this->printHtml($task->title); ?></a>
<td data-label="<?= $this->getHtml('Tag'); ?>">
<?php $tags = $task->getTags(); foreach ($tags as $tag) : ?>
<?php foreach ($task->tags as $tag) : ?>
<a href="<?= $url; ?>">
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
<?= empty($tag->icon) ? '' : ''; ?>
@ -162,7 +162,7 @@ echo $this->data['nav']->render(); ?>
</a>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Creator'); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $task->createdBy->id); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $task->createdBy->id); ?>">
<?= $this->printHtml($this->renderUserName(
'%3$s %2$s %1$s',
[
@ -208,7 +208,7 @@ echo $this->data['nav']->render(); ?>
++$c;
$url = UriFactory::build(empty($task->redirect)
? '{/base}/task/single?{?}&id=' . $task->id
? '{/base}/task/view?{?}&id=' . $task->id
: ('{/app}/' . $task->redirect),
['$id' => $task->id]
);
@ -216,23 +216,23 @@ echo $this->data['nav']->render(); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Status'); ?>">
<a href="<?= $url; ?>">
<span class="tag <?= $this->printHtml('task-status-' . $task->getStatus()); ?>">
<?= $this->getHtml('S' . $task->getStatus()); ?>
<span class="tag <?= $this->printHtml('task-status-' . $task->status); ?>">
<?= $this->getHtml('S' . $task->status); ?>
</span>
</a>
<td data-label="<?= $this->getHtml('Due/Priority'); ?>">
<a href="<?= $url; ?>">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->printHtml($task->due->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</a>
<td><?= ($this->data['task_media'][$task->id] ?? false) === true ? '<i class="g-icon">attachment</i>' : ''; ?>
<td data-label="<?= $this->getHtml('Title'); ?>">
<a href="<?= $url; ?>"><?= $this->printHtml($task->title); ?></a>
<td data-label="<?= $this->getHtml('Tag'); ?>">
<?php $tags = $task->getTags(); foreach ($tags as $tag) : ?>
<?php foreach ($task->tags as $tag) : ?>
<a href="<?= $url; ?>">
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
<?= empty($tag->icon) ? '' : ''; ?>
@ -241,7 +241,7 @@ echo $this->data['nav']->render(); ?>
</a>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Creator'); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $task->createdBy->id); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $task->createdBy->id); ?>">
<?= $this->printHtml($this->renderUserName(
'%3$s %2$s %1$s',
[
@ -293,7 +293,7 @@ echo $this->data['nav']->render(); ?>
}
$url = UriFactory::build(empty($task->redirect)
? '{/base}/task/single?{?}&id=' . $task->id
? '{/base}/task/view?{?}&id=' . $task->id
: ('{/app}/' . $task->redirect),
['$id' => $task->id]
);
@ -301,23 +301,23 @@ echo $this->data['nav']->render(); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Status'); ?>">
<a href="<?= $url; ?>">
<span class="tag <?= $this->printHtml('task-status-' . $task->getStatus()); ?>">
<?= $this->getHtml('S' . $task->getStatus()); ?>
<span class="tag <?= $this->printHtml('task-status-' . $task->status); ?>">
<?= $this->getHtml('S' . $task->status); ?>
</span>
</a>
<td data-label="<?= $this->getHtml('Due/Priority'); ?>">
<a href="<?= $url; ?>">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->printHtml($task->due->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</a>
<td><?= ($this->data['task_media'][$task->id] ?? false) === true ? '<i class="g-icon">attachment</i>' : ''; ?>
<td data-label="<?= $this->getHtml('Title'); ?>">
<a href="<?= $url; ?>"><?= $this->printHtml($task->title); ?></a>
<td data-label="<?= $this->getHtml('Tag'); ?>">
<?php $tags = $task->getTags(); foreach ($tags as $tag) : ?>
<?php foreach ($task->tags as $tag) : ?>
<a href="<?= $url; ?>">
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
<?= empty($tag->icon) ? '' : ''; ?>
@ -326,7 +326,7 @@ echo $this->data['nav']->render(); ?>
</a>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Creator'); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $task->createdBy->id); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $task->createdBy->id); ?>">
<?= $this->printHtml($this->renderUserName(
'%3$s %2$s %1$s',
[

View File

@ -21,10 +21,10 @@ use phpOMS\Uri\UriFactory;
/** @var Modules\Tasks\Views\TaskView $this */
/** @var Modules\Tasks\Models\Task $task */
$task = $this->data['task'];
$taskMedia = $task->getMedia();
$taskMedia = $task->files;
$elements = $task->invertTaskElements();
$cElements = \count($elements);
$color = $this->getStatus($task->getStatus());
$color = $this->getStatus($task->status);
echo $this->data['nav']->render(); ?>
@ -49,8 +49,8 @@ echo $this->data['nav']->render(); ?>
</template>
<template id="contentTpl">
<div class="task-content">
<?= $this->getData('editor')->render('task-edit'); ?>
<?= $this->getData('editor')->getData('text')->render(
<?= $this->data['editor']->render('task-edit'); ?>
<?= $this->data['editor']->getData('text')->render(
'task-edit',
'plain',
'taskEdit',
@ -71,8 +71,8 @@ echo $this->data['nav']->render(); ?>
<form style="display: inline-block;" id="taskReminder" action="<?= UriFactory::build('{/api}task/reminder?{?}&csrf={$CSRF}'); ?>" method="POST">
<i class="g-icon btn submit">notifications</i>
</form>
<span id="task-status-badge" class="nobreak tag task-status-<?= $task->getStatus(); ?>">
<?= $this->getHtml('S' . $task->getStatus()); ?>
<span id="task-status-badge" class="nobreak tag task-status-<?= $task->status; ?>">
<?= $this->getHtml('S' . $task->status); ?>
</span>
</span>
</div>
@ -85,8 +85,7 @@ echo $this->data['nav']->render(); ?>
data-tpl-text-path="/0/response/description"
data-value=""><?= $task->description; ?></article>
<?php
$tags = $task->getTags();
foreach ($tags as $tag) : ?>
foreach ($task->tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
<?= empty($tag->icon) ? '' : ''; ?><?= $this->printHtml($tag->getL11n()); ?>
</span>
@ -95,7 +94,7 @@ echo $this->data['nav']->render(); ?>
<div>
<?php foreach ($taskMedia as $media) : ?>
<span>
<a class="content" href="<?= UriFactory::build('{/base}/media/single?id=' . $media->id);?>"><?= $media->name; ?></a>
<a class="content" href="<?= UriFactory::build('{/base}/media/view?id=' . $media->id);?>"><?= $media->name; ?></a>
</span>
<?php endforeach; ?>
</div>
@ -105,10 +104,10 @@ echo $this->data['nav']->render(); ?>
<div class="row col-xs plain-grid">
<div class="col-xs">
<div>
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
<?php if ($task->priority === TaskPriority::NONE) : ?>
<?= $this->getHtml('Due'); ?>: <?= $this->printHtml($task->due->format('Y/m/d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $task->getPriority()); ?>
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $task->priority); ?>
<?php endif; ?>
</div>
</div>
@ -168,8 +167,8 @@ echo $this->data['nav']->render(); ?>
<template id="taskElementContentTpl">
<div class="taskElement-content">
<!-- @todo bind js after adding template -->
<?= $this->getData('editor')->render('task-element-edit'); ?>
<?= $this->getData('editor')->getData('text')->render(
<?= $this->data['editor']->render('task-element-edit'); ?>
<?= $this->data['editor']->getData('text')->render(
'task-element-edit',
'plain',
'taskElementEdit',
@ -182,40 +181,40 @@ echo $this->data['nav']->render(); ?>
<?php $c = 0; $previous = null;
foreach ($elements as $key => $element) : ++$c; ?>
<?php if ($c === 1
|| ($previous !== null && $element->getStatus() !== $previous->getStatus())
|| ($previous !== null && $element->status !== $previous->status)
) : ?>
<section class="portlet">
<div class="portlet-body">
<?= \sprintf($this->getHtml('status_change'),
'<a href="' . UriFactory::build('profile/single?{?}&for=' . $element->createdBy->id) . '">' . $this->printHtml(
'<a href="' . UriFactory::build('profile/view?{?}&for=' . $element->createdBy->id) . '">' . $this->printHtml(
$this->renderUserName(
'%3$s %2$s %1$s',
[$element->createdBy->name1, $element->createdBy->name2, $element->createdBy->name3, $element->createdBy->login])
) . '</a>',
$element->createdAt->format('Y-m-d H:i')
); ?>
<span class="tag task-status-<?= $element->getStatus(); ?>">
<?= $this->getHtml('S' . $element->getStatus()); ?>
<span class="tag task-status-<?= $element->status; ?>">
<?= $this->getHtml('S' . $element->status); ?>
</span>
</div>
</section>
<?php endif; ?>
<?php if (($c === 1)
|| ($previous !== null && $element->getPriority() !== $previous->getPriority())
|| ($previous !== null && $element->priority !== $previous->priority)
) : ?>
<section class="portlet">
<div class="portlet-body">
<?= \sprintf($this->getHtml('priority_change'),
'<a href="' . UriFactory::build('profile/single?{?}&for=' . $element->createdBy->id) . '">' . $this->printHtml(
'<a href="' . UriFactory::build('profile/view?{?}&for=' . $element->createdBy->id) . '">' . $this->printHtml(
$this->renderUserName(
'%3$s %2$s %1$s',
[$element->createdBy->name1, $element->createdBy->name2, $element->createdBy->name3, $element->createdBy->login])
) . '</a>',
$element->createdAt->format('Y-m-d H:i')
); ?>
<span class="tag task-priority-<?= $element->getPriority(); ?>">
<?= $this->getHtml('P' . $element->getPriority()); ?>
<span class="tag task-priority-<?= $element->priority; ?>">
<?= $this->getHtml('P' . $element->priority); ?>
</span>
</div>
</section>
@ -246,7 +245,7 @@ echo $this->data['nav']->render(); ?>
</div>
<?php
$elementMedia = $element->getMedia();
$elementMedia = $element->files;
if ($element->description !== '') : ?>
<div class="portlet-body">
<article class="taskElement-content" data-tpl-text="{/base}/api/task/element?id={$id}"
@ -258,7 +257,7 @@ echo $this->data['nav']->render(); ?>
<?php if (!empty($elementMedia)) : ?>
<div>
<?php foreach ($elementMedia as $media) : ?>
<span><a class="content" href="<?= UriFactory::build('{/base}/media/single?id=' . $media->id);?>"><?= $media->name; ?></a></span>
<span><a class="content" href="<?= UriFactory::build('{/base}/media/view?id=' . $media->id);?>"><?= $media->name; ?></a></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
@ -269,21 +268,21 @@ echo $this->data['nav']->render(); ?>
&& $this->request->header->account === $element->createdBy->id
) : ?>
<div class="portlet-foot row middle-xs">
<?php if ($element->getStatus() !== TaskStatus::CANCELED
|| $element->getStatus() !== TaskStatus::DONE
|| $element->getStatus() !== TaskStatus::SUSPENDED
<?php if ($element->status !== TaskStatus::CANCELED
|| $element->status !== TaskStatus::DONE
|| $element->status !== TaskStatus::SUSPENDED
|| $c != $cElements
) : ?>
<div>
<?php
if ($element->getPriority() === TaskPriority::NONE
if ($element->priority === TaskPriority::NONE
&& ($previous !== null
&& $previous->due->format('Y/m/d H:i') !== $element->due->format('Y/m/d H:i')
)
) : ?>
<?= $this->getHtml('Due'); ?>: <?= $this->printHtml($element->due->format('Y/m/d H:i')); ?>
<?php elseif ($previous !== null && $previous->getPriority() !== $element->getPriority()) : ?>
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $element->getPriority()); ?>
<?php elseif ($previous !== null && $previous->priority !== $element->priority) : ?>
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $element->priority); ?>
<?php endif; ?>
</div>
<?php endif; ?>
@ -310,14 +309,14 @@ echo $this->data['nav']->render(); ?>
) : ?>
<section class="portlet wf-100">
<div class="portlet-body">
<a href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $element->createdBy->id); ?>"><?= $this->printHtml(
<a href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $element->createdBy->id); ?>"><?= $this->printHtml(
$this->renderUserName(
'%3$s %2$s %1$s',
[$element->createdBy->name1, $element->createdBy->name2, $element->createdBy->name3, $element->createdBy->login])
); ?></a> <?= $this->getHtml('forwarded_to'); ?>
<?php foreach ($tos as $to) : ?>
<?php if ($to instanceof AccountRelation) : ?>
<a href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $to->getRelation()->id); ?>"><?= $this->renderUserName(
<a href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $to->getRelation()->id); ?>"><?= $this->renderUserName(
'%3$s %2$s %1$s',
[$to->getRelation()->name1, $to->getRelation()->name2, $to->getRelation()->name3, $to->getRelation()->login]
); ?></a>
@ -344,11 +343,11 @@ echo $this->data['nav']->render(); ?>
<div class="portlet-head"><?= $this->getHtml('Message'); ?></div>
<div class="portlet-body">
<div class="form-group">
<?= $this->getData('editor')->render('task-editor'); ?>
<?= $this->data['editor']->render('task-editor'); ?>
</div>
<div class="form-group">
<?= $this->getData('editor')->getData('text')->render(
<?= $this->data['editor']->getData('text')->render(
'task-editor',
'plain',
'taskElementCreate',
@ -360,11 +359,11 @@ echo $this->data['nav']->render(); ?>
<div class="form-group">
<label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<select id="iStatus" name="status">
<option value="<?= TaskStatus::OPEN; ?>"<?= $task->getStatus() === TaskStatus::OPEN ? ' selected' : '';?>><?= $this->getHtml('S1'); ?>
<option value="<?= TaskStatus::WORKING; ?>"<?= $task->getStatus() === TaskStatus::WORKING ? ' selected' : '';?>><?= $this->getHtml('S2'); ?>
<option value="<?= TaskStatus::SUSPENDED; ?>"<?= $task->getStatus() === TaskStatus::SUSPENDED ? ' selected' : '';?>><?= $this->getHtml('S3'); ?>
<option value="<?= TaskStatus::CANCELED; ?>"<?= $task->getStatus() === TaskStatus::CANCELED ? ' selected' : '';?>><?= $this->getHtml('S4'); ?>
<option value="<?= TaskStatus::DONE; ?>"<?= $task->getStatus() === TaskStatus::DONE ? ' selected' : '';?>><?= $this->getHtml('S5'); ?>
<option value="<?= TaskStatus::OPEN; ?>"<?= $task->status === TaskStatus::OPEN ? ' selected' : '';?>><?= $this->getHtml('S1'); ?>
<option value="<?= TaskStatus::WORKING; ?>"<?= $task->status === TaskStatus::WORKING ? ' selected' : '';?>><?= $this->getHtml('S2'); ?>
<option value="<?= TaskStatus::SUSPENDED; ?>"<?= $task->status === TaskStatus::SUSPENDED ? ' selected' : '';?>><?= $this->getHtml('S3'); ?>
<option value="<?= TaskStatus::CANCELED; ?>"<?= $task->status === TaskStatus::CANCELED ? ' selected' : '';?>><?= $this->getHtml('S4'); ?>
<option value="<?= TaskStatus::DONE; ?>"<?= $task->status === TaskStatus::DONE ? ' selected' : '';?>><?= $this->getHtml('S5'); ?>
</select>
</div>
@ -373,7 +372,8 @@ echo $this->data['nav']->render(); ?>
<?= $this->getData('accGrpSelector')->render('iReceiver', 'to', true); ?>
</div>
<div class="more-container">
<div class="form-group wf-100">
<div class="more-container wf-100">
<input id="more-customer-sales" type="checkbox" name="more-container">
<label for="more-customer-sales">
<span>Advanced</span>
@ -383,12 +383,12 @@ echo $this->data['nav']->render(); ?>
<div class="form-group">
<label for="iPriority"><?= $this->getHtml('Priority'); ?></label>
<select id="iPriority" name="priority">
<option value="<?= TaskPriority::NONE; ?>"<?= $task->getPriority() === TaskPriority::NONE ? ' selected' : '';?>><?= $this->getHtml('P0'); ?>
<option value="<?= TaskPriority::VLOW; ?>"<?= $task->getPriority() === TaskPriority::VLOW ? ' selected' : '';?>><?= $this->getHtml('P1'); ?>
<option value="<?= TaskPriority::LOW; ?>"<?= $task->getPriority() === TaskPriority::LOW ? ' selected' : '';?>><?= $this->getHtml('P2'); ?>
<option value="<?= TaskPriority::MEDIUM; ?>"<?= $task->getPriority() === TaskPriority::MEDIUM ? ' selected' : '';?>><?= $this->getHtml('P3'); ?>
<option value="<?= TaskPriority::HIGH; ?>"<?= $task->getPriority() === TaskPriority::HIGH ? ' selected' : '';?>><?= $this->getHtml('P4'); ?>
<option value="<?= TaskPriority::VHIGH; ?>"<?= $task->getPriority() === TaskPriority::VHIGH ? ' selected' : '';?>><?= $this->getHtml('P5'); ?>
<option value="<?= TaskPriority::NONE; ?>"<?= $task->priority === TaskPriority::NONE ? ' selected' : '';?>><?= $this->getHtml('P0'); ?>
<option value="<?= TaskPriority::VLOW; ?>"<?= $task->priority === TaskPriority::VLOW ? ' selected' : '';?>><?= $this->getHtml('P1'); ?>
<option value="<?= TaskPriority::LOW; ?>"<?= $task->priority === TaskPriority::LOW ? ' selected' : '';?>><?= $this->getHtml('P2'); ?>
<option value="<?= TaskPriority::MEDIUM; ?>"<?= $task->priority === TaskPriority::MEDIUM ? ' selected' : '';?>><?= $this->getHtml('P3'); ?>
<option value="<?= TaskPriority::HIGH; ?>"<?= $task->priority === TaskPriority::HIGH ? ' selected' : '';?>><?= $this->getHtml('P4'); ?>
<option value="<?= TaskPriority::VHIGH; ?>"<?= $task->priority === TaskPriority::VHIGH ? ' selected' : '';?>><?= $this->getHtml('P5'); ?>
</select>
</div>
@ -405,6 +405,7 @@ echo $this->data['nav']->render(); ?>
<input id="iCompletion" name="completion" type="number" min="0" max="100">
</div>
</div>
</div>
<div class="form-group">
<label for="iMedia"><?= $this->getHtml('Media'); ?></label>

View File

@ -47,7 +47,7 @@ class TaskView extends View
*
* @since 1.0.0
*/
public function __construct(L11nManager $l11n = null, RequestAbstract $request = null, ResponseAbstract $response = null)
public function __construct(?L11nManager $l11n = null, ?RequestAbstract $request = null, ?ResponseAbstract $response = null)
{
$this->defaultProfileImage = new NullMedia();
parent::__construct($l11n, $request, $response);

View File

@ -75,8 +75,8 @@ final class Autoloader
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class);

View File

@ -1,4 +1,15 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks\tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
\ini_set('memory_limit', '2048M');
@ -67,10 +78,10 @@ $GLOBALS['is_github'] = $IS_GITHUB;
$tmp = FileLogger::getInstance(__DIR__ . '/../Logs');
$CONFIG = [
'db' => [
'db' => [
'core' => [
'masters' => [
'admin' => [
'admin' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -80,7 +91,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -90,7 +101,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -100,7 +111,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -110,7 +121,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -120,7 +131,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -132,7 +143,7 @@ $CONFIG = [
],
],
'postgresql' => [
'admin' => [
'admin' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -142,7 +153,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -152,7 +163,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -162,7 +173,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -172,7 +183,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -182,7 +193,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -194,37 +205,37 @@ $CONFIG = [
],
],
'sqlite' => [
'admin' => [
'admin' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
@ -232,7 +243,7 @@ $CONFIG = [
],
],
'mssql' => [
'admin' => [
'admin' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -242,7 +253,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -252,7 +263,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -262,7 +273,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -272,7 +283,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -282,7 +293,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -322,16 +333,16 @@ $CONFIG = [
'password' => '123456',
],
],
'log' => [
'log' => [
'file' => [
'path' => __DIR__ . '/Logs',
],
],
'page' => [
'page' => [
'root' => '/',
'https' => false,
],
'app' => [
'app' => [
'path' => __DIR__,
'default' => [
'app' => 'Backend',
@ -350,7 +361,7 @@ $CONFIG = [
],
],
],
'socket' => [
'socket' => [
'master' => [
'host' => '127.0.0.1',
'limit' => 300,
@ -360,7 +371,7 @@ $CONFIG = [
'language' => [
'en',
],
'apis' => [
'apis' => [
],
];

View File

@ -31,7 +31,6 @@ use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
/**
@ -39,7 +38,7 @@ use phpOMS\Utils\TestUtils;
*/
final class ControllerTest extends \PHPUnit\Framework\TestCase
{
protected $app = null;
protected $app = null;
protected $module = null;
@ -94,7 +93,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testCreateTask() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', 'Controller Test Title');
@ -131,7 +130,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testApiTaskGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '1');
@ -148,7 +147,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testApiTaskSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', 1);
@ -168,7 +167,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testCreateTaskElement() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('due', (new \DateTime())->format('Y-m-d H:i:s'));
@ -206,7 +205,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testApiTaskElementGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '1');
@ -223,7 +222,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testApiTaskElementSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', 1);
@ -242,7 +241,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testInvalidTaskCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('plain', 'Controller Test Description');
@ -259,7 +258,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
public function testInvalidTaskElementCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('due', (new \DateTime())->format('Y-m-d H:i:s'));

View File

@ -31,7 +31,7 @@ use phpOMS\Utils\TestUtils;
*/
final class BackendControllerTest extends \PHPUnit\Framework\TestCase
{
protected $app = null;
protected $app = null;
protected $module = null;
@ -45,13 +45,13 @@ final class BackendControllerTest extends \PHPUnit\Framework\TestCase
protected string $appName = 'Backend';
};
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Web/Backend/Hooks.php');
$account = new Account();

View File

@ -16,7 +16,6 @@ namespace Modules\Tasks\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\Admin\Models\NullGroup;
use Modules\Media\Models\Media;
use Modules\Tasks\Models\TaskElement;
use Modules\Tasks\Models\TaskPriority;
use Modules\Tasks\Models\TaskStatus;
@ -46,13 +45,13 @@ final class TaskElementTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->element->createdBy->id);
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->element->createdAt->format('Y-m-d'));
self::assertEquals((new \DateTime('now'))->modify('+1 day')->format('Y-m-d'), $this->element->due->format('Y-m-d'));
self::assertEquals(TaskStatus::OPEN, $this->element->getStatus());
self::assertEquals(TaskStatus::OPEN, $this->element->status);
self::assertEquals('', $this->element->description);
self::assertEquals('', $this->element->descriptionRaw);
self::assertEquals([], $this->element->getTo());
self::assertEquals([], $this->element->getCC());
self::assertEquals(0, $this->element->task);
self::assertEquals(TaskPriority::NONE, $this->element->getPriority());
self::assertEquals(TaskPriority::NONE, $this->element->priority);
}
/**
@ -75,36 +74,6 @@ final class TaskElementTest extends \PHPUnit\Framework\TestCase
self::assertEquals($date->format('Y-m-d'), $this->element->due->format('Y-m-d'));
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
*/
public function testStatusInputOutput() : void
{
$this->element->setStatus(TaskStatus::DONE);
self::assertEquals(TaskStatus::DONE, $this->element->getStatus());
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
*/
public function testPriorityInputOutput() : void
{
$this->element->setPriority(TaskPriority::MEDIUM);
self::assertEquals(TaskPriority::MEDIUM, $this->element->getPriority());
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
*/
public function testMediaInputOutput() : void
{
$this->element->addMedia(new Media());
self::assertCount(1, $this->element->getMedia());
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
@ -227,36 +196,16 @@ final class TaskElementTest extends \PHPUnit\Framework\TestCase
self::assertFalse($this->element->isCCGroup(10));
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
*/
public function testInvalidStatus() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
$this->element->setStatus(9999);
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
*/
public function testInvalidPriority() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
$this->element->setPriority(9999);
}
/**
* @covers Modules\Tasks\Models\TaskElement
* @group module
*/
public function testSerialize() : void
{
$this->element->task = 2;
$this->element->description = 'Test';
$this->element->descriptionRaw = 'TestRaw';
$this->element->setStatus(TaskStatus::DONE);
$this->element->task = 2;
$this->element->description = 'Test';
$this->element->descriptionRaw = 'TestRaw';
$this->element->status = TaskStatus::DONE;
$serialized = $this->element->jsonSerialize();
unset($serialized['createdAt']);

View File

@ -49,36 +49,36 @@ final class TaskMapperTest extends \PHPUnit\Framework\TestCase
$task = new Task();
$task->setCreatedBy(new NullAccount(1));
$task->schedule->createdBy = new NullAccount(1);
$task->start = new \DateTime('2005-05-05');
$task->title = 'Task Test';
$task->setStatus(TaskStatus::OPEN);
$task->isClosable = false;
$task->setPriority(TaskPriority::HIGH);
$task->description = 'Description';
$task->descriptionRaw = 'DescriptionRaw';
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$task->schedule->createdBy = new NullAccount(1);
$task->start = new \DateTime('2005-05-05');
$task->title = 'Task Test';
$task->status = TaskStatus::OPEN;
$task->isClosable = false;
$task->priority = TaskPriority::HIGH;
$task->description = 'Description';
$task->descriptionRaw = 'DescriptionRaw';
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$taskElement1 = new TaskElement();
$taskElement1->description = 'Desc1';
$taskElement1->createdBy = new NullAccount(1);
$taskElement1->setStatus($task->getStatus());
$taskElement1->status = $task->status;
$task->addElement($taskElement1);
$media = new Media();
$media->createdBy = new NullAccount(1);
$media->description = 'desc';
$media->setPath('some/path');
$media->size = 11;
$media->extension = 'png';
$media->name = 'Task Element Media';
$taskElement1->addMedia($media);
$media->size = 11;
$media->extension = 'png';
$media->name = 'Task Element Media';
$taskElement1->files[] = $media;
$taskElement2 = new TaskElement();
$taskElement2->description = 'Desc2';
$taskElement2->createdBy = new NullAccount(1);
$taskElement2->setStatus($task->getStatus());
$taskElement2->status = $task->status;
$taskElement2->addAccountTo(new NullAccount(1));
$taskElement2->addAccountCC(new NullAccount(1));
$taskElement2->addGroupTo(new NullGroup(1));
@ -92,14 +92,14 @@ final class TaskMapperTest extends \PHPUnit\Framework\TestCase
$media->size = 11;
$media->extension = 'png';
$media->name = 'Task Media';
$task->addMedia($media);
$task->files[] = $media;
$id = TaskMapper::create()->execute($task);
self::assertGreaterThan(0, $task->id);
self::assertEquals($id, $task->id);
$taskR = TaskMapper::get()
->with('media')
->with('files')
->with('taskElements')
->with('taskElements/media')
->with('taskElements/accRelation')
@ -114,22 +114,22 @@ final class TaskMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($task->description, $taskR->description);
self::assertEquals($task->descriptionRaw, $taskR->descriptionRaw);
self::assertEquals($task->title, $taskR->title);
self::assertEquals($task->getStatus(), $taskR->getStatus());
self::assertEquals($task->status, $taskR->status);
self::assertEquals($task->isClosable, $taskR->isClosable);
self::assertEquals($task->getType(), $taskR->getType());
self::assertEquals($task->type, $taskR->type);
self::assertEquals($task->done->format('Y-m-d'), $taskR->done->format('Y-m-d'));
self::assertEquals($task->due->format('Y-m-d'), $taskR->due->format('Y-m-d'));
self::assertGreaterThan(0, TaskMapper::countUnread(1));
$expected = $task->getMedia();
$actual = $taskR->getMedia();
$expected = $task->files;
$actual = $taskR->files;
self::assertEquals(\end($expected)->name, \end($actual)->name);
$expected = $task->getTaskElements();
$actual = $taskR->getTaskElements();
$expectedMedia = \reset($expected)->getMedia();
$actualMedia = \reset($actual)->getMedia();
$expectedMedia = \reset($expected)->files;
$actualMedia = \reset($actual)->files;
self::assertEquals(\end($expected)->description, \end($actual)->description);
self::assertEquals(\end($expectedMedia)->name, \end($actualMedia)->name);
@ -169,24 +169,24 @@ final class TaskMapperTest extends \PHPUnit\Framework\TestCase
$task = new Task();
$task->setCreatedBy(new NullAccount(1));
$task->schedule->createdBy = new NullAccount(1);
$task->start = new \DateTime('2005-05-05');
$task->title = $text->generateText(\mt_rand(1, 5));
$task->setStatus($status);
$task->description = $text->generateText(\mt_rand(10, 30));
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$task->schedule->createdBy = new NullAccount(1);
$task->start = new \DateTime('2005-05-05');
$task->title = $text->generateText(\mt_rand(1, 5));
$task->status = $status;
$task->description = $text->generateText(\mt_rand(10, 30));
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$taskElement1 = new TaskElement();
$taskElement1->description = $text->generateText(\mt_rand(3, 20));
$taskElement1->createdBy = new NullAccount(1);
$taskElement1->setStatus($status);
$taskElement1->status = $status;
$task->addElement($taskElement1);
$taskElement2 = new TaskElement();
$taskElement2->description = 'Desc2';
$taskElement2->createdBy = new NullAccount(1);
$taskElement2->setStatus($status);
$taskElement2->status = $status;
$task->addElement($taskElement2);
$id = TaskMapper::create()->execute($task);
@ -210,24 +210,24 @@ final class TaskMapperTest extends \PHPUnit\Framework\TestCase
$task = new Task();
$task->setCreatedBy(new NullAccount(1));
$task->schedule->createdBy = new NullAccount(1);
$task->title = $text->generateText(\mt_rand(1, 5));
$task->setStatus($status);
$task->isClosable = true;
$task->description = $text->generateText(\mt_rand(10, 30));
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$task->schedule->createdBy = new NullAccount(1);
$task->title = $text->generateText(\mt_rand(1, 5));
$task->status = $status;
$task->isClosable = true;
$task->description = $text->generateText(\mt_rand(10, 30));
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$taskElement1 = new TaskElement();
$taskElement1->description = $text->generateText(\mt_rand(3, 20));
$taskElement1->createdBy = new NullAccount(1);
$taskElement1->setStatus($status);
$taskElement1->status = $status;
$task->addElement($taskElement1);
$taskElement2 = new TaskElement();
$taskElement2->description = $text->generateText(\mt_rand(3, 20));
$taskElement2->createdBy = new NullAccount(1);
$taskElement2->setStatus($status);
$taskElement2->status = $status;
$task->addElement($taskElement2);
$id = TaskMapper::create()->execute($task);
@ -249,24 +249,24 @@ final class TaskMapperTest extends \PHPUnit\Framework\TestCase
$task = new Task();
$task->setCreatedBy(new NullAccount(1));
$task->schedule->createdBy = new NullAccount(1);
$task->title = $text->generateText(\mt_rand(1, 5));
$task->setStatus($status);
$task->isClosable = true;
$task->description = $text->generateText(\mt_rand(10, 30));
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$task->schedule->createdBy = new NullAccount(1);
$task->title = $text->generateText(\mt_rand(1, 5));
$task->status = $status;
$task->isClosable = true;
$task->description = $text->generateText(\mt_rand(10, 30));
$task->done = new \DateTime('2000-05-06');
$task->due = new \DateTime('2000-05-05');
$taskElement1 = new TaskElement();
$taskElement1->description = $text->generateText(\mt_rand(3, 20));
$taskElement1->createdBy = new NullAccount(1);
$taskElement1->setStatus($status);
$taskElement1->status = $status;
$task->addElement($taskElement1);
$taskElement2 = new TaskElement();
$taskElement2->description = $text->generateText(\mt_rand(3, 20));
$taskElement2->createdBy = new NullAccount(1);
$taskElement2->setStatus($status);
$taskElement2->status = $status;
$task->addElement($taskElement2);
$id = TaskMapper::create()->execute($task);

View File

@ -16,8 +16,6 @@ namespace Modules\Tasks\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\Admin\Models\NullGroup;
use Modules\Media\Models\Media;
use Modules\Tag\Models\Tag;
use Modules\Tasks\Models\Task;
use Modules\Tasks\Models\TaskElement;
use Modules\Tasks\Models\TaskPriority;
@ -57,16 +55,15 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->task->start->format('Y-m-d'));
self::assertNull($this->task->done);
self::assertEquals((new \DateTime('now'))->modify('+1 day')->format('Y-m-d'), $this->task->due->format('Y-m-d'));
self::assertEquals(TaskStatus::OPEN, $this->task->getStatus());
self::assertEquals(TaskStatus::OPEN, $this->task->status);
self::assertTrue($this->task->isClosable);
self::assertEquals(TaskPriority::NONE, $this->task->getPriority());
self::assertEquals(TaskType::SINGLE, $this->task->getType());
self::assertEquals(TaskPriority::NONE, $this->task->priority);
self::assertEquals(TaskType::SINGLE, $this->task->type);
self::assertEquals([], $this->task->getTaskElements());
self::assertEquals([], $this->task->getMedia());
self::assertEquals([], $this->task->getTags());
self::assertEquals([], $this->task->files);
self::assertEquals([], $this->task->tags);
self::assertEquals('', $this->task->description);
self::assertEquals('', $this->task->descriptionRaw);
self::assertInstanceOf('\Modules\Tag\Models\NullTag', $this->task->getTag(0));
self::assertInstanceOf('\Modules\Tasks\Models\NullTaskElement', $this->task->getTaskElement(1));
}
@ -120,16 +117,6 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
self::assertEquals($date->format('Y-m-d'), $this->task->due->format('Y-m-d'));
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testStatusInputOutput() : void
{
$this->task->setStatus(TaskStatus::DONE);
self::assertEquals(TaskStatus::DONE, $this->task->getStatus());
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
@ -140,16 +127,6 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
self::assertFalse($this->task->isClosable);
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testPriority() : void
{
$this->task->setPriority(TaskPriority::LOW);
self::assertEquals(TaskPriority::LOW, $this->task->getPriority());
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
@ -276,55 +253,6 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
self::assertFalse($this->task->isEditable);
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testTypeInputOutput() : void
{
$this->task->setType(TaskType::TEMPLATE);
self::assertEquals(TaskType::TEMPLATE, $this->task->getType());
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testTagInputOutput() : void
{
$tag = new Tag();
$tag->setL11n('Tag');
$this->task->addTag($tag);
self::assertEquals($tag, $this->task->getTag(0));
self::assertCount(1, $this->task->getTags());
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testTagRemove() : void
{
$tag = new Tag();
$tag->setL11n('Tag');
$this->task->addTag($tag);
self::assertTrue($this->task->removeTag(0));
self::assertCount(0, $this->task->getTags());
self::assertFalse($this->task->removeTag(0));
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testMediaInputOutput() : void
{
$this->task->addMedia(new Media());
self::assertCount(1, $this->task->getMedia());
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
@ -337,9 +265,9 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
'createdAt' => $this->task->createdAt,
'title' => $this->task->title,
'description' => $this->task->description,
'status' => $this->task->getStatus(),
'type' => $this->task->getType(),
'priority' => $this->task->getPriority(),
'status' => $this->task->status,
'type' => $this->task->type,
'priority' => $this->task->priority,
'due' => $this->task->due,
'done' => $this->task->done,
];
@ -367,9 +295,9 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
'createdAt' => $this->task->createdAt,
'title' => $this->task->title,
'description' => $this->task->description,
'status' => $this->task->getStatus(),
'type' => $this->task->getType(),
'priority' => $this->task->getPriority(),
'status' => $this->task->status,
'type' => $this->task->type,
'priority' => $this->task->priority,
'due' => $this->task->due,
'done' => $this->task->done,
];
@ -384,24 +312,4 @@ final class TaskTest extends \PHPUnit\Framework\TestCase
}
self::assertTrue($isSubset);
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testInvalidStatus() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
$this->task->setStatus(9999);
}
/**
* @covers Modules\Tasks\Models\Task
* @group module
*/
public function testInvalidPriority() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
$this->task->setPriority(9999);
}
}

View File

@ -175,7 +175,7 @@
["css=tr:nth-child(1) > td:nth-child(2) > a", "css:finder"],
["xpath=//a[contains(text(),'2019-06-15 13:29')]", "xpath:link"],
["xpath=//table[@id='taskList']/tbody/tr/td[2]/a", "xpath:idRelative"],
["xpath=(//a[contains(@href, 'task/single?id=40')])[2]", "xpath:href"],
["xpath=(//a[contains(@href, 'task/view?id=40')])[2]", "xpath:href"],
["xpath=//td[2]/a", "xpath:position"],
["xpath=//a[contains(.,'2019-06-15 13:29')]", "xpath:innerText"]
],

View File

@ -56,14 +56,14 @@ class TaskViewTest extends \PHPUnit\Framework\TestCase
$profile->account = AccountMapper::get()->where('id', 1)->execute();
$profile->image = $media;
$profile->birthday = new \DateTime('now');
$profile->birthday = new \DateTime('now');
$id = ProfileMapper::create()->execute($profile);
self::assertGreaterThan(0, $profile->id);
self::assertEquals($id, $profile->id);
} else {
$profile->image = $media;
$profile->birthday = new \DateTime('now');
$profile->birthday = new \DateTime('now');
ProfileMapper::update()->with('image')->execute($profile);
}