diff --git a/application/utils.inc.php b/application/utils.inc.php
index e8a70e88b..204e6b5af 100644
--- a/application/utils.inc.php
+++ b/application/utils.inc.php
@@ -1480,7 +1480,7 @@ class utils
*/
public static function GetSafeId($sId)
{
- return str_replace(array(':', '[', ']', '+', '-'), '_', $sId);
+ return str_replace(array(':', '[', ']', '+', '-', ' '), '_', $sId);
}
/**
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index 779dd585b..fac45c133 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -5182,9 +5182,9 @@ class AttributeEnum extends AttributeString
/**
* @param string|null $sValue
*
- * @return \ormStyle
+ * @return \ormStyle|null
*/
- protected function GetStyle(?string $sValue): ormStyle
+ protected function GetStyle(?string $sValue): ?ormStyle
{
if ($this->IsParam('styled_values')) {
$aStyles = $this->Get('styled_values');
@@ -5193,7 +5193,11 @@ class AttributeEnum extends AttributeString
}
}
- return new ormStyle();
+ if ($this->IsParam('default_style')) {
+ return $this->Get('default_style');
+ }
+
+ return null;
}
protected function GetSQLCol($bFullSpec = false)
diff --git a/core/ormStyle.class.inc.php b/core/ormStyle.class.inc.php
index 6f4916162..187db199e 100644
--- a/core/ormStyle.class.inc.php
+++ b/core/ormStyle.class.inc.php
@@ -11,6 +11,10 @@ class ormStyle
protected $sMainColor;
/** @var string */
protected $sComplementaryColor;
+ /** @var string CSS class with color and background-color */
+ protected $sStyleClass;
+ /** @var string CSS class with only color */
+ protected $sAltStyleClass;
/** @var string */
protected $sDecorationClasses;
/** @var string */
@@ -19,15 +23,19 @@ class ormStyle
/**
* ormStyle constructor.
*
+ * @param string $sStyleClass
+ * @param string $sAltStyleClass
* @param string $sMainColor
* @param string $sComplementaryColor
* @param string $sDecorationClasses
* @param string $sIcon
*/
- public function __construct(string $sMainColor = '#2B6CB0', string $sComplementaryColor = '#FFFFFF', string $sDecorationClasses = '', string $sIcon = '')
+ public function __construct(string $sStyleClass = '', string $sAltStyleClass = '', string $sMainColor = '#2B6CB0', string $sComplementaryColor = '#FFFFFF', string $sDecorationClasses = '', string $sIcon = '')
{
$this->sMainColor = $sMainColor;
$this->sComplementaryColor = $sComplementaryColor;
+ $this->sStyleClass = $sStyleClass;
+ $this->sAltStyleClass = $sAltStyleClass;
$this->sDecorationClasses = $sDecorationClasses;
$this->sIcon = $sIcon;
}
@@ -43,9 +51,9 @@ class ormStyle
/**
* @param string $sMainColor
*
- * @return ormStyle
+ * @return $this
*/
- public function SetMainColor(string $sMainColor): ormStyle
+ public function SetMainColor(string $sMainColor)
{
$this->sMainColor = $sMainColor;
return $this;
@@ -62,14 +70,52 @@ class ormStyle
/**
* @param string $sComplementaryColor
*
- * @return ormStyle
+ * @return $this
*/
- public function SetComplementaryColor(string $sComplementaryColor): ormStyle
+ public function SetComplementaryColor(string $sComplementaryColor)
{
$this->sComplementaryColor = $sComplementaryColor;
return $this;
}
+ /**
+ * @return string
+ */
+ public function GetStyleClass(): string
+ {
+ return $this->sStyleClass;
+ }
+
+ /**
+ * @param string $sStyleClass
+ *
+ * @return $this
+ */
+ public function SetStyleClass(string $sStyleClass)
+ {
+ $this->sStyleClass = $sStyleClass;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function GetAltStyleClass(): string
+ {
+ return $this->sAltStyleClass;
+ }
+
+ /**
+ * @param string $sAltStyleClass
+ *
+ * @return $this
+ */
+ public function SetAltStyleClass(string $sAltStyleClass)
+ {
+ $this->sAltStyleClass = $sAltStyleClass;
+ return $this;
+ }
+
/**
* @return string
*/
@@ -81,9 +127,9 @@ class ormStyle
/**
* @param string $sDecorationClasses
*
- * @return ormStyle
+ * @return $this
*/
- public function SetDecorationClasses(string $sDecorationClasses): ormStyle
+ public function SetDecorationClasses(string $sDecorationClasses)
{
$this->sDecorationClasses = $sDecorationClasses;
return $this;
@@ -100,9 +146,9 @@ class ormStyle
/**
* @param string $sIcon
*
- * @return ormStyle
+ * @return $this
*/
- public function SetIcon(string $sIcon): ormStyle
+ public function SetIcon(string $sIcon)
{
$this->sIcon = $sIcon;
return $this;
diff --git a/datamodels/2.x/itop-bridge-cmdb-ticket/datamodel.itop-bridge-cmdb-ticket.xml b/datamodels/2.x/itop-bridge-cmdb-ticket/datamodel.itop-bridge-cmdb-ticket.xml
index 35472c072..6f48edc1a 100644
--- a/datamodels/2.x/itop-bridge-cmdb-ticket/datamodel.itop-bridge-cmdb-ticket.xml
+++ b/datamodels/2.x/itop-bridge-cmdb-ticket/datamodel.itop-bridge-cmdb-ticket.xml
@@ -60,27 +60,12 @@
manual
-
computed
-
not_impacted
-
impact_code
diff --git a/datamodels/2.x/itop-change-mgmt-itil/datamodel.itop-change-mgmt-itil.xml b/datamodels/2.x/itop-change-mgmt-itil/datamodel.itop-change-mgmt-itil.xml
index 48ba19854..6d5b495d7 100755
--- a/datamodels/2.x/itop-change-mgmt-itil/datamodel.itop-change-mgmt-itil.xml
+++ b/datamodels/2.x/itop-change-mgmt-itil/datamodel.itop-change-mgmt-itil.xml
@@ -43,15 +43,15 @@
approved
approved
assigned
assigned
@@ -59,31 +59,21 @@
closed
implemented
-
monitored
-
new
@@ -91,36 +81,41 @@
notapproved
plannedscheduled
rejected
validated
+
+ #2B6CB0
+ #FFFFFF
+
+
status
new
true
@@ -218,19 +213,9 @@
yes
-
no
-
outage
@@ -243,7 +228,9 @@
true
- id]]>
+ id
+ ]]>
parent_id
Change
true
diff --git a/datamodels/2.x/itop-change-mgmt/datamodel.itop-change-mgmt.xml b/datamodels/2.x/itop-change-mgmt/datamodel.itop-change-mgmt.xml
index e7cfc1e56..9c14e9735 100755
--- a/datamodels/2.x/itop-change-mgmt/datamodel.itop-change-mgmt.xml
+++ b/datamodels/2.x/itop-change-mgmt/datamodel.itop-change-mgmt.xml
@@ -42,7 +42,7 @@
new
@@ -50,44 +50,44 @@
assigned
planned
-
approved
closed
rejected
+
+ #2B6CB0
+ #FFFFFF
+
+
status
new
true
@@ -96,51 +96,21 @@
hardware
-
software
-
system
-
network
-
application
-
other
-
category
@@ -194,19 +164,9 @@
yes
-
no
-
outage
diff --git a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml
index 616cf23a1..09f705a3e 100755
--- a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml
+++ b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml
@@ -50,27 +50,12 @@
high
-
medium
-
low
-
business_criticity
@@ -321,35 +306,15 @@
production
-
implementation
-
stock
-
obsolete
-
status
@@ -1605,7 +1570,7 @@
active
@@ -1613,8 +1578,8 @@
inactive
@@ -1755,7 +1720,7 @@
active
@@ -1763,8 +1728,8 @@
inactive
@@ -1921,7 +1886,7 @@
active
@@ -1929,8 +1894,8 @@
inactive
@@ -3037,43 +3002,18 @@
Middleware
-
DBServer
-
PCSoftware
-
OtherSoftware
-
WebServer
-
type
@@ -3518,19 +3458,9 @@
yes
-
no
-
perpetual
@@ -4206,147 +4136,57 @@
NetworkDevice
-
Server
-
SANSwitch
-
StorageSystem
-
Rack
-
Enclosure
-
PC
-
Tablet
-
Phone
-
MobilePhone
-
Printer
-
DiskArray
-
NAS
-
TapeLibrary
-
IPPhone
-
Peripheral
-
PowerSource
-
PDU
-
type
@@ -5879,19 +5719,9 @@
uplink
-
downlink
-
type
@@ -6289,27 +6119,12 @@
production
-
implementation
-
obsolete
-
status
diff --git a/datamodels/2.x/itop-endusers-devices/datamodel.itop-enduser-devices.xml b/datamodels/2.x/itop-endusers-devices/datamodel.itop-enduser-devices.xml
index f2ec9371f..a486e0535 100644
--- a/datamodels/2.x/itop-endusers-devices/datamodel.itop-enduser-devices.xml
+++ b/datamodels/2.x/itop-endusers-devices/datamodel.itop-enduser-devices.xml
@@ -839,19 +839,9 @@
laptop
-
desktop
-
type
diff --git a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml
index bc08aa80d..baf797e16 100755
--- a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml
+++ b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml
@@ -43,7 +43,7 @@
new
@@ -51,7 +51,7 @@
assigned
@@ -59,44 +59,49 @@
pending
escalated_tto
escalated_ttr
resolved
closed
+
+ #2B6CB0
+ #FFFFFF
+
+
status
new
false
@@ -106,27 +111,12 @@
1
-
2
-
3
-
impact
@@ -138,35 +128,15 @@
1
-
2
-
3
-
4
-
@@ -181,35 +151,15 @@
1
-
2
-
3
-
4
-
urgency
@@ -220,35 +170,15 @@
mail
-
phone
-
portal
-
monitoring
-
origin
@@ -257,7 +187,11 @@
list
- org_id AND s.status != 'obsolete']]>
+ org_id AND s.status != 'obsolete'
+ ]]>
@@ -290,19 +224,9 @@
yes
-
no
-
escalation_flag
@@ -439,32 +363,25 @@
assistance
-
other
-
- software patch
+
+ software patch
+
training
-
- hardware repair
- system update
- bug fixed
+
+ hardware repair
+
+
+ system update
+
+
+ bug fixed
+
resolution_code
assistance
@@ -536,35 +453,15 @@
1
-
2
-
3
-
4
-
user_satisfaction
diff --git a/datamodels/2.x/itop-knownerror-light/datamodel.itop-knownerror-light.xml b/datamodels/2.x/itop-knownerror-light/datamodel.itop-knownerror-light.xml
index 493c57b6b..a59719723 100755
--- a/datamodels/2.x/itop-knownerror-light/datamodel.itop-knownerror-light.xml
+++ b/datamodels/2.x/itop-knownerror-light/datamodel.itop-knownerror-light.xml
@@ -81,35 +81,15 @@
Network
-
Server
-
Application
-
Desktop
-
domain
diff --git a/datamodels/2.x/itop-problem-mgmt/datamodel.itop-problem-mgmt.xml b/datamodels/2.x/itop-problem-mgmt/datamodel.itop-problem-mgmt.xml
index e055b6d72..36e2050a2 100755
--- a/datamodels/2.x/itop-problem-mgmt/datamodel.itop-problem-mgmt.xml
+++ b/datamodels/2.x/itop-problem-mgmt/datamodel.itop-problem-mgmt.xml
@@ -42,7 +42,7 @@
new
@@ -50,7 +50,7 @@
assigned
@@ -58,20 +58,25 @@
resolved
closed
+
+ #2B6CB0
+ #FFFFFF
+
+
status
new
false
@@ -116,27 +121,12 @@
1
-
2
-
3
-
impact
@@ -148,35 +138,15 @@
1
-
2
-
3
-
4
-
urgency
@@ -188,35 +158,15 @@
1
-
2
-
3
-
4
-
priority
diff --git a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml
index 83611ce23..e5a22862d 100755
--- a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml
+++ b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml
@@ -43,7 +43,7 @@
new
@@ -51,31 +51,31 @@
waiting_for_approval
approved
rejected
assigned
@@ -83,44 +83,49 @@
pending
escalated_tto
escalated_ttr
resolved
closed
+
+ #2B6CB0
+ #FFFFFF
+
+
status
new
false
@@ -129,11 +134,6 @@
service_request
-
request_type
@@ -145,27 +145,12 @@
1
-
2
-
3
-
impact
@@ -177,35 +162,15 @@
1
-
2
-
3
-
4
-
@@ -220,35 +185,15 @@
1
-
2
-
3
-
4
-
urgency
@@ -259,27 +204,12 @@
mail
-
phone
-
portal
-
origin
@@ -287,7 +217,9 @@
true
- org_id]]>
+ org_id
+ ]]>
@@ -337,19 +269,9 @@
yes
-
no
-
escalation_flag
@@ -488,28 +410,13 @@
assistance
-
other
-
software patch
training
-
hardware repair
system update
@@ -590,35 +497,15 @@
1
-
2
-
3
-
4
-
user_satisfaction
diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml
index 3db140680..cf18574d0 100755
--- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml
+++ b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml
@@ -129,19 +129,9 @@
incident
-
service_request
-
request_type
@@ -153,27 +143,12 @@
1
-
2
-
3
-
impact
@@ -186,15 +161,15 @@
1
2
@@ -202,7 +177,7 @@
3
@@ -210,12 +185,17 @@
4
+
+ #2B6CB0
+ #FFFFFF
+
+
@@ -228,35 +208,15 @@
1
-
2
-
3
-
4
-
urgency
@@ -267,35 +227,15 @@
mail
-
phone
-
portal
-
monitoring
-
origin
@@ -360,19 +300,9 @@
yes
-
no
-
escalation_flag
@@ -510,59 +440,24 @@
assistance
-
other
-
software patch
-
training
-
hardware repair
-
system update
-
bug fixed
-
resolution_code
@@ -636,35 +531,15 @@
1
-
2
-
3
-
4
-
user_satisfaction
diff --git a/datamodels/2.x/itop-service-mgmt-provider/datamodel.itop-service-mgmt-provider.xml b/datamodels/2.x/itop-service-mgmt-provider/datamodel.itop-service-mgmt-provider.xml
index de2704e7b..3f93d882d 100755
--- a/datamodels/2.x/itop-service-mgmt-provider/datamodel.itop-service-mgmt-provider.xml
+++ b/datamodels/2.x/itop-service-mgmt-provider/datamodel.itop-service-mgmt-provider.xml
@@ -131,19 +131,9 @@
dollars
-
euros
-
cost_currency
@@ -185,27 +175,12 @@
production
-
implementation
-
obsolete
-
status
@@ -1091,27 +1066,12 @@ public function PrefillSearchForm(&$aContextParam)
production
-
implementation
-
obsolete
-
status
@@ -1447,19 +1407,9 @@ public function PrefillSearchForm(&$aContextParam)
incident
-
service_request
-
request_type
@@ -1471,27 +1421,12 @@ public function PrefillSearchForm(&$aContextParam)
production
-
implementation
-
obsolete
-
status
@@ -1750,35 +1685,15 @@ public function PrefillSearchForm(&$aContextParam)
1
-
2
-
3
-
4
-
priority
@@ -1790,19 +1705,9 @@ public function PrefillSearchForm(&$aContextParam)
service_request
-
incident
-
request_type
@@ -1814,19 +1719,9 @@ public function PrefillSearchForm(&$aContextParam)
tto
-
ttr
-
metric
@@ -1843,19 +1738,9 @@ public function PrefillSearchForm(&$aContextParam)
hours
-
minutes
-
unit
diff --git a/datamodels/2.x/itop-service-mgmt/datamodel.itop-service-mgmt.xml b/datamodels/2.x/itop-service-mgmt/datamodel.itop-service-mgmt.xml
index 2a28370e5..26694e584 100755
--- a/datamodels/2.x/itop-service-mgmt/datamodel.itop-service-mgmt.xml
+++ b/datamodels/2.x/itop-service-mgmt/datamodel.itop-service-mgmt.xml
@@ -131,19 +131,9 @@
dollars
-
euros
-
cost_currency
@@ -185,27 +175,12 @@
production
-
implementation
-
obsolete
-
status
@@ -1063,27 +1038,12 @@ public function PrefillSearchForm(&$aContextParam)
production
-
implementation
-
obsolete
-
status
@@ -1441,19 +1401,9 @@ public function PrefillSearchForm(&$aContextParam)
incident
-
service_request
-
request_type
@@ -1465,27 +1415,12 @@ public function PrefillSearchForm(&$aContextParam)
production
-
implementation
-
obsolete
-
status
@@ -1744,35 +1679,15 @@ public function PrefillSearchForm(&$aContextParam)
1
-
2
-
3
-
4
-
priority
@@ -1784,19 +1699,9 @@ public function PrefillSearchForm(&$aContextParam)
service_request
-
incident
-
request_type
@@ -1808,19 +1713,9 @@ public function PrefillSearchForm(&$aContextParam)
tto
-
ttr
-
metric
@@ -1837,19 +1732,9 @@ public function PrefillSearchForm(&$aContextParam)
hours
-
minutes
-
unit
diff --git a/datamodels/2.x/itop-structure/datamodel.itop-structure.xml b/datamodels/2.x/itop-structure/datamodel.itop-structure.xml
index c0a5e65e0..b8cf14df9 100644
--- a/datamodels/2.x/itop-structure/datamodel.itop-structure.xml
+++ b/datamodels/2.x/itop-structure/datamodel.itop-structure.xml
@@ -51,7 +51,7 @@
active
@@ -59,8 +59,8 @@
inactive
@@ -224,7 +224,7 @@
active
@@ -232,8 +232,8 @@
inactive
@@ -409,7 +409,7 @@
active
@@ -417,8 +417,8 @@
inactive
@@ -452,19 +452,9 @@
yes
-
no
-
notify
@@ -1220,27 +1210,12 @@
draft
-
published
-
obsolete
-
status
diff --git a/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml b/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml
index 8c40f650e..dc9df8816 100755
--- a/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml
+++ b/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml
@@ -55,29 +55,29 @@
ongoing
-
resolved
closed
+
+ #2B6CB0
+ #FFFFFF
+
+
operational_status
ongoing
@@ -431,27 +431,12 @@
manual
-
computed
-
do_not_notify
-
impact_code
@@ -538,19 +523,9 @@
open
-
closed
-
status
diff --git a/datamodels/2.x/itop-virtualization-mgmt/datamodel.itop-virtualization-mgmt.xml b/datamodels/2.x/itop-virtualization-mgmt/datamodel.itop-virtualization-mgmt.xml
index 0c1977131..6487b9f04 100644
--- a/datamodels/2.x/itop-virtualization-mgmt/datamodel.itop-virtualization-mgmt.xml
+++ b/datamodels/2.x/itop-virtualization-mgmt/datamodel.itop-virtualization-mgmt.xml
@@ -36,35 +36,15 @@
production
-
implementation
-
stock
-
obsolete
-
status
diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php
index 3d3e31c49..79343d139 100644
--- a/setup/compiler.class.inc.php
+++ b/setup/compiler.class.inc.php
@@ -312,6 +312,10 @@ class MFCompiler
}
}
+
+ /** array of strings containing dynamic CSS class definitions */
+ $aClassesCss = [];
+
$oClasses = $this->oFactory->ListClasses($sModuleName);
$iClassCount = $oClasses->length;
if ($iClassCount == 0)
@@ -327,7 +331,7 @@ class MFCompiler
$aAllClasses[] = $sClass;
try
{
- $sCompiledCode .= $this->CompileClass($oClass, $sTempTargetDir, $sFinalTargetDir, $sRelativeDir);
+ $sCompiledCode .= $this->CompileClass($oClass, $sTempTargetDir, $sFinalTargetDir, $sRelativeDir, $aClassesCss);
}
catch (DOMFormatException $e)
{
@@ -982,15 +986,17 @@ EOF
* @param string $sTempTargetDir
* @param string $sFinalTargetDir
* @param string $sModuleRelativeDir
+ * @param array $aClassesCss Contains dynamic CSS class definitions
*
* @return string
* @throws \DOMFormatException
*/
- protected function CompileClass($oClass, $sTempTargetDir, $sFinalTargetDir, $sModuleRelativeDir)
+ protected function CompileClass($oClass, $sTempTargetDir, $sFinalTargetDir, $sModuleRelativeDir, &$aClassesCss)
{
$sClass = $oClass->getAttribute('id');
$oProperties = $oClass->GetUniqueElement('properties');
$sPHP = '';
+ $sCss = ''; // Contains dynamic CSS class definitions
// Class caracteristics
//
@@ -1353,15 +1359,47 @@ EOF
$oStyleNode = $oValue->GetOptionalElement('style');
if ($oStyleNode) {
$sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
+ $sSafeCode = utils::GetSafeId($sCode);
+ $sEnumClass = "ibo-enum--$sClass-$sAttCode-$sSafeCode";
+ $sEnumClassAlt = "ibo-enum-alt--$sClass-$sAttCode-$sSafeCode";
$sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
$sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
- $aStyledValues[] = "'$sCode' => new ormStyle($sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $aStyledValues[] = "'$sCode' => new ormStyle('$sEnumClass', '$sEnumClassAlt', $sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $sCss .= <<GetOptionalElement('default_style');
+ if ($oStyleNode) {
+ $sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
+ $sEnumClass = "ibo-enum--$sClass-$sAttCode";
+ $sEnumClassAlt = "ibo-enum-alt--$sClass-$sAttCode";
+ $sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
+ $sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
+ $aParameters['default_style'] = "new ormStyle('$sEnumClass', '$sEnumClassAlt', $sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $sCss .= <<GetPropString($oField, 'display_style', 'list');
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['default_value'] = $this->GetPropString($oField, 'default_value', '');
@@ -1382,15 +1420,47 @@ EOF
$oStyleNode = $oValue->GetOptionalElement('style');
if ($oStyleNode) {
$sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
+ $sSafeCode = utils::GetSafeId($sCode);
+ $sEnumClass = "ibo-enum--$sClass-$sAttCode-$sSafeCode";
+ $sEnumClassAlt = "ibo-enum-alt--$sClass-$sAttCode-$sSafeCode";
$sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
$sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
- $aStyledValues[] = "'$sCode' => new ormStyle($sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $aStyledValues[] = "'$sCode' => new ormStyle('$sEnumClass', '$sEnumClassAlt', $sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $sCss .= <<GetOptionalElement('default_style');
+ if ($oStyleNode) {
+ $sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
+ $sEnumClass = "ibo-enum--$sClass-$sAttCode";
+ $sEnumClassAlt = "ibo-enum-alt--$sClass-$sAttCode";
+ $sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
+ $sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
+ $aParameters['default_style'] = "new ormStyle('$sEnumClass', '$sEnumClassAlt', $sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $sCss .= <<GetMandatoryPropString($oField, 'sql');
$aParameters['default_value'] = $this->GetPropString($oField, 'default_value', '');
@@ -2104,6 +2174,8 @@ EOF
}
}
+ $aClassesCss[] = $sCss;
+
return $sPHP;
}
@@ -2801,6 +2873,7 @@ EOF;
copy($sPrecompiledFile, $sThemeDir.'/main.css');
// Make sure that the copy of the precompiled file is older than any other files to force a validation of the signature
touch($sThemeDir.'/main.css', 1577836800 /* 2020-01-01 00:00:00 */);
+
}
else if ($sPrecompiledFile != '')
{
diff --git a/setup/itopdesignformat.class.inc.php b/setup/itopdesignformat.class.inc.php
index d8647d559..7a53a072b 100644
--- a/setup/itopdesignformat.class.inc.php
+++ b/setup/itopdesignformat.class.inc.php
@@ -800,24 +800,20 @@ class iTopDesignFormat
// New Enum values format
$oNodeList = $oXPath->query("/itop_design/classes//class/fields/field[@xsi:type='AttributeEnum']/values/value");
- foreach ($oNodeList as $oNode)
- {
+ foreach ($oNodeList as $oNode) {
$oNode->textContent = '';
$oCodeNode = $oNode->ownerDocument->createElement("enum_code", $oNode->textContent);
$oNode->appendChild($oCodeNode);
+ }
- $oStyleNode = $oNode->ownerDocument->createElement("style");
- $oNode->appendChild($oStyleNode);
+ // MetaEnum
+ $oNodeList = $oXPath->query("/itop_design/classes//class/fields/field[@xsi:type='AttributeMetaEnum']/values/value");
+ foreach ($oNodeList as $oNode) {
+ $oNode->textContent = '';
- $oMainColorNode = $oNode->ownerDocument->createElement("main_color", "#2B6CB0");
- $oStyleNode->appendChild($oMainColorNode);
-
- $oComplementaryColorNode = $oNode->ownerDocument->createElement("complementary_color", "#FFFFFF");
- $oStyleNode->appendChild($oComplementaryColorNode);
-
- $oDecorationClassesNode = $oNode->ownerDocument->createElement("decoration_classes");
- $oStyleNode->appendChild($oDecorationClassesNode);
+ $oCodeNode = $oNode->ownerDocument->createElement("enum_code", $oNode->textContent);
+ $oNode->appendChild($oCodeNode);
}
}
@@ -865,8 +861,7 @@ class iTopDesignFormat
// New Enum values format
$oNodeList = $oXPath->query("/itop_design/classes//class/fields/field[@xsi:type='AttributeEnum']/values/value");
- foreach ($oNodeList as $oNode)
- {
+ foreach ($oNodeList as $oNode) {
$oCodeNode = $oXPath->query('enum_code', $oNode)->item(0);
$oNode->textContent = $oCodeNode->textContent;
$this->DeleteNode($oCodeNode);
@@ -874,6 +869,21 @@ class iTopDesignFormat
$this->DeleteNode($oStyleNode);
}
+ $sPath = "/itop_design/classes//class/fields/field[@xsi:type='AttributeEnum']/default_style";
+ $this->RemoveNodeFromXPath($sPath);
+
+ // MetaEnum
+ $oNodeList = $oXPath->query("/itop_design/classes//class/fields/field[@xsi:type='AttributeMetaEnum']/values/value");
+ foreach ($oNodeList as $oNode) {
+ $oCodeNode = $oXPath->query('enum_code', $oNode)->item(0);
+ $oNode->textContent = $oCodeNode->textContent;
+ $this->DeleteNode($oCodeNode);
+ $oStyleNode = $oXPath->query('style', $oNode)->item(0);
+ $this->DeleteNode($oStyleNode);
+ }
+
+ $sPath = "/itop_design/classes//class/fields/field[@xsi:type='AttributeMetaEnum']/default_style";
+ $this->RemoveNodeFromXPath($sPath);
}
/**
diff --git a/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php b/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php
index 578791e39..a610f407e 100644
--- a/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php
+++ b/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php
@@ -21,6 +21,6 @@ class FieldBadge extends UIContentBlock
public function __construct(string $sName = null, string $sContainerClass = '')
{
- parent::__construct($sName, $sContainerClass.' ibo-field-badge');
+ parent::__construct($sName, $sContainerClass);
}
}
\ No newline at end of file
diff --git a/sources/application/UI/Base/Component/FieldBadge/FieldBadgeFactory.php b/sources/application/UI/Base/Component/FieldBadge/FieldBadgeFactory.php
index e28eb443d..ef467168e 100644
--- a/sources/application/UI/Base/Component/FieldBadge/FieldBadgeFactory.php
+++ b/sources/application/UI/Base/Component/FieldBadge/FieldBadgeFactory.php
@@ -14,31 +14,38 @@ class FieldBadgeFactory
{
/**
* @param string $sValue
- * @param \ormStyle $oStyle
+ * @param \ormStyle|null $oStyle
*
* @return \Combodo\iTop\Application\UI\Base\Component\FieldBadge\FieldBadge
*/
- public static function MakeForField(string $sValue, ormStyle $oStyle)
+ public static function MakeForField(string $sValue, ?ormStyle $oStyle)
{
- $sPrimaryColor = $oStyle->GetMainColor();
- $oBadge = new FieldBadge();
- $sId = $oBadge->GetId();
- $sComplementaryColor = $oStyle->GetComplementaryColor();
- $sDecorationClasses = $oStyle->GetDecorationClasses();
- if ($sDecorationClasses != '') {
- $oBadge->AddHtml(" ");
- }
- $oBadge->AddHtml("$sValue");
- // Add custom style
- $oBadge->AddHtml(<<GetStyleClass();
+ $sPrimaryColor = $oStyle->GetMainColor();
+ $oBadge = new FieldBadge(null, $sStyleClass.' ibo-field-badge');
+ $sComplementaryColor = $oStyle->GetComplementaryColor();
+ $sDecorationClasses = $oStyle->GetDecorationClasses();
+ if ($sDecorationClasses != '') {
+ $oBadge->AddHtml(" ");
+ }
+ $oBadge->AddHtml("$sValue");
+ // Add custom style
+ // TODO 3.0 To be removed when compilation supports generated CSS
+ $oBadge->AddHtml(<<
- #$sId {
+.$sStyleClass {
color: $sComplementaryColor;
background-color: $sPrimaryColor;
}
HTML
- );
+ );
+ } else {
+ $oBadge = new FieldBadge();
+ $oBadge->AddHtml("$sValue");
+ }
+
return $oBadge;
}
}
\ No newline at end of file