Skip to content

Commit ec16494

Browse files
EscalationCondition: Remove not required incident age operators
Operators `<` and `<=` have no use case.
1 parent a4eca70 commit ec16494

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

application/forms/EventRuleConfigElements/EscalationCondition.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,26 @@ protected function assemble(): void
118118
)
119119
]));
120120

121-
$this->addElement('select', 'operator', [
122-
'required' => true,
123-
'options' => [
121+
$selectedColumn = $this->getPopulatedValue('column');
122+
if ($selectedColumn === 'incident_age') {
123+
$operators = ['>' => '>'];
124+
} else {
125+
$operators = [
124126
'=' => '=',
125127
'>' => '>',
126128
'>=' => '>=',
127129
'<' => '<',
128130
'<=' => '<=',
129131
'!=' => '!='
130-
]
132+
];
133+
}
134+
135+
$this->addElement('select', 'operator', [
136+
'required' => true,
137+
'options' => $operators
131138
]);
132139

133-
if ($this->getPopulatedValue('column') === 'incident_severity') {
140+
if ($selectedColumn === 'incident_severity') {
134141
$this->addElement('select', 'severity', [
135142
'required' => true,
136143
'options' => [
@@ -145,7 +152,7 @@ protected function assemble(): void
145152
'emerg' => $this->translate('Emergency', 'notification.severity')
146153
]
147154
]);
148-
} elseif ($this->getPopulatedValue('column') === 'incident_age') {
155+
} elseif ($selectedColumn === 'incident_age') {
149156
$noOf = $this->createElement('number', 'no_of', [
150157
'required' => true,
151158
'min' => 1,

test/php/application/forms/EventRuleConfigFormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function testLoadAndStorage(): void
132132
(new RuleEscalation())->setProperties([
133133
'id' => 1,
134134
'position' => 0,
135-
'condition' => 'incident_age>=5m',
135+
'condition' => 'incident_age>5m',
136136
'rule_escalation_recipient' => [
137137
(new RuleEscalationRecipient())->setProperties([
138138
'id' => 1,

0 commit comments

Comments
 (0)