mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
Move dashboard blocks to itop project and keep demonstrator one
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Application\Dashboard\FormBlock;
|
||||
|
||||
use Combodo\iTop\Forms\Block\Base\ChoiceFormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\CollectionBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\TextFormBlock;
|
||||
|
||||
class DashboardFormBlock extends FormBlock
|
||||
{
|
||||
protected function BuildForm(): void
|
||||
{
|
||||
// Label
|
||||
$this->Add('title', TextFormBlock::class, [
|
||||
'label' => 'Title',
|
||||
]);
|
||||
|
||||
// Refresh
|
||||
$this->Add('refresh', ChoiceFormBlock::class, [
|
||||
'label' => 'Refresh',
|
||||
'choices' => [
|
||||
'Never' => 0,
|
||||
'Every 5 minutes' => 5,
|
||||
'Every 15 minutes' => 15,
|
||||
'Every 30 minutes' => 30,
|
||||
'Every hour' => 60,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->Add('dashlets_list', CollectionBlock::class, [
|
||||
'label' => 'Dashlets List',
|
||||
'block_entry_type' => DashletFormBlock::class,
|
||||
'block_entry_options' => [],
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
48
sources/Application/Dashboard/FormBlock/DashletFormBlock.php
Normal file
48
sources/Application/Dashboard/FormBlock/DashletFormBlock.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Application\Dashboard\FormBlock;
|
||||
|
||||
use Combodo\iTop\Forms\Block\Base\ChoiceFormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\IntegerFormBlock;
|
||||
use Combodo\iTop\PropertyType\PropertyTypeService;
|
||||
|
||||
class DashletFormBlock extends FormBlock
|
||||
{
|
||||
protected function BuildForm(): void
|
||||
{
|
||||
// type
|
||||
$aPropertyTypes = PropertyTypeService::GetInstance()->ListPropertyTypesByType('Dashlet');
|
||||
$this->Add('class', ChoiceFormBlock::class, [
|
||||
'label' => 'Class',
|
||||
'choices' => array_combine($aPropertyTypes, $aPropertyTypes),
|
||||
]);
|
||||
|
||||
// column
|
||||
$this->Add('position_x', IntegerFormBlock::class, [
|
||||
'label' => 'Position X',
|
||||
]);
|
||||
|
||||
// row
|
||||
$this->Add('position_y', IntegerFormBlock::class, [
|
||||
'label' => 'Position Y',
|
||||
]);
|
||||
|
||||
// column
|
||||
$this->Add('height', IntegerFormBlock::class, [
|
||||
'label' => 'Height',
|
||||
]);
|
||||
|
||||
// row
|
||||
$this->Add('width', IntegerFormBlock::class, [
|
||||
'label' => 'Width',
|
||||
]);
|
||||
|
||||
// dashlet
|
||||
$this->Add('dashlet', DashletPropertiesFormBlock::class, [
|
||||
'label' => 'Dashlet',
|
||||
])
|
||||
->InputDependsOn(DashletPropertiesFormBlock::INPUT_DASHLET_TYPE, 'class', ChoiceFormBlock::OUTPUT_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Application\Dashboard\FormBlock;
|
||||
|
||||
use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\Forms\IO\Format\StringIOFormat;
|
||||
use Combodo\iTop\Forms\Register\IORegister;
|
||||
use Combodo\iTop\PropertyType\PropertyTypeService;
|
||||
|
||||
class DashletPropertiesFormBlock extends FormBlock
|
||||
{
|
||||
// inputs
|
||||
public const INPUT_DASHLET_TYPE = 'dashlet_type';
|
||||
|
||||
protected function RegisterIO(IORegister $oIORegister): void
|
||||
{
|
||||
parent::RegisterIO($oIORegister);
|
||||
$oIORegister->AddInput(self::INPUT_DASHLET_TYPE, StringIOFormat::class);
|
||||
}
|
||||
|
||||
public function GetFormType(): string
|
||||
{
|
||||
$sDashletType = strval($this->GetInputValue(self::INPUT_DASHLET_TYPE));
|
||||
$oDashlet = PropertyTypeService::GetInstance()->GetFormBlockById($sDashletType, 'Dashlet');
|
||||
|
||||
return $oDashlet->GetFormType();
|
||||
}
|
||||
|
||||
public function GetOptions(): array
|
||||
{
|
||||
$sDashletType = strval($this->GetInputValue(self::INPUT_DASHLET_TYPE));
|
||||
$oDashlet = PropertyTypeService::GetInstance()->GetFormBlockById($sDashletType, 'Dashlet');
|
||||
|
||||
return $oDashlet->GetOptions();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user