Add UIBlocks to twig (DataTable, Form, Input)

This commit is contained in:
Eric
2021-01-14 13:14:05 +01:00
parent e51fd028fa
commit d8316a090a
21 changed files with 434 additions and 212 deletions

View File

@@ -7,12 +7,13 @@
namespace Combodo\iTop\Application\UI\Base\Component\Field;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* @since 3.0.0
*/
class Field extends UIBlock
class Field extends UIContentBlock
{
/** @inheritdoc */
public const BLOCK_CODE = 'ibo-field';
@@ -48,21 +49,18 @@ class Field extends UIBlock
protected $sLabel;
/** @var string */
protected $sValueId;
/**
* Could be Input, but we have legacy code that needs to set raw HTML !
*
* @var UIBlock
*/
protected $oValue;
/** @var string */
protected $sComments;
public function __construct(string $sLabel, UIBlock $oValue, ?string $sId = null)
public function __construct(string $sLabel, UIBlock $oValue = null, ?string $sId = null)
{
parent::__construct($sId);
$this->sLabel = $sLabel;
$this->oValue = $oValue;
$this->sValueId = null;
if (!is_null($oValue)) {
$this->AddSubBlock($oValue);
}
}
/**

View File

@@ -8,7 +8,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\Field;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput;
use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* @since 3.0.0
@@ -61,7 +61,7 @@ class FieldFactory
$oField->$sMethodName((($iParamsFlags & $iConstant) === $iConstant));
}
public static function MakeFromObject(string $sLabel, AbstractInput $oInput, ?string $sLayout = null)
public static function MakeFromObject(string $sLabel, UIBlock $oInput, ?string $sLayout = null)
{
$oField = new Field($sLabel, $oInput);

View File

@@ -20,6 +20,8 @@ class Input extends AbstractInput
public const INPUT_HIDDEN = 'hidden';
protected $bChecked = false;
/** @var string */
protected $sType;
@@ -39,4 +41,23 @@ class Input extends AbstractInput
return $this;
}
/**
* @param $bChecked
*
* @return $this
*/
public function SetChecked($bChecked)
{
$this->bChecked = $bChecked;
return $this;
}
/**
* @return bool
*/
public function IsChecked()
{
return $this->bChecked;
}
}

View File

@@ -26,6 +26,32 @@ class InputFactory
return $oInput;
}
public static function MakeStandard(string $sType, string $sName, string $sValue, ?string $sId = null): Input
{
$oInput = new Input($sId);
$oInput->SetType($sType)
->SetName($sName)
->SetValue($sValue);
return $oInput;
}
public static function MakeWithLabel(string $sType, string $sLabel, string $sName, string $sValue, ?string $sId = null): InputWithLabel
{
$oInput = new Input($sId);
$oInput->SetType($sType)
->SetName($sName)
->SetValue($sValue);
if (is_null($sId)) {
$sId = $oInput->GetId();
}
return new InputWithLabel($sLabel, $oInput, $sId);
}
/**
* @see Field component that is better adapter when dealing with a standard iTop form
*