From cc8c6ac0271fb7374eda3ab0b14f380b39eeea2f Mon Sep 17 00:00:00 2001 From: Anne-Catherine <57360138+accognet@users.noreply.github.com> Date: Thu, 8 Jun 2023 17:29:53 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03213=20-=20Order=20transition=20attribut?= =?UTF-8?q?es=20like=20in=20the=20"details"=20zlist=20instead=20of=20reord?= =?UTF-8?q?ering=20them=20regarding=20the=20dependencies=20(#306)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit N°3213 - Order transition attributes like in the "details" zlist instead of reordering them regarding the dependencies (#306) --------- Co-authored-by: Molkobain --- application/cmdbabstract.class.inc.php | 19 ++++++------------- core/metamodel.class.php | 3 +-- setup/compiler.class.inc.php | 14 +++++--------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 4c73c9c82..ada63bbe2 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3392,22 +3392,15 @@ EOF ]; // The list of candidate fields is made of the ordered list of "details" attributes + other attributes - $aAttributes = array(); - foreach ($this->FlattenZList(MetaModel::GetZListItems($sClass, 'details')) as $sAttCode) { - $aAttributes[$sAttCode] = true; - } + // First attributes from the "details" zlist as they were sorted... + $aList = $this->FlattenZList(MetaModel::GetZListItems($sClass, 'details')); + + // ... then append forgotten attributes foreach (MetaModel::GetAttributesList($sClass) as $sAttCode) { - if (!array_key_exists($sAttCode, $aAttributes)) { - $aAttributes[$sAttCode] = true; + if (!in_array($sAttCode, $aList)) { + $aList[] = $sAttCode; } } - // Order the fields based on their dependencies, set the fields for which there is only one possible value - // and perform this in the order of dependencies to avoid dead-ends - $aDeps = array(); - foreach ($aAttributes as $sAttCode => $trash) { - $aDeps[$sAttCode] = MetaModel::GetPrerequisiteAttributes($sClass, $sAttCode); - } - $aList = $this->OrderDependentFields($aDeps); $bExistFieldToDisplay = false; foreach ($aList as $sAttCode) { diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 66606ab69..8d80ff618 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -3621,8 +3621,7 @@ abstract class MetaModel { MyHelpers::CheckKeyInArray('list code', $sListCode, self::$m_aListInfos); - if (!$sTargetClass) - { + if (!$sTargetClass) { $sTargetClass = self::GetCallersPHPClass("Init"); } diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 828cf0e04..4df999dff 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -1540,7 +1540,7 @@ EOF; // $oField $sAttCode = $oField->getAttribute('id'); $sAttType = $oField->getAttribute('xsi:type'); - + $aParameters = $this->CompileAttribute($sAttType, $oField, $sModuleRelativeDir, $sClass, $sAttCode, $sCss, $aTagFieldsInfo, $sTempTargetDir); @@ -1854,20 +1854,16 @@ EOF; $this->aCustomListsCodes[] = $sListCode; } - $sZlists .= "\n" . $this->GeneratePhpCodeForZlist($sListCode, $oListNode); + $sZlists .= "\n".$this->GeneratePhpCodeForZlist($sListCode, $oListNode); } // Methods $oMethods = $oClass->GetUniqueElement('methods'); - foreach($oMethods->getElementsByTagName('method') as $oMethod) - { + foreach ($oMethods->getElementsByTagName('method') as $oMethod) { $sMethodCode = $oMethod->GetChildText('code'); - if ($sMethodComment = $oMethod->GetChildText('comment', null)) - { + if ($sMethodComment = $oMethod->GetChildText('comment', null)) { $sMethods .= "\n\t$sMethodComment\n".$sMethodCode."\n"; - } - else - { + } else { $sMethods .= "\n\n".$sMethodCode."\n"; } }