make sure that minute_increment is not zero (#2860)
This commit is contained in:
@@ -354,10 +354,10 @@ final class SystemConfigurationController extends AbstractController
|
|||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('timesheet.time_increment')
|
->setName('timesheet.time_increment')
|
||||||
->setType(MinuteIncrementType::class)
|
->setType(MinuteIncrementType::class)
|
||||||
->setOptions(['deactivate' => false])
|
->setOptions(['deactivate' => false, 'max_one_hour' => true])
|
||||||
->setTranslationDomain('system-configuration')
|
->setTranslationDomain('system-configuration')
|
||||||
->setConstraints([
|
->setConstraints([
|
||||||
new GreaterThanOrEqual(['value' => 1])
|
new Range(['min' => 1, 'max' => 60])
|
||||||
]),
|
]),
|
||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('timesheet.duration_increment')
|
->setName('timesheet.duration_increment')
|
||||||
|
|||||||
@@ -55,13 +55,20 @@ class DateTimePickerType extends AbstractType
|
|||||||
|
|
||||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
{
|
{
|
||||||
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
$attr = array_merge($view->vars['attr'], [
|
||||||
'data-datetimepicker' => 'on',
|
'data-datetimepicker' => 'on',
|
||||||
'autocomplete' => 'off',
|
'autocomplete' => 'off',
|
||||||
'placeholder' => strtoupper($options['format']),
|
'placeholder' => strtoupper($options['format']),
|
||||||
'data-format' => $options['format_picker'],
|
'data-format' => $options['format_picker'],
|
||||||
'data-time-picker-increment' => $options['time_increment'],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($options['time_increment'] !== null) {
|
||||||
|
if ($options['time_increment'] >= 1) {
|
||||||
|
$attr['data-time-picker-increment'] = $options['time_increment'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->vars['attr'] = $attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class MinuteIncrementType extends AbstractType
|
|||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'deactivate' => true,
|
'deactivate' => true,
|
||||||
|
'max_one_hour' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$resolver->setDefault('choices', function (Options $options) {
|
$resolver->setDefault('choices', function (Options $options) {
|
||||||
@@ -47,8 +48,11 @@ class MinuteIncrementType extends AbstractType
|
|||||||
$choices['30'] = '30';
|
$choices['30'] = '30';
|
||||||
$choices['45'] = '45';
|
$choices['45'] = '45';
|
||||||
$choices['60'] = '60';
|
$choices['60'] = '60';
|
||||||
|
|
||||||
|
if (!$options['max_one_hour']) {
|
||||||
$choices['90'] = '90';
|
$choices['90'] = '90';
|
||||||
$choices['120'] = '120';
|
$choices['120'] = '120';
|
||||||
|
}
|
||||||
|
|
||||||
return $choices;
|
return $choices;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user