New concept in the XML: HighlightScale to avoid overloading GetIcon and GetHilightClass...

SVN:trunk[3291]
This commit is contained in:
Denis Flaven
2014-07-28 15:16:16 +00:00
parent 357ae4abb1
commit fd9008a163
11 changed files with 604 additions and 581 deletions

View File

@@ -145,6 +145,23 @@
</field>
</fields>
<lifecycle>
<highlight_scale>
<item id="approved">
<rank>1</rank>
<color>HIGHLIGHT_CLASS_NONE</color>
<icon>images/change-approved.png</icon>
</item>
<item id="rejected">
<rank>2</rank>
<color>HIGHLIGHT_CLASS_NONE</color>
<icon>images/change-rejected.png</icon>
</item>
<item id="closed">
<rank>3</rank>
<color>HIGHLIGHT_CLASS_NONE</color>
<icon>images/change-closed.png</icon>
</item>
</highlight_scale>
<attribute>status</attribute>
<stimuli>
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
@@ -340,6 +357,9 @@
</transitions>
</state>
<state id="rejected">
<highlight>
<code>rejected</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -415,6 +435,9 @@
</transitions>
</state>
<state id="approved">
<highlight>
<code>approved</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -490,6 +513,9 @@
</transitions>
</state>
<state id="closed">
<highlight>
<code>closed</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -633,63 +659,6 @@
$this->Set('last_update', time());
}]]></code>
</method>
<method id="GetIcon">
<comment>/**&#13;
* Get the icon representing this object&#13;
* @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)&#13;
* @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file&#13;
*/</comment>
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public function GetIcon($bImgTag = true)
{
$sStatus = $this->Get('status');
switch($this->GetState())
{
case 'approved':
case 'implemented':
case 'monitored':
$sIcon = self::MakeIconFromName('change-approved.png');
break;
case 'rejected':
case 'notapproved':
$sIcon = self::MakeIconFromName('change-rejected.png');
break;
case 'closed':
$sIcon = self::MakeIconFromName('change-closed.png');
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
return $sIcon;
}]]></code>
</method>
<method id="MakeIconFromName">
<static>true</static>
<access>protected</access>
<type>Overload-DBObject</type>
<code><![CDATA[ protected static function MakeIconFromName($sIconName, $bImgTag = true)
{
$sIcon = '';
if ($sIconName != '')
{
$sPath = '../env-'.utils::GetCurrentEnvironment().'/itop-change-mgmt/images/'.$sIconName;
if ($bImgTag)
{
$sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
}
else
{
$sIcon = $sPath;
}
}
return $sIcon;
}]]></code>
</method>
</methods>
<presentation>
<details>