N°985 - Add applicable contexts on Trigger (fix MTP warnings)

This commit is contained in:
Eric
2020-01-21 12:01:42 +01:00
parent 083f8d69c2
commit beda8e2810
2 changed files with 27 additions and 5 deletions

View File

@@ -9694,6 +9694,21 @@ abstract class AttributeSet extends AttributeDBFieldVoid
return parent::GetAllowedValues($aArgs, $sContains);
}
/**
* Allowed different values for the set values are mandatory for this attribute to be modified
*
* @param array $aArgs
* @param string $sContains
*
* @return array|null
* @throws \CoreException
* @throws \OQLException
*/
public function GetPossibleValues($aArgs = array(), $sContains = '')
{
return $this->GetAllowedValues($aArgs, $sContains);
}
/**
* @param \ormSet $oValue
*
@@ -9708,7 +9723,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
$aJson = array();
// possible_values
$aAllowedValues = $this->GetAllowedValues($aArgs);
$aAllowedValues = $this->GetPossibleValues($aArgs);
$aSetKeyValData = array();
foreach($aAllowedValues as $sCode => $sLabel)
{
@@ -10054,13 +10069,20 @@ class AttributeEnumSet extends AttributeSet
{
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
public function GetAllowedValues($aArgs = array(), $sContains = '')
public static function ListExpectedParams()
{
$aRawValues = parent::GetAllowedValues($aArgs, $sContains);
if (is_null($aRawValues))
return array_merge(parent::ListExpectedParams(), array('possible_values', 'is_null_allowed', 'max_items'));
}
public function GetPossibleValues($aArgs = array(), $sContains = '')
{
$oValSetDef = $this->Get('possible_values');
if (!$oValSetDef)
{
return null;
}
$aRawValues = $oValSetDef->GetValues($aArgs, $sContains);
$aLocalizedValues = array();
foreach($aRawValues as $sKey => $sValue)
{

View File

@@ -58,7 +58,7 @@ abstract class Trigger extends cmdbAbstractObject
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("action_list", array("linked_class" => "lnkTriggerAction", "ext_key_to_me" => "trigger_id", "ext_key_to_remote" => "action_id", "allowed_values" => null, "count_min" => 1, "count_max" => 0, "depends_on" => array())));
$aTags = ContextTag::GetTags();
$sTags = implode(',', $aTags);
MetaModel::Init_AddAttribute( new AttributeEnumSet("context", array("allowed_values" => new ValueSetEnum($sTags), "sql" => "context", "depends_on" => array(), "is_null_allowed" => true, "max_items" => 12)));
MetaModel::Init_AddAttribute( new AttributeEnumSet("context", array("allowed_values" => null, "possible_values" => new ValueSetEnum($sTags), "sql" => "context", "depends_on" => array(), "is_null_allowed" => true, "max_items" => 12)));
// Display lists
MetaModel::Init_SetZListItems('details', array('finalclass', 'description', 'context', 'action_list')); // Attributes to be displayed for the complete details