Skip to content

Commit

Permalink
EventRuleConfigForm: Fix zero condition escalation assignment for new…
Browse files Browse the repository at this point in the history
… event rule
  • Loading branch information
raviks789 committed May 14, 2024
1 parent 4bbe6f0 commit c81fd09
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions application/forms/EventRuleConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ protected function assemble(): void
]
);

$this->addElement('hidden', 'zero-condition-escalation');
$defaultEscalationPrefix = bin2hex('1');
$ruleId = $this->config['id'];

$this->addElement(
'hidden',
'zero-condition-escalation',
['value' => $ruleId === '-1' ? $defaultEscalationPrefix : null]
);

$configFilter = new EventRuleConfigFilter($this->searchEditorUrl, $this->config['object_filter']);
$this->registerElement($configFilter);

Expand All @@ -156,20 +162,14 @@ protected function assemble(): void
);

$this->registerElement($addEscalationButton);
$prefixesElement = $this->createElement('hidden', 'prefixes-map', ['value' => bin2hex('1')]);
$prefixesElement = $this->createElement('hidden', 'prefixes-map', ['value' => $defaultEscalationPrefix]);
$this->addElement($prefixesElement);
$this->handleAdd();

$prefixesMapString = $prefixesElement->getValue();
$prefixesMap = explode(',', $prefixesMapString);
$escalationCount = count($prefixesMap);
$zeroConditionEscalation = $this->getValue('zero-condition-escalation');

if ($ruleId === '-1' && $escalationCount === 1 && $zeroConditionEscalation === null) {
$zeroConditionEscalation = bin2hex('1');
$this->getElement('zero-condition-escalation')->setValue($zeroConditionEscalation);
}

$removePosition = null;
$removeEscalationButtons = [];

Expand Down

0 comments on commit c81fd09

Please sign in to comment.