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