auto fixes + some impl.

This commit is contained in:
Dennis Eichhorn 2024-01-26 22:53:59 +00:00
parent 98537a7698
commit 828989a4e1
25 changed files with 285 additions and 539 deletions

View File

@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/kanban.*$' => [
'^.*/kanban(\?.*$|$)' => [
[
'dest' => '\Modules\Kanban\Controller\BackendController:setupStyles',
'verb' => RouteVerb::GET,
@ -29,7 +29,7 @@ return [
],
],
],
'^.*/kanban/dashboard.*$' => [
'^.*/kanban/dashboard(\?.*$|$)' => [
[
'dest' => '\Modules\Kanban\Controller\BackendController:viewKanbanDashboard',
'verb' => RouteVerb::GET,
@ -40,7 +40,7 @@ return [
],
],
],
'^.*/kanban/archive.*$' => [
'^.*/kanban/archive(\?.*$|$)' => [
[
'dest' => '\Modules\Kanban\Controller\BackendController:viewKanbanArchive',
'verb' => RouteVerb::GET,
@ -51,7 +51,7 @@ return [
],
],
],
'^.*/kanban/board.*$' => [
'^.*/kanban/board(\?.*$|$)' => [
[
'dest' => '\Modules\Kanban\Controller\BackendController:viewKanbanBoard',
'verb' => RouteVerb::GET,
@ -62,7 +62,7 @@ return [
],
],
],
'^.*/kanban/card.*$' => [
'^.*/kanban/card(\?.*$|$)' => [
[
'dest' => '\Modules\Kanban\Controller\BackendController:viewKanbanCard',
'verb' => RouteVerb::GET,
@ -73,7 +73,7 @@ return [
],
],
],
'^.*/kanban/create.*$' => [
'^.*/kanban/create(\?.*$|$)' => [
[
'dest' => '\Modules\Kanban\Controller\BackendController:viewKanbanBoardCreate',
'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).
## 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
@ -16,56 +20,104 @@ Generally, the development philosophy is result orientated. This means that anyo
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.
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

@ -27,8 +27,6 @@ use Modules\Kanban\Models\KanbanCardMapper;
use Modules\Kanban\Models\KanbanColumn;
use Modules\Kanban\Models\KanbanColumnMapper;
use Modules\Media\Models\NullMedia;
use Modules\Tag\Models\NullTag;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
@ -90,30 +88,12 @@ final class ApiController extends Controller
$card->column = (int) $request->getData('column');
$card->order = $request->getDataInt('order') ?? 1;
$card->ref = $request->getDataInt('ref') ?? 0;
$card->setStatus($request->getDataInt('status') ?? CardStatus::ACTIVE);
$card->setType($request->getDataInt('type') ?? CardType::TEXT);
$card->status = CardStatus::tryFromValue($request->getDataInt('status')) ?? CardStatus::ACTIVE;
$card->type = CardType::tryFromValue($request->getDataInt('type')) ?? CardType::TEXT;
$card->createdBy = new NullAccount($request->header->account);
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;
}
$card->addTag($data['response']);
} else {
$card->addTag(new NullTag((int) $tag['id']));
}
}
if ($request->hasData('tags')) {
$card->tags = $this->app->moduleManager->get('Tag', 'Api')->createTagsFromRequest($request);
}
if (!empty($uploadedFiles = $request->files)) {
@ -127,13 +107,13 @@ final class ApiController extends Controller
);
foreach ($uploaded as $media) {
$card->addMedia($media);
$card->files[] = $media;
}
}
if (!empty($mediaFiles = $request->getDataJson('media'))) {
foreach ($mediaFiles as $media) {
$card->addMedia(new NullMedia($media));
$card->files[] = new NullMedia($media);
}
}
@ -224,7 +204,7 @@ final class ApiController extends Controller
);
foreach ($uploaded as $media) {
$comment->addMedia($media);
$comment->files[] = $media;
}
}
@ -296,29 +276,11 @@ final class ApiController extends Controller
$board->description = Markdown::parse($request->getDataString('plain') ?? '');
$board->descriptionRaw = $request->getDataString('plain') ?? '';
$board->order = $request->getDataInt('order') ?? 1;
$board->setStatus($request->getDataInt('status') ?? BoardStatus::ACTIVE);
$board->status = BoardStatus::tryFromValue($request->getDataInt('status')) ?? BoardStatus::ACTIVE;
$board->createdBy = new NullAccount($request->header->account);
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;
}
$board->addTag($data['response']);
} else {
$board->addTag(new NullTag((int) $tag['id']));
}
}
if ($request->hasData('tags')) {
$board->tags = $this->app->moduleManager->get('Tag', 'Api')->createTagsFromRequest($request);
}
return $board;
@ -386,7 +348,7 @@ final class ApiController extends Controller
$new->description = Markdown::parse($request->getDataString('plain') ?? $new->descriptionRaw);
$new->descriptionRaw = $request->getDataString('plain') ?? $new->descriptionRaw;
$new->order = $request->getDataInt('order') ?? $new->order;
$new->setStatus($request->getDataInt('status') ?? $new->getStatus());
$new->status = BoardStatus::tryFromValue($request->getDataInt('status')) ?? $new->status;
$new->style = $request->getDataString('style') ?? $new->style;
return $new;

View File

@ -220,7 +220,7 @@ final class BackendController extends Controller
$card = KanbanCardMapper::get()
->with('tags')
->with('tags/title')
->with('media')
->with('files')
->with('createdBy')
->with('comments')
->with('comments/media')

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

@ -16,7 +16,6 @@ namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
/**
@ -136,84 +135,6 @@ class KanbanBoard implements \JsonSerializable
$this->createdBy = new NullAccount();
}
/**
* Get id.
*
* @return int Model id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get the status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set the status
*
* @param int $status Status
*
* @return void
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
$this->status = $status;
}
/**
* Get tags
*
* @return array
*
* @since 1.0.0
*/
public function getTags() : array
{
return $this->tags;
}
/**
* Add tag
*
* @param Tag $tag Tag
*
* @return void
*
* @since 1.0.0
*/
public function addTag(Tag $tag) : void
{
$this->tags[] = $tag;
}
/**
* 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 the columns
*

View File

@ -16,8 +16,6 @@ namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media;
use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
use Modules\Tasks\Models\Task;
@ -153,14 +151,6 @@ class KanbanCard implements \JsonSerializable
*/
public array $comments = [];
/**
* Media
*
* @var Media[]
* @since 1.0.0
*/
public array $media = [];
/**
* Constructor.
*
@ -172,70 +162,6 @@ class KanbanCard implements \JsonSerializable
$this->createdBy = new NullAccount();
}
/**
* Get id.
*
* @return int Model id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get the status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set the status
*
* @param int $status Status
*
* @return void
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
$this->status = $status;
}
/**
* Get the card type
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Set the card type
*
* @param int $type Card type
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type) : void
{
$this->type = $type;
}
/**
* Count the amount of comments in a card
*
@ -294,56 +220,6 @@ class KanbanCard implements \JsonSerializable
return false;
}
/**
* Get the media files
*
* @return array
*
* @since 1.0.0
*/
public function getMedia() : array
{
return $this->media;
}
/**
* Add a media file
*
* @return void
*
* @since 1.0.0
*/
public function addMedia(Media $media) : void
{
$this->media[] = $media;
}
/**
* Get tags
*
* @return array
*
* @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();
}
/**
* Add tag
*
@ -376,7 +252,7 @@ class KanbanCard implements \JsonSerializable
'createdBy' => $this->createdBy,
'createdAt' => $this->createdAt,
'comments' => $this->comments,
'media' => $this->media,
'media' => $this->files,
];
}
@ -404,4 +280,6 @@ class KanbanCard implements \JsonSerializable
return $card;
}
use \Modules\Media\Models\MediaListTrait;
}

View File

@ -16,7 +16,6 @@ namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media;
/**
* Kanban card comment class.
@ -76,14 +75,6 @@ class KanbanCardComment implements \JsonSerializable
*/
public \DateTimeImmutable $createdAt;
/**
* Media.
*
* @var \Modules\Media\Models\Media[]
* @since 1.0.0
*/
public array $media = [];
/**
* Constructor.
*
@ -95,44 +86,6 @@ class KanbanCardComment implements \JsonSerializable
$this->createdBy = new NullAccount();
}
/**
* Get id.
*
* @return int Model id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get the media files
*
* @return array
*
* @since 1.0.0
*/
public function getMedia() : array
{
return $this->media;
}
/**
* Add a media file
*
* @param Media $media Media
*
* @return void
*
* @since 1.0.0
*/
public function addMedia(Media $media) : void
{
$this->media[] = $media;
}
/**
* {@inheritdoc}
*/
@ -145,7 +98,7 @@ class KanbanCardComment implements \JsonSerializable
'card' => $this->card,
'createdBy' => $this->createdBy,
'createdAt' => $this->createdAt,
'media' => $this->media,
'media' => $this->files,
];
}
@ -156,4 +109,6 @@ class KanbanCardComment implements \JsonSerializable
{
return $this->toArray();
}
use \Modules\Media\Models\MediaListTrait;
}

View File

@ -53,7 +53,7 @@ final class KanbanCardCommentMapper extends DataMapperFactory
* @since 1.0.0
*/
public const HAS_MANY = [
'media' => [
'files' => [
'mapper' => MediaMapper::class,
'table' => 'kanban_card_comment_media',
'external' => 'kanban_card_comment_media_dst',

View File

@ -74,7 +74,7 @@ final class KanbanCardMapper extends DataMapperFactory
* @since 1.0.0
*/
public const HAS_MANY = [
'media' => [
'files' => [
'mapper' => MediaMapper::class,
'table' => 'kanban_card_media',
'external' => 'kanban_card_media_dst',

View File

@ -64,18 +64,6 @@ class KanbanColumn implements \JsonSerializable
*/
public array $cards = [];
/**
* Get id.
*
* @return int Model id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get the cards
*

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
/** @var \Modules\News\Models\NewsArticle[] $boards */
/** @var \Modules\Kanban\Models\KanbanBoard[] $boards */
$boards = $this->data['boards'] ?? [];
$previous = empty($boards) ? 'kanban/archive' : 'kanban/archive?{?}&id=' . \reset($boards)->id . '&ptype=p';
@ -75,7 +75,7 @@ echo $this->data['nav']->render(); ?>
$url = UriFactory::build('{/base}/kanban/board?{?}&id=' . $board->id);
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $this->getHtml(':bStatus' . $board->getStatus()); ?></a>
<td><a href="<?= $url; ?>"><?= $this->getHtml(':bStatus' . $board->status); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($board->name); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($board->createdAt->format('Y-m-d')); ?></a>
<?php endforeach; ?>

View File

@ -36,7 +36,7 @@ $layout = \max(4, $columnCount);
<div class="portlet-body">
<article><?= $card->description; ?></article>
<?php $tags = $card->getTags(); foreach ($tags as $tag) : ?>
<?php foreach ($card->tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= empty($tag->icon) ? '' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?>
</div>

View File

@ -34,8 +34,8 @@ $comments = $card->getComments();
<article><?= $card->description; ?></article>
</div>
<div class="portlet-foot">
<?php $files = $card->getMedia(); foreach ($files as $file) : ?>
<span><a class="content" href="<?= UriFactory::build('{/base}/media/single?id=' . $file->id);?>"><?= $file->name; ?></a></span>
<?php $files = $card->files; foreach ($files as $file) : ?>
<span><a class="content" href="<?= UriFactory::build('{/base}/media/view?id=' . $file->id);?>"><?= $file->name; ?></a></span>
<?php endforeach; ?>
</div>
</section>
@ -50,8 +50,8 @@ $comments = $card->getComments();
<article><?= $comment->description; ?></article>
</div>
<div class="portlet-foot">
<?php $files = $comment->getMedia(); foreach ($files as $file) : ?>
<span><a class="content" href="<?= UriFactory::build('{/base}/media/single?id=' . $file->id);?>"><?= $file->name; ?></a></span>
<?php $files = $comment->files; foreach ($files as $file) : ?>
<span><a class="content" href="<?= UriFactory::build('{/base}/media/view?id=' . $file->id);?>"><?= $file->name; ?></a></span>
<?php endforeach; ?>
</div>
</section>

View File

@ -44,7 +44,7 @@ echo $this->data['nav']->render(); ?>
</div>
<div class="portlet-body">
<article><?= $board->description; ?></article>
<?php $tags = $board->getTags(); foreach ($tags as $tag) : ?>
<?php foreach ($board->tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= empty($tag->icon) ? '' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?>
</div>

View File

@ -1,4 +1,15 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Kanban\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');

View File

@ -30,7 +30,6 @@ use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
/**
@ -96,7 +95,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiBoardCU() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', 'Controller Test Board');
@ -110,7 +109,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
// update
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', $bId);
@ -127,7 +126,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testCreateColumn() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', 'Controller Test Column');
@ -146,7 +145,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testCreateCard() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', 'Controller Test Card');
@ -183,7 +182,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testCreateCommentCard() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('plain', 'Controller Test Description');
@ -216,7 +215,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiKanbanBoardCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');
@ -232,7 +231,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiKanbanColumnCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');
@ -248,7 +247,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiKanbanCardCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');
@ -264,7 +263,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiKanbanCardCommentCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');

View File

@ -41,7 +41,7 @@ final class KanbanBoardMapperTest extends \PHPUnit\Framework\TestCase
$boardR = KanbanBoardMapper::get()->where('id', $board->id)->execute();
self::assertEquals($board->name, $boardR->name);
self::assertEquals($board->getStatus(), $boardR->getStatus());
self::assertEquals($board->status, $boardR->status);
self::assertEquals($board->description, $boardR->description);
self::assertEquals($board->createdBy->id, $boardR->createdBy->id);
self::assertEquals($board->createdAt->format('Y-m-d'), $boardR->createdAt->format('Y-m-d'));

View File

@ -17,7 +17,6 @@ namespace Modules\Kanban\tests\Models;
use Modules\Kanban\Models\BoardStatus;
use Modules\Kanban\Models\KanbanBoard;
use Modules\Kanban\Models\NullKanbanColumn;
use Modules\Tag\Models\Tag;
/**
* @internal
@ -41,7 +40,7 @@ final class KanbanBoardTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void
{
self::assertEquals(0, $this->board->id);
self::assertEquals(BoardStatus::ACTIVE, $this->board->getStatus());
self::assertEquals(BoardStatus::ACTIVE, $this->board->status);
self::assertEquals('', $this->board->name);
self::assertEquals('', $this->board->description);
self::assertEquals(0, $this->board->createdBy->id);
@ -49,16 +48,6 @@ final class KanbanBoardTest extends \PHPUnit\Framework\TestCase
self::assertEquals([], $this->board->getColumns());
}
/**
* @covers Modules\Kanban\Models\KanbanBoard
* @group module
*/
public function testStatusInputOutput() : void
{
$this->board->setStatus(BoardStatus::ARCHIVED);
self::assertEquals(BoardStatus::ARCHIVED, $this->board->getStatus());
}
/**
* @covers Modules\Kanban\Models\KanbanBoard
* @group module
@ -81,27 +70,13 @@ final class KanbanBoardTest extends \PHPUnit\Framework\TestCase
self::assertFalse($this->board->removeColumn(0));
}
/**
* @covers Modules\Kanban\Models\KanbanBoard
* @group module
*/
public function testTagInputOutput() : void
{
$tag = new Tag();
$tag->setL11n('Tag');
$this->board->addTag($tag);
self::assertEquals($tag, $this->board->getTag(0));
self::assertCount(1, $this->board->getTags());
}
/**
* @covers Modules\Kanban\Models\KanbanBoard
* @group module
*/
public function testSerialize() : void
{
$this->board->setStatus(BoardStatus::ARCHIVED);
$this->board->status = BoardStatus::ARCHIVED;
$serialized = $this->board->jsonSerialize();

View File

@ -15,7 +15,6 @@ declare(strict_types=1);
namespace Modules\Kanban\tests\Models;
use Modules\Kanban\Models\KanbanCardComment;
use Modules\Media\Models\NullMedia;
/**
* @internal
@ -43,17 +42,7 @@ final class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase
self::assertEquals('', $this->comment->description);
self::assertEquals(0, $this->comment->createdBy->id);
self::assertInstanceOf('\DateTimeImmutable', $this->comment->createdAt);
self::assertEquals([], $this->comment->getMedia());
}
/**
* @covers Modules\Kanban\Models\KanbanCardComment
* @group module
*/
public function testMediaInputOutput() : void
{
$this->comment->addMedia($m = new NullMedia(7));
self::assertCount(1, $this->comment->getMedia());
self::assertEquals([], $this->comment->files);
}
/**

View File

@ -37,8 +37,8 @@ final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
$card->name = 'Some Card name';
$card->description = 'This is some card description';
$card->setStatus(CardStatus::ACTIVE);
$card->setType(CardType::TEXT);
$card->status = CardStatus::ACTIVE;
$card->type = CardType::TEXT;
$card->order = 1;
$card->column = 1;
$card->createdBy = new NullAccount(1);
@ -54,8 +54,8 @@ final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($card->description, $cardR->description);
self::assertEquals($card->column, $cardR->column);
self::assertEquals($card->order, $cardR->order);
self::assertEquals($card->getStatus(), $cardR->getStatus());
self::assertEquals($card->getType(), $cardR->getType());
self::assertEquals($card->status, $cardR->status);
self::assertEquals($card->type, $cardR->type);
self::assertEquals($card->createdBy->id, $cardR->createdBy->id);
self::assertEquals($card->createdAt->format('Y-m-d'), $cardR->createdAt->format('Y-m-d'));
self::assertEquals($card->ref, $cardR->ref);
@ -69,8 +69,8 @@ final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
{
$card = new KanbanCard();
$card->setStatus(CardStatus::ACTIVE);
$card->setType(CardType::TASK);
$card->status = CardStatus::ACTIVE;
$card->type = CardType::TASK;
$card->ref = 1;
$card->order = 1;
$card->column = 1;

View File

@ -18,8 +18,6 @@ use Modules\Kanban\Models\CardStatus;
use Modules\Kanban\Models\CardType;
use Modules\Kanban\Models\KanbanCard;
use Modules\Kanban\Models\NullKanbanCardComment;
use Modules\Media\Models\NullMedia;
use Modules\Tag\Models\Tag;
use Modules\Tasks\Models\Task;
/**
@ -44,8 +42,8 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void
{
self::assertEquals(0, $this->card->id);
self::assertEquals(CardStatus::ACTIVE, $this->card->getStatus());
self::assertEquals(CardType::TEXT, $this->card->getType());
self::assertEquals(CardStatus::ACTIVE, $this->card->status);
self::assertEquals(CardType::TEXT, $this->card->type);
self::assertEquals('', $this->card->name);
self::assertEquals('', $this->card->description);
self::assertEquals(0, $this->card->column);
@ -53,28 +51,8 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->card->createdBy->id);
self::assertInstanceOf('\DateTimeImmutable', $this->card->createdAt);
self::assertEquals([], $this->card->getComments());
self::assertEquals([], $this->card->getTags());
self::assertEquals([], $this->card->getMedia());
}
/**
* @covers Modules\Kanban\Models\KanbanCard
* @group module
*/
public function testStatusInputOutput() : void
{
$this->card->setStatus(CardStatus::ARCHIVED);
self::assertEquals(CardStatus::ARCHIVED, $this->card->getStatus());
}
/**
* @covers Modules\Kanban\Models\KanbanCard
* @group module
*/
public function testTypeInputOutput() : void
{
$this->card->setType(CardType::TASK);
self::assertEquals(CardType::TASK, $this->card->getType());
self::assertEquals([], $this->card->tags);
self::assertEquals([], $this->card->files);
}
/**
@ -87,16 +65,6 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
self::assertEquals(1, $this->card->column);
}
/**
* @covers Modules\Kanban\Models\KanbanCard
* @group module
*/
public function testMediaInputOutput() : void
{
$this->card->addMedia($m = new NullMedia(7));
self::assertCount(1, $this->card->getMedia());
}
/**
* @covers Modules\Kanban\Models\KanbanCard
* @group module
@ -108,20 +76,6 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
self::assertEquals(1, $this->card->getCommentCount());
}
/**
* @covers Modules\Kanban\Models\KanbanCard
* @group module
*/
public function testTagInputOutput() : void
{
$tag = new Tag();
$tag->setL11n('Tag');
$this->card->addTag($tag);
self::assertEquals($tag, $this->card->getTag(0));
self::assertCount(1, $this->card->getTags());
}
/**
* @covers Modules\Kanban\Models\KanbanCard
* @group module
@ -155,8 +109,8 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
$this->card->descriptionRaw = 'DescriptionRaw';
$this->card->order = 3;
$this->card->column = 2;
$this->card->setStatus(CardStatus::ARCHIVED);
$this->card->setType(CardType::TASK);
$this->card->status = CardStatus::ARCHIVED;
$this->card->type = CardType::TASK;
$serialized = $this->card->jsonSerialize();
unset($serialized['createdBy']);