N°985 - Add applicable contexts on Trigger (Add portal contexts)

This commit is contained in:
Eric
2020-01-24 17:43:59 +01:00
parent 5485897bbb
commit cc4e1ea104
5 changed files with 92 additions and 30 deletions

View File

@@ -10090,15 +10090,20 @@ class AttributeEnumSet extends AttributeSet
return array_merge(parent::ListExpectedParams(), array('possible_values', 'is_null_allowed', 'max_items'));
}
public function GetPossibleValues($aArgs = array(), $sContains = '')
private function GetRawValues($aArgs = array(), $sContains = '')
{
$oValSetDef = $this->Get('possible_values');
if (!$oValSetDef)
{
return null;
return array();
}
$aRawValues = $oValSetDef->GetValues($aArgs, $sContains);
return $oValSetDef->GetValues($aArgs, $sContains);
}
public function GetPossibleValues($aArgs = array(), $sContains = '')
{
$aRawValues = $this->GetRawValues($aArgs, $sContains);
$aLocalizedValues = array();
foreach($aRawValues as $sKey => $sValue)
{
@@ -10110,6 +10115,12 @@ class AttributeEnumSet extends AttributeSet
public function GetValueLabel($sValue)
{
$aValues = $this->GetRawValues();
if (isset($aValues[$sValue]))
{
$sValue = $aValues[$sValue];
}
if (is_null($sValue))
{
// Unless a specific label is defined for the null value of this enum, use a generic "undefined" label
@@ -10193,6 +10204,37 @@ class AttributeEnumSet extends AttributeSet
}
class AttributeContextSet extends AttributeEnumSet
{
public function GetPossibleValues($aArgs = array(), $sContains = '')
{
$oValSetDef = $this->Get('possible_values');
if (!$oValSetDef)
{
return null;
}
return $oValSetDef->GetValues($aArgs, $sContains);
}
public function GetValueLabel($sValue)
{
$aValues = $this->GetPossibleValues();
if (in_array($sValue, $aValues))
{
return $aValues[$sValue];
}
return Dict::S('Enum:Undefined');
}
public function GetValueDescription($sValue)
{
return '';
}
}
class AttributeClassAttCodeSet extends AttributeSet
{
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;

View File

@@ -91,12 +91,37 @@ class ContextTag
*/
public static function GetTags()
{
return array(
$aRawTags = array(
ContextTag::TAG_REST,
ContextTag::TAG_SYNCHRO,
ContextTag::TAG_SETUP,
ContextTag::TAG_CONSOLE,
ContextTag::TAG_CRON,
ContextTag::TAG_PORTAL);
$aTags = array();
foreach ($aRawTags as $sRawTag)
{
$aTags[$sRawTag] = Dict::S("Core:Context={$sRawTag}");
}
$aPortalsConf = PortalDispatcherData::GetData();
$aDispatchers = array();
foreach ($aPortalsConf as $sPortalId => $aConf)
{
$sHandlerClass = $aConf['handler'];
$aDispatchers[$sPortalId] = new $sHandlerClass($sPortalId);
}
foreach ($aDispatchers as $sPortalId => $oDispatcher)
{
if ($sPortalId != 'backoffice')
{
$aTags['Portal:'.$sPortalId] = $oDispatcher->GetLabel();
}
}
return $aTags;
}
}

View File

@@ -57,8 +57,7 @@ abstract class Trigger extends cmdbAbstractObject
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values" => null, "sql" => "description", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
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" => null, "possible_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($aTags), "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

View File

@@ -203,6 +203,13 @@ Operators:<br/>
'Core:AttributeTag' => 'Tags',
'Core:AttributeTag+' => 'Tags',
'Core:Context=REST/JSON' => 'REST',
'Core:Context=Synchro' => 'Synchro',
'Core:Context=Setup' => 'Setup',
'Core:Context=GUI:Console' => 'Console',
'Core:Context=CRON' => 'CRON',
'Core:Context=GUI:Portal' => 'Portal',
));
@@ -535,18 +542,6 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:Trigger/Attribute:action_list+' => 'Actions performed when the trigger is activated',
'Class:Trigger/Attribute:finalclass' => 'Trigger sub-class',
'Class:Trigger/Attribute:finalclass+' => 'Name of the final class',
'Class:Trigger/Attribute:context/Value:REST/JSON' => 'REST',
'Class:Trigger/Attribute:context/Value:REST/JSON+' => 'REST/JSON',
'Class:Trigger/Attribute:context/Value:Synchro' => 'Synchro',
'Class:Trigger/Attribute:context/Value:Synchro+' => 'Synchro',
'Class:Trigger/Attribute:context/Value:Setup' => 'Setup',
'Class:Trigger/Attribute:context/Value:Setup+' => 'Setup',
'Class:Trigger/Attribute:context/Value:GUI:Console' => 'Console',
'Class:Trigger/Attribute:context/Value:GUI:Console+' => 'GUI:Console',
'Class:Trigger/Attribute:context/Value:CRON' => 'CRON',
'Class:Trigger/Attribute:context/Value:CRON+' => 'CRON',
'Class:Trigger/Attribute:context/Value:GUI:Portal' => 'Portal',
'Class:Trigger/Attribute:context/Value:GUI:Portal+' => 'GUI:Portal',
));
//

View File

@@ -201,6 +201,19 @@ Opérateurs :<br/>
'Core:AttributeTag' => 'Taxon',
'Core:AttributeTag+' => 'Taxon',
'Core:Context=REST/JSON' => 'REST',
'Core:Context=REST/JSON+' => 'REST/JSON',
'Core:Context=Synchro' => 'Synchro',
'Core:Context=Synchro+' => 'Synchro',
'Core:Context=Setup' => 'Setup',
'Core:Context=Setup+' => 'Setup',
'Core:Context=GUI:Console' => 'Console',
'Core:Context=GUI:Console+' => 'GUI:Console',
'Core:Context=CRON' => 'CRON',
'Core:Context=CRON+' => 'CRON',
'Core:Context=GUI:Portal' => 'Portal',
'Core:Context=GUI:Portal+' => 'GUI:Portal',
));
@@ -533,18 +546,6 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:Trigger/Attribute:action_list+' => '',
'Class:Trigger/Attribute:finalclass' => 'Sous-classe de Déclencheur',
'Class:Trigger/Attribute:finalclass+' => 'Nom de la classe instanciable',
'Class:Trigger/Attribute:context/Value:REST/JSON' => 'REST',
'Class:Trigger/Attribute:context/Value:REST/JSON+' => 'REST/JSON',
'Class:Trigger/Attribute:context/Value:Synchro' => 'Synchro',
'Class:Trigger/Attribute:context/Value:Synchro+' => 'Synchro',
'Class:Trigger/Attribute:context/Value:Setup' => 'Setup',
'Class:Trigger/Attribute:context/Value:Setup+' => 'Setup',
'Class:Trigger/Attribute:context/Value:GUI:Console' => 'Console',
'Class:Trigger/Attribute:context/Value:GUI:Console+' => 'GUI:Console',
'Class:Trigger/Attribute:context/Value:CRON' => 'CRON',
'Class:Trigger/Attribute:context/Value:CRON+' => 'CRON',
'Class:Trigger/Attribute:context/Value:GUI:Portal' => 'Portal',
'Class:Trigger/Attribute:context/Value:GUI:Portal+' => 'GUI:Portal',
));
//