mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
Fix some value types
This commit is contained in:
@@ -12,6 +12,7 @@ use Combodo\iTop\Forms\Block\Base\ChoiceFormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\PropertyType\Serializer\XMLFormat\AbstractXMLFormat;
|
||||
use Combodo\iTop\PropertyType\Serializer\XMLFormat\XMLFormatFactory;
|
||||
use Combodo\iTop\PropertyType\ValueType\AbstractValueType;
|
||||
use Combodo\iTop\PropertyType\ValueType\Branch\AbstractBranchValueType;
|
||||
use Combodo\iTop\PropertyType\ValueType\Leaf\AbstractLeafValueType;
|
||||
use Combodo\iTop\PropertyType\ValueType\ValueTypeFactory;
|
||||
@@ -20,6 +21,7 @@ class ValueTypeCollectionOfValues extends AbstractLeafValueType
|
||||
{
|
||||
private string $sFormBlockClass;
|
||||
private AbstractXMLFormat $oXMLFormat;
|
||||
private AbstractValueType $oRealValueType;
|
||||
|
||||
public function GetFormBlockClass(): string
|
||||
{
|
||||
@@ -29,17 +31,27 @@ class ValueTypeCollectionOfValues extends AbstractLeafValueType
|
||||
public function InitFromDomNode(DesignElement $oDomNode, ?AbstractBranchValueType $oParent = null): void
|
||||
{
|
||||
$oNode = $oDomNode->GetUniqueElement('value-type');
|
||||
$oRealValueType = ValueTypeFactory::GetInstance()->CreateValueTypeFromDomNode($oNode, $oParent);
|
||||
$this->sFormBlockClass = $oRealValueType->getFormBlockClass();
|
||||
$this->oRealValueType = ValueTypeFactory::GetInstance()->CreateValueTypeFromDomNode($oNode, $oParent);
|
||||
$this->sFormBlockClass = $this->oRealValueType->getFormBlockClass();
|
||||
|
||||
if (is_a($this->sFormBlockClass, ChoiceFormBlock::class, true)) {
|
||||
$this->aFormBlockOptionsForPHP['multiple'] = 'true';
|
||||
$this->oRealValueType->aFormBlockOptionsForPHP['multiple'] = 'true';
|
||||
}
|
||||
|
||||
$oNode = $oDomNode->GetUniqueElement('xml-format');
|
||||
$this->oXMLFormat = XMLFormatFactory::GetInstance()->CreateXMLFormatFromDomNode($oNode);
|
||||
|
||||
parent::InitFromDomNode($oDomNode, $oParent);
|
||||
|
||||
$this->oRealValueType->sLabel = $this->sLabel;
|
||||
$this->oRealValueType->sRelevanceCondition = $this->sRelevanceCondition;
|
||||
$this->oRealValueType->sId = $this->sId;
|
||||
$this->oRealValueType->sIdWithPath = $this->sIdWithPath;
|
||||
}
|
||||
|
||||
public function ToPHPFormBlock(array &$aPHPFragments = []): string
|
||||
{
|
||||
return $this->oRealValueType->ToPHPFormBlock($aPHPFragments);
|
||||
}
|
||||
|
||||
public function Normalize(mixed $value): mixed
|
||||
|
||||
@@ -37,7 +37,7 @@ class ValueTypeIcon extends AbstractLeafValueType
|
||||
$sValue = utils::QuoteForPHP($aIcon['label']);
|
||||
$sCode = utils::QuoteForPHP($aIcon['value']);
|
||||
$sChoices .= <<<PHP
|
||||
\t\t\t\t$sCode => $sValue,\n
|
||||
\t\t\t\t$sValue => $sCode,\n
|
||||
PHP;
|
||||
}
|
||||
$sChoices .= "\t\t\t]";
|
||||
|
||||
@@ -602,7 +602,9 @@ class FormFor__CollectionOfValuesTest extends Combodo\iTop\Forms\Block\Base\Form
|
||||
\$this->Add('coll', 'Combodo\iTop\Forms\Block\DataModel\AttributeValueChoiceFormBlock', [
|
||||
'label' => 'UI:ClassAttributeValue',
|
||||
'multiple' => true,
|
||||
]);
|
||||
])
|
||||
->SetInputValue('class', 'Contact')
|
||||
->SetInputValue('attribute', 'status');
|
||||
}
|
||||
}
|
||||
PHP,
|
||||
@@ -883,6 +885,8 @@ PHP;
|
||||
|
||||
$this->AssertPHPCodeIsValid($sProducedPHP);
|
||||
$this->assertStringStartsWith($sExpectedStart, $sProducedPHP);
|
||||
|
||||
echo $sProducedPHP;
|
||||
}
|
||||
|
||||
public function testCompileFormForClassSelection()
|
||||
|
||||
Reference in New Issue
Block a user