mirror of
https://github.com/Karaka-Management/oms-Dashboard.git
synced 2026-02-16 18:38:41 +00:00
todo implementations
This commit is contained in:
parent
b191536f3a
commit
a93208441a
|
|
@ -24,6 +24,7 @@ use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Model\Message\FormValidation;
|
use phpOMS\Model\Message\FormValidation;
|
||||||
|
use Modules\Admin\Models\NullAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Api controller for the dashboard module.
|
* Api controller for the dashboard module.
|
||||||
|
|
@ -94,7 +95,7 @@ final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
$board = new DashboardBoard();
|
$board = new DashboardBoard();
|
||||||
$board->title = (string) ($request->getData('title') ?? '');
|
$board->title = (string) ($request->getData('title') ?? '');
|
||||||
$board->account = $request->header->account;
|
$board->account = new NullAccount($request->header->account);
|
||||||
$board->setStatus(DashboardBoardStatus::ACTIVE);
|
$board->setStatus(DashboardBoardStatus::ACTIVE);
|
||||||
|
|
||||||
return $board;
|
return $board;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Dashboard\Models;
|
namespace Modules\Dashboard\Models;
|
||||||
|
|
||||||
|
use Modules\Admin\Models\Account;
|
||||||
|
use Modules\Admin\Models\NullAccount;
|
||||||
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,10 +47,10 @@ class DashboardBoard implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Account.
|
* Account.
|
||||||
*
|
*
|
||||||
* @var null|int
|
* @var Account
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public ?int $account = null;
|
public Account $account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status.
|
* Status.
|
||||||
|
|
@ -66,6 +68,16 @@ class DashboardBoard implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
protected array $components = [];
|
protected array $components = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cosntructor.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->account = new NullAccount();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id
|
* Get id
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<?php $panels = $this->getData('panels'); ?>
|
<?php
|
||||||
<?php foreach ($panels as $panel) : ?>
|
$panels = $this->getData('panels');
|
||||||
<?= $panel->render(); ?>
|
if (empty($panels)) : ?>
|
||||||
<?php endforeach; ?>
|
<div class="emptyPage"></div>
|
||||||
|
<?php else: foreach ($panels as $panel) : ?>
|
||||||
|
<?= $panel->render(); ?>
|
||||||
|
<?php endforeach; endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://orange-management.org
|
* @link https://orange-management.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Dashboard\tests\Models;
|
namespace Modules\Dashboard\tests\Models;
|
||||||
|
|
@ -17,6 +18,7 @@ namespace Modules\Dashboard\tests\Models;
|
||||||
use Modules\Dashboard\Models\DashboardBoard;
|
use Modules\Dashboard\Models\DashboardBoard;
|
||||||
use Modules\Dashboard\Models\DashboardBoardStatus;
|
use Modules\Dashboard\Models\DashboardBoardStatus;
|
||||||
use Modules\Dashboard\Models\DashboardComponent;
|
use Modules\Dashboard\Models\DashboardComponent;
|
||||||
|
use Modules\Admin\Models\NullAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -28,7 +30,7 @@ final class DashboardBoardTest extends \PHPUnit\Framework\TestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function setUp() : void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->board = new DashboardBoard();
|
$this->board = new DashboardBoard();
|
||||||
}
|
}
|
||||||
|
|
@ -37,13 +39,13 @@ final class DashboardBoardTest extends \PHPUnit\Framework\TestCase
|
||||||
* @covers Modules\Dashboard\Models\DashboardBoard
|
* @covers Modules\Dashboard\Models\DashboardBoard
|
||||||
* @group module
|
* @group module
|
||||||
*/
|
*/
|
||||||
public function testDefault() : void
|
public function testDefault(): void
|
||||||
{
|
{
|
||||||
self::assertEquals(0, $this->board->getId());
|
self::assertEquals(0, $this->board->getId());
|
||||||
self::assertEquals('', $this->board->title);
|
self::assertEquals('', $this->board->title);
|
||||||
self::assertNull($this->board->account);
|
|
||||||
self::assertEquals([], $this->board->getComponents());
|
self::assertEquals([], $this->board->getComponents());
|
||||||
self::assertEquals(DashboardBoardStatus::ACTIVE, $this->board->getStatus());
|
self::assertEquals(DashboardBoardStatus::ACTIVE, $this->board->getStatus());
|
||||||
|
self::assertInstanceOf('\Modules\Admin\Models\NullAccount', $this->board->account);
|
||||||
self::assertInstanceOf('\Modules\Dashboard\Models\NullDashboardComponent', $this->board->getComponent(0));
|
self::assertInstanceOf('\Modules\Dashboard\Models\NullDashboardComponent', $this->board->getComponent(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +53,7 @@ final class DashboardBoardTest extends \PHPUnit\Framework\TestCase
|
||||||
* @covers Modules\Dashboard\Models\DashboardBoard
|
* @covers Modules\Dashboard\Models\DashboardBoard
|
||||||
* @group module
|
* @group module
|
||||||
*/
|
*/
|
||||||
public function testStatusInputOutput() : void
|
public function testStatusInputOutput(): void
|
||||||
{
|
{
|
||||||
$this->board->setStatus(DashboardBoardStatus::INACTIVE);
|
$this->board->setStatus(DashboardBoardStatus::INACTIVE);
|
||||||
self::assertEquals(DashboardBoardStatus::INACTIVE, $this->board->getStatus());
|
self::assertEquals(DashboardBoardStatus::INACTIVE, $this->board->getStatus());
|
||||||
|
|
@ -61,7 +63,7 @@ final class DashboardBoardTest extends \PHPUnit\Framework\TestCase
|
||||||
* @covers Modules\Dashboard\Models\DashboardBoard
|
* @covers Modules\Dashboard\Models\DashboardBoard
|
||||||
* @group module
|
* @group module
|
||||||
*/
|
*/
|
||||||
public function testInvalidStatus() : void
|
public function testInvalidStatus(): void
|
||||||
{
|
{
|
||||||
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
||||||
$this->board->setStatus(999);
|
$this->board->setStatus(999);
|
||||||
|
|
@ -71,7 +73,7 @@ final class DashboardBoardTest extends \PHPUnit\Framework\TestCase
|
||||||
* @covers Modules\Dashboard\Models\DashboardBoard
|
* @covers Modules\Dashboard\Models\DashboardBoard
|
||||||
* @group module
|
* @group module
|
||||||
*/
|
*/
|
||||||
public function testComponentInputOutput() : void
|
public function testComponentInputOutput(): void
|
||||||
{
|
{
|
||||||
$id = $this->board->addComponent($temp = new DashboardComponent());
|
$id = $this->board->addComponent($temp = new DashboardComponent());
|
||||||
self::assertEquals($temp, $this->board->getComponent($id));
|
self::assertEquals($temp, $this->board->getComponent($id));
|
||||||
|
|
@ -84,16 +86,16 @@ final class DashboardBoardTest extends \PHPUnit\Framework\TestCase
|
||||||
* @covers Modules\Dashboard\Models\DashboardBoard
|
* @covers Modules\Dashboard\Models\DashboardBoard
|
||||||
* @group module
|
* @group module
|
||||||
*/
|
*/
|
||||||
public function testSerialize() : void
|
public function testSerialize(): void
|
||||||
{
|
{
|
||||||
$this->board->title = 'Title';
|
$this->board->title = 'Title';
|
||||||
$this->board->account = 2;
|
$this->board->account = new NullAccount(2);
|
||||||
$this->board->setStatus(DashboardBoardStatus::INACTIVE);
|
$this->board->setStatus(DashboardBoardStatus::INACTIVE);
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'account' => 2,
|
'account' => $this->board->account,
|
||||||
'title' => 'Title',
|
'title' => 'Title',
|
||||||
'status' => DashboardBoardStatus::INACTIVE,
|
'status' => DashboardBoardStatus::INACTIVE,
|
||||||
'components' => [],
|
'components' => [],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user