mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Prevent downtime flexible duration being set to 0h0m
This commit is contained in:
parent
d4958a4a6a
commit
4f7b56ade1
1 changed files with 25 additions and 7 deletions
|
|
@ -179,10 +179,22 @@ class ScheduleServiceDowntimeForm extends CommandForm
|
|||
'number',
|
||||
'hours',
|
||||
[
|
||||
'required' => true,
|
||||
'label' => t('Duration'),
|
||||
'value' => $this->flexibleDuration->h,
|
||||
'min' => 0
|
||||
'required' => true,
|
||||
'label' => t('Duration'),
|
||||
'value' => $this->flexibleDuration->h,
|
||||
'min' => 0,
|
||||
'validators' => [
|
||||
'Callback' => function ($value, $validator) {
|
||||
/** @var CallbackValidator $validator */
|
||||
|
||||
if ($this->getValue('minutes') == 0 && $value == 0) {
|
||||
$validator->addMessage(t('The duration must not be zero'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
]
|
||||
);
|
||||
$this->registerElement($hoursInput);
|
||||
|
|
@ -202,9 +214,15 @@ class ScheduleServiceDowntimeForm extends CommandForm
|
|||
new HtmlElement('label', null, new HtmlElement('span', null, Text::create(t('Minutes'))))
|
||||
);
|
||||
|
||||
$hoursInput->getWrapper()
|
||||
->add($minutesInput)
|
||||
->getAttributes()->add('class', 'downtime-duration');
|
||||
$hoursInput->getWrapper()->on(
|
||||
IcingaFormDecorator::ON_ASSEMBLED,
|
||||
function ($hoursInputWrapper) use ($minutesInput, $hoursInput) {
|
||||
$hoursInputWrapper
|
||||
->insertAfter($minutesInput, $hoursInput)
|
||||
->getAttributes()->add('class', 'downtime-duration');
|
||||
}
|
||||
);
|
||||
|
||||
$hoursInput->prependWrapper(
|
||||
new HtmlElement('label', null, new HtmlElement('span', null, Text::create(t('Hours'))))
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue