mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°931 change CSS for displaying TagSet datas
This commit is contained in:
@@ -6054,65 +6054,84 @@ class AttributeTagSet extends AttributeDBFieldVoid
|
||||
* @throws \CoreException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
if ($value instanceof ormTagSet)
|
||||
{
|
||||
if ($bLocalize)
|
||||
{
|
||||
$aValues = $value->GetTags();
|
||||
}
|
||||
else
|
||||
{
|
||||
$aValues = $value->GetValue();
|
||||
}
|
||||
if (empty($aValues))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
return '<span class="attribute-tagset">'.implode('</span><span class="attribute-tagset">', $aValues).'</span>';
|
||||
}
|
||||
if (is_string($value))
|
||||
{
|
||||
try
|
||||
{
|
||||
$oValue = $this->MakeRealValue($value, $oHostObject);
|
||||
return $this->GetAsHTML($oValue, $oHostObject, $bLocalize);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// unknown tags are present display the code instead
|
||||
}
|
||||
$aTagCodes = explode(' ', $value);
|
||||
$aValues = array();
|
||||
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode());
|
||||
foreach ($aTagCodes as $sTagCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
$oTagSet->AddTag($sTagCode);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$aValues[] = $sTagCode;
|
||||
}
|
||||
}
|
||||
$sHTML = '';
|
||||
if (!empty($aValues))
|
||||
{
|
||||
$sHTML .= '<span class="attribute-tagset-undefined">'.implode('</span><span class="attribute-tagset-undefined">', $aValues).'</span>';
|
||||
}
|
||||
$aValues = $oTagSet->GetTags();
|
||||
if (!empty($aValues))
|
||||
{
|
||||
$sHTML .= '<span class="attribute-tagset">'.implode('</span><span class="attribute-tagset">', $aValues).'</span>';
|
||||
}
|
||||
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
if ($value instanceof ormTagSet)
|
||||
{
|
||||
if ($bLocalize)
|
||||
{
|
||||
$aValues = $value->GetTags();
|
||||
}
|
||||
else
|
||||
{
|
||||
$aValues = $value->GetValue();
|
||||
}
|
||||
if (empty($aValues))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $sHTML;
|
||||
}
|
||||
return parent::GetAsHTML($value, $oHostObject, $bLocalize);
|
||||
return $this->GenerateViewHtmlForValues($aValues);
|
||||
}
|
||||
if (is_string($value))
|
||||
{
|
||||
try
|
||||
{
|
||||
$oValue = $this->MakeRealValue($value, $oHostObject);
|
||||
|
||||
}
|
||||
return $this->GetAsHTML($oValue, $oHostObject, $bLocalize);
|
||||
} catch (Exception $e)
|
||||
{
|
||||
// unknown tags are present display the code instead
|
||||
}
|
||||
$aTagCodes = explode(' ', $value);
|
||||
$aValues = array();
|
||||
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()),
|
||||
$this->GetCode());
|
||||
foreach($aTagCodes as $sTagCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
$oTagSet->AddTag($sTagCode);
|
||||
} catch (Exception $e)
|
||||
{
|
||||
$aValues[] = $sTagCode;
|
||||
}
|
||||
}
|
||||
$sHTML = '';
|
||||
if (!empty($aValues))
|
||||
{
|
||||
$sHTML .= $this->GenerateViewHtmlForValues($aValues, 'attribute-tagset-undefined');
|
||||
}
|
||||
$aValues = $oTagSet->GetTags();
|
||||
if (!empty($aValues))
|
||||
{
|
||||
$sHTML .= $this->GenerateViewHtmlForValues($aValues);
|
||||
}
|
||||
|
||||
return $sHTML;
|
||||
}
|
||||
|
||||
return parent::GetAsHTML($value, $oHostObject, $bLocalize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aValues
|
||||
* @param string $sCssClass
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function GenerateViewHtmlForValues($aValues, $sCssClass = 'attribute-tagset')
|
||||
{
|
||||
$sHtml = '<span class="'.$sCssClass.'">';
|
||||
foreach($aValues as $sTagSetLabel)
|
||||
{
|
||||
$sHtml .= '<span>'.$sTagSetLabel.'</span>';
|
||||
}
|
||||
$sHtml .= '</span>';
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
|
||||
@@ -2862,20 +2862,21 @@ table.listResults .originColor {
|
||||
.menu-icon-select > .ui-menu-item {
|
||||
padding: 0.3em 3%;
|
||||
}
|
||||
.attribute-tagset {
|
||||
|
||||
.attribute-tagset > span, .attribute-tagset-undefined > span {
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
background-color: grey;
|
||||
margin-right: 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.attribute-tagset > span {
|
||||
color: white;
|
||||
margin-right: 3px;
|
||||
border-radius: 4px;
|
||||
background-color: grey;
|
||||
}
|
||||
.attribute-tagset-undefined {
|
||||
|
||||
.attribute-tagset-undefined > span {
|
||||
color: grey;
|
||||
font-style: italic;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
background-color: lightgrey;
|
||||
margin-right: 3px;
|
||||
border-radius: 4px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@@ -3261,21 +3261,20 @@ table.listResults .originColor{
|
||||
padding: .3em 3%;
|
||||
}
|
||||
|
||||
.attribute-tagset{
|
||||
.attribute-tagset > span, .attribute-tagset-undefined > span {
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
background-color: grey;
|
||||
color: white;
|
||||
margin-right: 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.attribute-tagset-undefined{
|
||||
.attribute-tagset > span {
|
||||
color: white;
|
||||
background-color: grey;
|
||||
}
|
||||
|
||||
.attribute-tagset-undefined > span {
|
||||
color: grey;
|
||||
font-style: italic;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
background-color: lightgrey;
|
||||
margin-right: 3px;
|
||||
border-radius: 4px;
|
||||
font-style: italic;
|
||||
}
|
||||
Reference in New Issue
Block a user