mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-29 21:48:45 +02:00
N°2847 Refactor Inputs components
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
namespace Combodo\iTop\Application\UI\Component\Input;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Component\Input\Select\Select;
|
||||
use Combodo\iTop\Application\UI\Component\Input\Select\SelectOption;
|
||||
|
||||
class InputFactory
|
||||
{
|
||||
|
||||
@@ -22,13 +25,20 @@ class InputFactory
|
||||
return $oInput;
|
||||
}
|
||||
|
||||
public static function MakeForSelect(string $sName, string $sLabel, ?string $sId = null): Select
|
||||
public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel
|
||||
{
|
||||
$oInput = new Select();
|
||||
$oInput->SetName($sName);
|
||||
|
||||
$oInputWithLabel = new InputWithLabel($sLabel, $oInput, $sId);
|
||||
|
||||
return $oInputWithLabel;
|
||||
}
|
||||
public static function MakeForSelect(string $sName, ?string $sId = null): Select
|
||||
{
|
||||
$oInput = new Select($sId);
|
||||
|
||||
$oInput->SetName($sName)
|
||||
->SetLabel($sLabel);
|
||||
|
||||
$oInput->SetName($sName);
|
||||
|
||||
return $oInput;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,49 @@
|
||||
namespace Combodo\iTop\Application\UI\Component\Input;
|
||||
|
||||
|
||||
class InputWithLabel extends Input
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
class InputWithLabel extends UIBlock
|
||||
{
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/input/inputwithlabel';
|
||||
|
||||
/** @var string */
|
||||
protected $sLabel;
|
||||
/** @var \Combodo\iTop\Application\UI\Component\Input\Input */
|
||||
protected $oInput;
|
||||
|
||||
/**
|
||||
* InputWithLabel constructor.
|
||||
*
|
||||
* @param string $sLabel
|
||||
* @param \Combodo\iTop\Application\UI\Component\Input\Input $oInput
|
||||
*/
|
||||
public function __construct(string $sLabel, \Combodo\iTop\Application\UI\Component\Input\Input $oInput, ?string $sId)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->sLabel = $sLabel;
|
||||
$this->oInput = $oInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Combodo\iTop\Application\UI\Component\Input\Input
|
||||
*/
|
||||
public function GetInput(): \Combodo\iTop\Application\UI\Component\Input\Input
|
||||
{
|
||||
return $this->oInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Combodo\iTop\Application\UI\Component\Input\Input $oInput
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetInput(\Combodo\iTop\Application\UI\Component\Input\Input $oInput): InputWithLabel
|
||||
{
|
||||
$this->oInput = $oInput;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Input;
|
||||
namespace Combodo\iTop\Application\UI\Component\Input\Select;
|
||||
|
||||
|
||||
class Select extends InputWithLabel
|
||||
use Combodo\iTop\Application\UI\Component\Input\Input;
|
||||
|
||||
class Select extends Input
|
||||
{
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/input/select';
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/input/select/select';
|
||||
|
||||
/** @var array */
|
||||
protected $aOptions;
|
||||
@@ -5,14 +5,14 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Input;
|
||||
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/selectoption';
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/input/select/selectoption';
|
||||
|
||||
/** @var string */
|
||||
protected $sValue;
|
||||
Reference in New Issue
Block a user