diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 4603f25a4..00679ecbe 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -10024,7 +10024,8 @@ abstract class AttributeSet extends AttributeDBFieldVoid { if ($value instanceof ormSet) { - $value = $value->GetValues(); + $aValues = $value->GetValues(); + return $this->GenerateViewHtmlForValues($aValues); } if (is_array($value)) { @@ -10033,6 +10034,47 @@ abstract class AttributeSet extends AttributeDBFieldVoid return $value; } + /** + * HTML representation of a list of values (read-only) + * accept a list of strings + * + * @param array $aValues + * @param string $sCssClass + * @param bool $bWithLink if true will generate a link, otherwise just a "a" tag without href + * + * @return string + * @throws \CoreException + * @throws \OQLException + */ + public function GenerateViewHtmlForValues($aValues, $sCssClass = '', $bWithLink = true) + { + if (empty($aValues)) {return '';} + $sHtml = ''; + foreach($aValues as $sValue) + { + $sClass = MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()); + $sAttCode = $this->GetCode(); + $sLabel = utils::HtmlEntities($this->GetValueLabel($sValue)); + $sDescription = utils::HtmlEntities($this->GetValueDescription($sValue)); + $oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sValue'"); + $oAppContext = new ApplicationContext(); + $sContext = $oAppContext->GetForLink(); + $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($oFilter->GetClass()); + $sFilter = rawurlencode($oFilter->serialize()); + $sLink = ''; + if ($bWithLink) + { + $sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}"; + $sLink = ' href="'.$sUrl.'"'; + } + $sHtml .= ''.$sLabel.''; + } + $sHtml .= ''; + + return $sHtml; + } + /** * @param $value * @param string $sSeparator @@ -10176,16 +10218,7 @@ class AttributeEnumSet extends AttributeSet { if ($value instanceof ormSet) { - /** @var ormSet $oOrmSet */ - $oOrmSet = $value; - $aRes = array(); - foreach ($oOrmSet->GetValues() as $sValue) - { - $sLabel = $this->GetValueLabel($sValue); - $sDescription = $this->GetValueDescription($sValue); - $aRes[] = "".parent::GetAsHtml($sLabel).""; - } - $sRes = implode(', ', $aRes); + $sRes = $this->GenerateViewHtmlForValues($value->GetValues()); } else { diff --git a/css/light-grey.scss b/css/light-grey.scss index 67c348225..1f0d0cb9a 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -3563,9 +3563,9 @@ table.listResults .originColor{ @extend %attribute-set-item-edition; } ////////////////////// -// TagSet attribute // +// Set attribute // // Always styled like the selectize items, see below. -.attribute-tag-set.attribute-set{ +.attribute-set{ .attribute-set-item{ @extend %attribute-set-item-edition; }