improved duration and minute selector (#2264)

* do not close modal if form is dirty
* deprecated TimesheetConfiguration
* inject timezone in form types
* cleanup usage of UserDateTimeFactory
* allow to configure increment steps for minutes
* use 15 minutes step for datetimepicker in project edit form
* use rounding rules for increments in minute select for begin and end
* allow duration in multi user and admin timesheet forms
* make dropdown values configurable
This commit is contained in:
Kevin Papst
2021-01-17 14:04:13 +01:00
committed by GitHub
parent e2324b7d51
commit 8d72d114c7
95 changed files with 1381 additions and 510 deletions

View File

@@ -71,6 +71,7 @@ class CalendarControllerTest extends ControllerBaseTest
],
'timesheet' => [
'default_begin' => '08:30:00',
'mode' => 'default'
],
'calendar' => [
'businessHours' => [

View File

@@ -89,7 +89,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$configService = static::$kernel->getContainer()->get(SystemConfiguration::class);
$this->assertEquals('default', $configService->find('timesheet.mode'));
$this->assertEquals(true, $configService->find('timesheet.rules.allow_future_times'));
$this->assertTrue($configService->find('timesheet.rules.allow_future_times'));
$this->assertEquals(1, $configService->find('timesheet.active_entries.hard_limit'));
$this->assertEquals(1, $configService->find('timesheet.active_entries.soft_limit'));
@@ -117,8 +117,8 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$configService = static::$kernel->getContainer()->get(SystemConfiguration::class);
$this->assertEquals('duration_only', $configService->find('timesheet.mode'));
$this->assertEquals(false, $configService->find('timesheet.rules.allow_future_times'));
$this->assertEquals(false, $configService->find('timesheet.rules.allow_overlapping_records'));
$this->assertFalse($configService->find('timesheet.rules.allow_future_times'));
$this->assertFalse($configService->find('timesheet.rules.allow_overlapping_records'));
$this->assertEquals(99, $configService->find('timesheet.active_entries.hard_limit'));
$this->assertEquals(77, $configService->find('timesheet.active_entries.soft_limit'));
}
@@ -247,7 +247,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$this->assertAccessIsGranted($client, '/admin/system-config/');
$configService = static::$kernel->getContainer()->get(SystemConfiguration::class);
$this->assertEquals(false, $configService->find('timesheet.markdown_content'));
$this->assertFalse($configService->find('timesheet.markdown_content'));
$this->assertEquals('selectpicker', $configService->find('theme.select_type'));
$form = $client->getCrawler()->filter('form[name=system_configuration_form_theme]')->form();
@@ -267,7 +267,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$configService = static::$kernel->getContainer()->get(SystemConfiguration::class);
$this->assertEquals('selectpicker', $configService->find('theme.select_type'));
$this->assertEquals(true, $configService->find('timesheet.markdown_content'));
$this->assertTrue($configService->find('timesheet.markdown_content'));
}
public function testUpdateThemeConfigValidation()

View File

@@ -190,6 +190,64 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertNull($timesheet->getFixedRate());
}
/**
* @dataProvider getTestDataForDurationValues
*/
public function testCreateActionWithDurationValues($begin, $end, $duration, $expectedDuration, $expectedEnd)
{
$client = $this->getClientForAuthenticatedUser();
$this->request($client, '/timesheet/create');
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
$client->submit($form, [
'timesheet_edit_form' => [
'description' => 'Testing is fun!',
'begin' => $begin,
'end' => $end,
'duration' => $duration,
'project' => 1,
'activity' => 1,
]
]);
$this->assertIsRedirect($client, $this->createUrl('/timesheet/'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertHasFlashSuccess($client);
$em = $this->getEntityManager();
/** @var Timesheet $timesheet */
$timesheet = $em->getRepository(Timesheet::class)->find(1);
$this->assertInstanceOf(\DateTime::class, $timesheet->getBegin());
$this->assertInstanceOf(\DateTime::class, $timesheet->getEnd());
$this->assertEquals($expectedDuration, $timesheet->getDuration());
$this->assertEquals($expectedEnd, $timesheet->getEnd()->format('Y-m-d H:i:s'));
$this->assertEquals('Testing is fun!', $timesheet->getDescription());
}
public function getTestDataForDurationValues()
{
// duration is ignored, because end is set and the duration might come from a rounding rule (by default seconds are rounded down with 1)
yield ['2018-12-31 00:00:00', '2018-12-31 02:10:10', '01:00', 7800, '2018-12-31 02:10:00'];
yield ['2018-12-31 00:00:00', '2018-12-31 02:09:59', '01:00', 7740, '2018-12-31 02:09:00'];
// if seconds are given, they are first rounded up (default for duration rounding is 1)
yield ['2018-12-31 00:00:00', null, '01:00', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '01:00:10', 3660, '2018-12-31 01:01:00'];
yield ['2018-12-31 00:00:00', null, '1h', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '1h10m', 4200, '2018-12-31 01:10:00'];
yield ['2018-12-31 00:00:00', null, '1h10s', 3660, '2018-12-31 01:01:00'];
yield ['2018-12-31 00:00:00', null, '60m', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '60M1s', 3660, '2018-12-31 01:01:00'];
yield ['2018-12-31 00:00:00', null, '3600s', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '59m60s', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '1', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '1,0', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '1.0', 3600, '2018-12-31 01:00:00'];
yield ['2018-12-31 00:00:00', null, '1.5', 5400, '2018-12-31 01:30:00'];
yield ['2018-12-31 00:00:00', null, '1,25', 4500, '2018-12-31 01:15:00'];
}
public function testCreateActionShowsMetaFields()
{
$client = $this->getClientForAuthenticatedUser();