mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°2847 Refactor Inputs components
This commit is contained in:
35
sources/application/UI/Component/Input/Select/Select.php
Normal file
35
sources/application/UI/Component/Input/Select/Select.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Input\Select;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Component\Input\Input;
|
||||
|
||||
class Select extends Input
|
||||
{
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/input/select/select';
|
||||
|
||||
/** @var array */
|
||||
protected $aOptions;
|
||||
|
||||
public function __construct(?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->aOptions = [];
|
||||
}
|
||||
|
||||
public function AddOption(SelectOption $oOption)
|
||||
{
|
||||
$this->aOptions[$oOption->GetId()] = $oOption;
|
||||
}
|
||||
|
||||
public function GetSubBlocks()
|
||||
{
|
||||
return $this->aOptions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Input\Select;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
class SelectOption extends UIBlock
|
||||
{
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/input/select/selectoption';
|
||||
|
||||
/** @var string */
|
||||
protected $sValue;
|
||||
/** @var string */
|
||||
protected $sLabel;
|
||||
/** @var bool */
|
||||
protected $bSelected;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetValue(): string
|
||||
{
|
||||
return $this->sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return SelectOption
|
||||
*/
|
||||
public function SetValue(string $sValue): SelectOption
|
||||
{
|
||||
$this->sValue = $sValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetLabel(): string
|
||||
{
|
||||
return $this->sLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sLabel
|
||||
*
|
||||
* @return SelectOption
|
||||
*/
|
||||
public function SetLabel(string $sLabel): SelectOption
|
||||
{
|
||||
$this->sLabel = $sLabel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSelected(): bool
|
||||
{
|
||||
return $this->bSelected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bSelected
|
||||
*
|
||||
* @return SelectOption
|
||||
*/
|
||||
public function SetSelected(bool $bSelected): SelectOption
|
||||
{
|
||||
$this->bSelected = $bSelected;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user