IcingaScheduledDowntimeForm: assignment elements

This commit is contained in:
Thomas Gelf 2018-06-15 12:06:18 +02:00
parent 2b8d2b4569
commit 6f790dd118
2 changed files with 45 additions and 0 deletions

View File

@ -49,6 +49,50 @@ class IcingaScheduledDowntimeForm extends DirectorObjectForm
'required' => ! $this->isTemplate(),
]);
$this->addAssignmentElements();
$this->setButtons();
}
/**
* @return $this
* @throws \Zend_Form_Exception
*/
protected function addAssignmentElements()
{
if ($this->isTemplate()) {
return $this;
}
$this->addElement('select', 'apply_to', [
'label' => $this->translate('Apply to'),
'description' => $this->translate(
'Whether this dependency should affect hosts or services'
),
'required' => true,
'class' => 'autosubmit',
'multiOptions' => $this->optionalEnum([
'host' => $this->translate('Hosts'),
'service' => $this->translate('Services'),
])
]);
$applyTo = $this->getSentOrObjectValue('apply_to');
if (! $applyTo) {
return $this;
}
$suggestionContext = ucfirst($applyTo) . 'FilterColumns';
$this->addAssignFilter([
'suggestionContext' => $suggestionContext,
'required' => true,
'description' => $this->translate(
'This allows you to configure an assignment filter. Please feel'
. ' free to combine as many nested operators as you want'
)
]);
return $this;
}
}

View File

@ -17,6 +17,7 @@ class IcingaScheduledDowntime extends IcingaObject
'comment' => null,
'fixed' => null,
'duration' => null,
'apply_to' => null,
'assign_filter' => null,
];