N°3746 - Migrate modal to new UIBlock system

This commit is contained in:
acognet
2021-02-26 10:05:02 +01:00
parent 1060c0ca94
commit cebbc215d7
38 changed files with 1094 additions and 868 deletions

View File

@@ -18,6 +18,8 @@ abstract class AbstractInput extends UIBlock
protected $sName;
/** @var string */
protected $sValue;
/**@var string */
protected $sPlaceholder;
public function GetName(): string
{
@@ -52,4 +54,25 @@ abstract class AbstractInput extends UIBlock
return $this;
}
/**
* @return string
*/
public function GetPlaceholder(): ?string
{
return $this->sPlaceholder;
}
/**
* @param string $sPlaceholder
*
* @return $this
*/
public function SetPlaceholder(string $sPlaceholder)
{
$this->sPlaceholder = $sPlaceholder;
return $this;
}
}

View File

@@ -94,4 +94,24 @@ class InputUIBlockFactory extends AbstractUIBlockFactory
return new InputWithLabel($sLabel, $oInput, $sId);
}
/**
* If you need to have a real field with a label, you might use a {@link Field} component instead
*
* @param string $sName
* @param string|null $sId
*
* @return \Combodo\iTop\Application\UI\Base\Component\Input\Select
*/
public static function MakeForSelect(string $sName, ?string $sId = null): Select
{
$oInput = new Select($sId);
$oInput->SetName($sName);
if (is_null($sId)) {
$sId = $oInput->GetId();
}
return $oInput;
}
}

View File

@@ -23,6 +23,8 @@ class InputWithLabel extends UIBlock
protected $sLabel;
/** @var \Combodo\iTop\Application\UI\Base\UIBlock */
protected $oInput;
/** @var bool Label before input ? */
protected $bBeforeInput;
/**
* @param string $sLabel
@@ -34,6 +36,7 @@ class InputWithLabel extends UIBlock
parent::__construct($sId);
$this->sLabel = $sLabel;
$this->oInput = $oInput;
$this->bBeforeInput = true;
}
/**
@@ -56,6 +59,30 @@ class InputWithLabel extends UIBlock
return $this;
}
/**
* @param bool $bBeforeInput
*
* @return $this
*/
public function SetBeforeInput(bool $bBeforeInput)
{
$this->bBeforeInput = $bBeforeInput;
if ($bBeforeInput) {
$this->oInput->AddCSSClass('ibo-input--label-left');
} else {
$this->oInput->AddCSSClass('ibo-input--label-right');
}
return $this;
}
/**
* @return bool
*/
public function IsLabelBefore(): bool
{
return $this->bBeforeInput;
}
/**
* @return string

View File

@@ -21,16 +21,17 @@ class TextArea extends AbstractInput
/** @var int */
protected $iRows;
public function __construct(?string $sValue, ?string $sId = null, ?int $iCols = null, ?int $iRows = null)
public function __construct(string $sName, ?string $sValue, ?string $sId = null, ?int $iCols = null, ?int $iRows = null)
{
parent::__construct($sId);
$this->sName = $sName;
$this->sValue = $sValue;
$this->iCols = $iCols;
$this->iRows = $iRows;
}
public function GetCols(): int
public function GetCols(): ?int
{
return $this->iCols;
}
@@ -47,7 +48,7 @@ class TextArea extends AbstractInput
return $this;
}
public function GetRows(): int
public function GetRows(): ?int
{
return $this->iRows;
}