added punch-in punch-out / time-clock mode (#812)

This commit is contained in:
Kevin Papst
2019-05-27 01:36:43 +02:00
committed by GitHub
parent ebff4a765a
commit d9dca96a32
20 changed files with 231 additions and 113 deletions

View File

@@ -8,5 +8,5 @@ A clear and concise description of what this pull request adds or changes.
## Checklist ## Checklist
- [ ] I verified that my code applies to the guidelines (`composer code-check`) - [ ] I verified that my code applies to the guidelines (`composer code-check`)
- [ ] I updated the documentation accordingly (see [here](https://github.com/kimai/www.kimai.org/tree/master/_documentation)) - [ ] I updated the documentation (see [here](https://github.com/kimai/www.kimai.org/tree/master/_documentation))
- [ ] I agree that this code is used in Kimai and will be published under the [MIT license](https://github.com/kevinpapst/kimai2/blob/master/LICENSE) - [ ] I agree that this code is used in Kimai and will be published under the [MIT license](https://github.com/kevinpapst/kimai2/blob/master/LICENSE)

View File

@@ -34,16 +34,26 @@ export default class KimaiAjaxModalForm extends KimaiClickHandlerReducedInTableR
}); });
} }
openUrlInModal(url) { openUrlInModal(url, errorHandler) {
const self = this; const self = this;
if (errorHandler === undefined) {
errorHandler = function(xhr, err) {
if (xhr.status !== undefined && xhr.status === 403) {
const alert = self.getContainer().getPlugin('alert');
alert.error(xhr.statusText);
return;
}
window.location = url;
};
}
jQuery.ajax({ jQuery.ajax({
url: url, url: url,
success: function(html) { success: function(html) {
self._openFormInModal(html); self._openFormInModal(html);
}, },
error: function(xhr, err) { error: errorHandler
window.location = url;
}
}); });
} }

View File

@@ -10,7 +10,7 @@ kimai:
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
# AUTHENTICATION # AUTHENTICATION
# You can disable some user management functions in the authentication screens. # You can disable some user management functions in the authentication screens.
# Both settings default to "true" # Both settings default to "true", see https://www.kimai.org/documentation/users.html
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
# user: # user:
# registration: false # registration: false

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{ {
"build/app.js": "./app.js?7f61ab551431df41b451", "build/app.js": "./app.js?1a3cad2c36a19bafdfb6",
"build/app.css": "./app.css?954c34ace3717cfb9d9c80d2be5f8c68", "build/app.css": "./app.css?954c34ace3717cfb9d9c80d2be5f8c68",
"build/fonts/fa-solid-900.woff2": "./fonts/fa-solid-900.woff2?e8a92a29", "build/fonts/fa-solid-900.woff2": "./fonts/fa-solid-900.woff2?e8a92a29",
"build/images/fa-solid-900.svg": "./images/fa-solid-900.svg?666a82cb", "build/images/fa-solid-900.svg": "./images/fa-solid-900.svg?666a82cb",

View File

@@ -275,6 +275,7 @@ class TimesheetController extends BaseApiController
'csrf_protection' => false, 'csrf_protection' => false,
'include_rate' => $this->isGranted('edit_rate', $timesheet), 'include_rate' => $this->isGranted('edit_rate', $timesheet),
'include_exported' => $this->isGranted('edit_export', $timesheet), 'include_exported' => $this->isGranted('edit_export', $timesheet),
'include_datetime' => !$this->configuration->isPunchInOut(),
'date_format' => self::DATE_FORMAT, 'date_format' => self::DATE_FORMAT,
]); ]);
@@ -352,6 +353,7 @@ class TimesheetController extends BaseApiController
'csrf_protection' => false, 'csrf_protection' => false,
'include_rate' => $this->isGranted('edit_rate', $timesheet), 'include_rate' => $this->isGranted('edit_rate', $timesheet),
'include_exported' => $this->isGranted('edit_export', $timesheet), 'include_exported' => $this->isGranted('edit_export', $timesheet),
'include_datetime' => !$this->configuration->isPunchInOut(),
'date_format' => self::DATE_FORMAT, 'date_format' => self::DATE_FORMAT,
]); ]);

View File

@@ -13,6 +13,7 @@ class TimesheetConfiguration implements SystemBundleConfiguration
{ {
public const MODE_DURATION_ONLY = 'duration_only'; public const MODE_DURATION_ONLY = 'duration_only';
public const MODE_DEFAULT = 'default'; public const MODE_DEFAULT = 'default';
public const MODE_PUNCH_IN_OUT = 'punch';
use StringAccessibleConfigTrait; use StringAccessibleConfigTrait;
@@ -31,6 +32,11 @@ class TimesheetConfiguration implements SystemBundleConfiguration
return $this->find('mode') === self::MODE_DURATION_ONLY; return $this->find('mode') === self::MODE_DURATION_ONLY;
} }
public function isPunchInOut(): bool
{
return $this->find('mode') === self::MODE_PUNCH_IN_OUT;
}
public function isMarkdownEnabled(): bool public function isMarkdownEnabled(): bool
{ {
return (bool) $this->find('markdown_content'); return (bool) $this->find('markdown_content');

View File

@@ -146,44 +146,7 @@ abstract class TimesheetAbstractController extends AbstractController
$entry->setUser($this->getUser()); $entry->setUser($this->getUser());
$entry->setBegin($this->dateTime->createDateTime()); $entry->setBegin($this->dateTime->createDateTime());
$start = $request->get('begin'); $this->setBeginEndFromRequest($request, $entry);
if ($start !== null) {
$start = $this->dateTime->createDateTimeFromFormat('Y-m-d', $start);
if ($start !== false) {
$entry->setBegin($start);
// only check for an end date if a begin date was given
$end = $request->get('end');
if ($end !== null) {
$end = $this->dateTime->createDateTimeFromFormat('Y-m-d', $end);
if ($end !== false) {
$start->setTime(10, 0, 0);
$end->setTime(18, 0, 0);
$entry->setEnd($end);
$entry->setDuration($end->getTimestamp() - $start->getTimestamp());
}
}
}
}
$from = $request->get('from');
if ($from !== null) {
$from = $this->dateTime->createDateTime($from);
if ($from !== false) {
$entry->setBegin($from);
// only check for an end datetime if a begin datetime was given
$to = $request->get('to');
if ($to !== null) {
$to = $this->dateTime->createDateTime($to);
if ($to !== false) {
$entry->setEnd($to);
$entry->setDuration($to->getTimestamp() - $from->getTimestamp());
}
}
}
}
if ($request->query->get('project')) { if ($request->query->get('project')) {
$project = $projectRepository->find($request->query->get('project')); $project = $projectRepository->find($request->query->get('project'));
@@ -225,6 +188,52 @@ abstract class TimesheetAbstractController extends AbstractController
]); ]);
} }
protected function setBeginEndFromRequest(Request $request, Timesheet $entry)
{
if ($this->configuration->isPunchInOut()) {
return;
}
$start = $request->get('begin');
if ($start !== null) {
$start = $this->dateTime->createDateTimeFromFormat('Y-m-d', $start);
if ($start !== false) {
$entry->setBegin($start);
// only check for an end date if a begin date was given
$end = $request->get('end');
if ($end !== null) {
$end = $this->dateTime->createDateTimeFromFormat('Y-m-d', $end);
if ($end !== false) {
$start->setTime(10, 0, 0);
$end->setTime(18, 0, 0);
$entry->setEnd($end);
$entry->setDuration($end->getTimestamp() - $start->getTimestamp());
}
}
}
}
$from = $request->get('from');
if ($from !== null) {
$from = $this->dateTime->createDateTime($from);
if ($from !== false) {
$entry->setBegin($from);
// only check for an end datetime if a begin datetime was given
$to = $request->get('to');
if ($to !== null) {
$to = $this->dateTime->createDateTime($to);
if ($to !== false) {
$entry->setEnd($to);
$entry->setDuration($to->getTimestamp() - $from->getTimestamp());
}
}
}
}
}
/** /**
* @param Request $request * @param Request $request
* @param string $renderTemplate * @param string $renderTemplate
@@ -274,10 +283,13 @@ abstract class TimesheetAbstractController extends AbstractController
*/ */
protected function getCreateForm(Timesheet $entry) protected function getCreateForm(Timesheet $entry)
{ {
return $this->createForm(TimesheetEditForm::class, $entry, [ return $this->createForm($this->getCreateFormClassName(), $entry, [
'action' => $this->generateUrl($this->getCreateRoute()), 'action' => $this->generateUrl($this->getCreateRoute()),
'include_rate' => $this->isGranted('edit_rate', $entry), 'include_rate' => $this->isGranted('edit_rate', $entry),
'include_exported' => $this->isGranted('edit_export', $entry),
'include_user' => $this->includeUserInForms(), 'include_user' => $this->includeUserInForms(),
'use_duration' => $this->configuration->isDurationOnly(),
'include_datetime' => !$this->configuration->isPunchInOut(),
'customer' => true, 'customer' => true,
]); ]);
} }
@@ -289,7 +301,7 @@ abstract class TimesheetAbstractController extends AbstractController
*/ */
protected function getEditForm(Timesheet $entry, $page) protected function getEditForm(Timesheet $entry, $page)
{ {
return $this->createForm(TimesheetEditForm::class, $entry, [ return $this->createForm($this->getEditFormClassName(), $entry, [
'action' => $this->generateUrl($this->getEditRoute(), [ 'action' => $this->generateUrl($this->getEditRoute(), [
'id' => $entry->getId(), 'id' => $entry->getId(),
'page' => $page, 'page' => $page,
@@ -297,6 +309,8 @@ abstract class TimesheetAbstractController extends AbstractController
'include_rate' => $this->isGranted('edit_rate', $entry), 'include_rate' => $this->isGranted('edit_rate', $entry),
'include_exported' => $this->isGranted('edit_export', $entry), 'include_exported' => $this->isGranted('edit_export', $entry),
'include_user' => $this->includeUserInForms(), 'include_user' => $this->includeUserInForms(),
'include_datetime' => !$this->configuration->isPunchInOut(),
'use_duration' => $this->configuration->isDurationOnly(),
'customer' => true, 'customer' => true,
]); ]);
} }
@@ -316,6 +330,16 @@ abstract class TimesheetAbstractController extends AbstractController
]); ]);
} }
protected function getCreateFormClassName()
{
return TimesheetEditForm::class;
}
protected function getEditFormClassName()
{
return TimesheetEditForm::class;
}
protected function includeSummary(): bool protected function includeSummary(): bool
{ {
return (bool) $this->getUser()->getPreferenceValue('timesheet.daily_stats', false); return (bool) $this->getUser()->getPreferenceValue('timesheet.daily_stats', false);

View File

@@ -10,6 +10,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Timesheet; use App\Entity\Timesheet;
use App\Form\TimesheetAdminEditForm;
use App\Repository\ActivityRepository; use App\Repository\ActivityRepository;
use App\Repository\ProjectRepository; use App\Repository\ProjectRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -74,6 +75,16 @@ class TimesheetTeamController extends TimesheetAbstractController
return $this->create($request, 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository); return $this->create($request, 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository);
} }
protected function getCreateFormClassName()
{
return TimesheetAdminEditForm::class;
}
protected function getEditFormClassName()
{
return TimesheetAdminEditForm::class;
}
protected function includeUserInForms(): bool protected function includeUserInForms(): bool
{ {
return true; return true;

View File

@@ -80,9 +80,9 @@ class Configuration implements ConfigurationInterface
->defaultValue('default') ->defaultValue('default')
->validate() ->validate()
->ifTrue(function ($value) { ->ifTrue(function ($value) {
return !in_array($value, ['default', 'duration_only']); return !in_array($value, ['default', 'duration_only', 'punch']);
}) })
->thenInvalid('Chosen timesheet mode is invalid, allowed values: default, duration_only') ->thenInvalid('Chosen timesheet mode is invalid, allowed values: default, duration_only, punch')
->end() ->end()
->end() ->end()
->booleanNode('markdown_content') ->booleanNode('markdown_content')

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Form;
class TimesheetAdminEditForm extends TimesheetEditForm
{
protected function showTimeFields(array $options): bool
{
return true;
}
protected function showCustomer(array $options, bool $isNew, int $customerCount): bool
{
return true;
}
}

View File

@@ -9,7 +9,6 @@
namespace App\Form; namespace App\Form;
use App\Configuration\TimesheetConfiguration;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Customer; use App\Entity\Customer;
use App\Entity\Project; use App\Entity\Project;
@@ -52,23 +51,17 @@ class TimesheetEditForm extends AbstractType
* @var UserDateTimeFactory * @var UserDateTimeFactory
*/ */
protected $dateTime; protected $dateTime;
/**
* @var TimesheetConfiguration
*/
private $configuration;
/** /**
* @param CustomerRepository $customer * @param CustomerRepository $customer
* @param ProjectRepository $project * @param ProjectRepository $project
* @param UserDateTimeFactory $dateTime * @param UserDateTimeFactory $dateTime
* @param TimesheetConfiguration $config
*/ */
public function __construct(CustomerRepository $customer, ProjectRepository $project, UserDateTimeFactory $dateTime, TimesheetConfiguration $config) public function __construct(CustomerRepository $customer, ProjectRepository $project, UserDateTimeFactory $dateTime)
{ {
$this->customers = $customer; $this->customers = $customer;
$this->projects = $project; $this->projects = $project;
$this->dateTime = $dateTime; $this->dateTime = $dateTime;
$this->configuration = $config;
} }
/** /**
@@ -80,10 +73,10 @@ class TimesheetEditForm extends AbstractType
$project = null; $project = null;
$customer = null; $customer = null;
$currency = false; $currency = false;
$end = null;
$begin = null; $begin = null;
$customerCount = $this->customers->countCustomer(true); $customerCount = $this->customers->countCustomer(true);
$projectCount = $this->projects->countProject(true); $projectCount = $this->projects->countProject(true);
$timezone = $this->dateTime->getTimezone()->getName();
$isNew = true; $isNew = true;
if (isset($options['data'])) { if (isset($options['data'])) {
@@ -106,15 +99,10 @@ class TimesheetEditForm extends AbstractType
$currency = $customer->getCurrency(); $currency = $customer->getCurrency();
} }
$begin = $entry->getBegin(); if (null !== ($begin = $entry->getBegin())) {
$end = $entry->getEnd();
}
$timezone = $this->dateTime->getTimezone()->getName();
if (null !== $begin) {
$timezone = $begin->getTimezone()->getName(); $timezone = $begin->getTimezone()->getName();
} }
}
$dateTimeOptions = [ $dateTimeOptions = [
'model_timezone' => $timezone, 'model_timezone' => $timezone,
@@ -126,44 +114,49 @@ class TimesheetEditForm extends AbstractType
$dateTimeOptions['format'] = $options['date_format']; $dateTimeOptions['format'] = $options['date_format'];
} }
if ($isNew || null === $end || !$this->configuration->isDurationOnly()) { if ($this->showTimeFields($options)) {
$this->addBegin($builder, $dateTimeOptions); $this->addBegin($builder, $dateTimeOptions);
}
if ($this->configuration->isDurationOnly()) { if ($options['use_duration']) {
$this->addDuration($builder); $this->addDuration($builder);
} else { } else {
$this->addEnd($builder, $dateTimeOptions); $this->addEnd($builder, $dateTimeOptions);
} }
}
$projectOptions = []; if ($this->showCustomer($options, $isNew, $customerCount)) {
if ($customerCount < 2) {
$projectOptions['group_by'] = null;
} elseif ($options['customer']) {
$this->addCustomer($builder, $customer); $this->addCustomer($builder, $customer);
} }
if ($projectCount <= 1) { $this->addProject($builder, $customerCount, $projectCount, $project, $customer);
$projectOptions['group_by'] = null;
}
$this->addProject($builder, $projectOptions, $project, $customer);
$this->addActivity($builder, $activity, $project); $this->addActivity($builder, $activity, $project);
$this->addDescription($builder); $this->addDescription($builder);
$this->addTags($builder); $this->addTags($builder);
$this->addRates($builder, $currency, $options);
if ($options['include_rate']) { $this->addUser($builder, $options);
$this->addRates($builder, $currency); $this->addExported($builder, $options);
} }
if ($options['include_user']) { protected function showCustomer(array $options, bool $isNew, int $customerCount): bool
$this->addUser($builder); {
if (!$isNew && $options['customer']) {
return true;
} }
if ($options['include_exported']) { if ($customerCount < 2) {
$this->addExported($builder); return false;
} }
if (!$options['customer']) {
return false;
}
return true;
}
protected function showTimeFields(array $options): bool
{
return $options['include_datetime'];
} }
protected function addCustomer(FormBuilderInterface $builder, ?Customer $customer = null) protected function addCustomer(FormBuilderInterface $builder, ?Customer $customer = null)
@@ -181,8 +174,18 @@ class TimesheetEditForm extends AbstractType
]); ]);
} }
protected function addProject(FormBuilderInterface $builder, array $projectOptions, ?Project $project = null, ?Customer $customer = null) protected function addProject(FormBuilderInterface $builder, int $customerCount, int $projectCount, ?Project $project = null, ?Customer $customer = null)
{ {
$projectOptions = [];
if ($customerCount < 2) {
$projectOptions['group_by'] = null;
}
if ($projectCount < 2) {
$projectOptions['group_by'] = null;
}
$builder $builder
->add( ->add(
'project', 'project',
@@ -322,8 +325,12 @@ class TimesheetEditForm extends AbstractType
]); ]);
} }
protected function addRates(FormBuilderInterface $builder, $currency) protected function addRates(FormBuilderInterface $builder, $currency, array $options)
{ {
if (!$options['include_rate']) {
return;
}
$builder $builder
->add('fixedRate', FixedRateType::class, [ ->add('fixedRate', FixedRateType::class, [
'currency' => $currency, 'currency' => $currency,
@@ -333,13 +340,21 @@ class TimesheetEditForm extends AbstractType
]); ]);
} }
protected function addUser(FormBuilderInterface $builder) protected function addUser(FormBuilderInterface $builder, array $options)
{ {
if (!$options['include_user']) {
return;
}
$builder->add('user', UserType::class); $builder->add('user', UserType::class);
} }
protected function addExported(FormBuilderInterface $builder) protected function addExported(FormBuilderInterface $builder, array $options)
{ {
if (!$options['include_exported']) {
return;
}
$builder->add('exported', YesNoType::class, [ $builder->add('exported', YesNoType::class, [
'label' => 'label.exported' 'label' => 'label.exported'
]); ]);
@@ -362,6 +377,8 @@ class TimesheetEditForm extends AbstractType
'method' => 'POST', 'method' => 'POST',
'date_format' => null, 'date_format' => null,
'customer' => false, // for API usage 'customer' => false, // for API usage
'use_duration' => false, // duration instead of end (for duration_only mode)
'include_datetime' => true,
'attr' => [ 'attr' => [
'data-form-event' => 'kimai.timesheetUpdate', 'data-form-event' => 'kimai.timesheetUpdate',
'data-msg-success' => 'action.update.success', 'data-msg-success' => 'action.update.success',

View File

@@ -28,6 +28,7 @@ class TimesheetModeType extends AbstractType
'label' => 'label.timesheet.mode', 'label' => 'label.timesheet.mode',
'choices' => [ 'choices' => [
'label.timesheet.mode_default' => TimesheetConfiguration::MODE_DEFAULT, 'label.timesheet.mode_default' => TimesheetConfiguration::MODE_DEFAULT,
'label.timesheet.mode_punch' => TimesheetConfiguration::MODE_PUNCH_IN_OUT,
'label.timesheet.mode_duration_only' => TimesheetConfiguration::MODE_DURATION_ONLY, 'label.timesheet.mode_duration_only' => TimesheetConfiguration::MODE_DURATION_ONLY,
], ],
]); ]);

View File

@@ -32,6 +32,7 @@ class TimesheetConfigExtension extends AbstractExtension
{ {
return [ return [
new TwigFunction('is_duration_only', [$this, 'isDurationOnly']), new TwigFunction('is_duration_only', [$this, 'isDurationOnly']),
new TwigFunction('is_punch_mode', [$this, 'isPunchInOut']),
]; ];
} }
@@ -39,4 +40,9 @@ class TimesheetConfigExtension extends AbstractExtension
{ {
return $this->configuration->isDurationOnly(); return $this->configuration->isDurationOnly();
} }
public function isPunchInOut(): bool
{
return $this->configuration->isPunchInOut();
}
} }

View File

@@ -153,11 +153,11 @@
html: true html: true
}); });
}, },
{% if is_granted('create_own_timesheet') %} {% if not is_punch_mode() and is_granted('create_own_timesheet') %}
dayClick: function(date, jsEvent, view) {
// day-clicks are always triggered, unless a selection was created // day-clicks are always triggered, unless a selection was created
// so clicking in a day (month view) or any slot (week and day view) will trigger a dayClick // so clicking in a day (month view) or any slot (week and day view) will trigger a dayClick
// BEFORE triggering a select - make sure not two create dialogs are requested // BEFORE triggering a select - make sure not two create dialogs are requested
dayClick: function(date, jsEvent, view) {
if(view.type !== 'month') { if(view.type !== 'month') {
return; return;
} }
@@ -187,6 +187,7 @@
var editUrl = '{{ path('timesheet_edit', {id: '-XX-'}) }}'.replace('-XX-', eventObj.id); var editUrl = '{{ path('timesheet_edit', {id: '-XX-'}) }}'.replace('-XX-', eventObj.id);
kimai.getPlugin('modal').openUrlInModal(editUrl); kimai.getPlugin('modal').openUrlInModal(editUrl);
}, },
{% if not is_punch_mode() %}
editable: true, editable: true,
eventDragStart: function(event, jsEvent, ui, view) { eventDragStart: function(event, jsEvent, ui, view) {
window.hidePopover = true; window.hidePopover = true;
@@ -203,6 +204,7 @@
}, },
eventResize: changeHandler, eventResize: changeHandler,
{% endif %} {% endif %}
{% endif %}
/* /*
slotDuration: '00:30:00', // TODO make me configurable slotDuration: '00:30:00', // TODO make me configurable
*/ */

View File

@@ -120,9 +120,9 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$this->request($client, '/team/timesheet/create'); $this->request($client, '/team/timesheet/create');
$this->assertTrue($client->getResponse()->isSuccessful()); $this->assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form(); $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();
$client->submit($form, [ $client->submit($form, [
'timesheet_edit_form' => [ 'timesheet_admin_edit_form' => [
'description' => 'Testing is fun!', 'description' => 'Testing is fun!',
'project' => 1, 'project' => 1,
'activity' => 1, 'activity' => 1,
@@ -170,9 +170,9 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
'Could not find link to documentation' 'Could not find link to documentation'
); );
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form(); $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();
$client->submit($form, [ $client->submit($form, [
'timesheet_edit_form' => [ 'timesheet_admin_edit_form' => [
'description' => 'foo-bar', 'description' => 'foo-bar',
'tags' => 'foo,bar, testing, hello world,,', 'tags' => 'foo,bar, testing, hello world,,',
'user' => $teamlead->getId() 'user' => $teamlead->getId()

View File

@@ -25,8 +25,9 @@ class TimesheetConfigExtensionTest extends TestCase
$config = new TimesheetConfiguration($loader, ['mode' => 'duration_only']); $config = new TimesheetConfiguration($loader, ['mode' => 'duration_only']);
$sut = new TimesheetConfigExtension($config); $sut = new TimesheetConfigExtension($config);
$filters = $sut->getFunctions(); $filters = $sut->getFunctions();
$this->assertCount(1, $filters); $this->assertCount(2, $filters);
$this->assertEquals('is_duration_only', $filters[0]->getName()); $this->assertEquals('is_duration_only', $filters[0]->getName());
$this->assertEquals('is_punch_mode', $filters[1]->getName());
} }
public function testIsDurationOnly() public function testIsDurationOnly()
@@ -35,6 +36,7 @@ class TimesheetConfigExtensionTest extends TestCase
$config = new TimesheetConfiguration($loader, ['mode' => 'duration_only']); $config = new TimesheetConfiguration($loader, ['mode' => 'duration_only']);
$sut = new TimesheetConfigExtension($config); $sut = new TimesheetConfigExtension($config);
$this->assertTrue($sut->isDurationOnly()); $this->assertTrue($sut->isDurationOnly());
$this->assertFalse($sut->isPunchInOut());
} }
public function testIsNotDurationOnly() public function testIsNotDurationOnly()
@@ -43,5 +45,15 @@ class TimesheetConfigExtensionTest extends TestCase
$config = new TimesheetConfiguration($loader, ['mode' => 'default']); $config = new TimesheetConfiguration($loader, ['mode' => 'default']);
$sut = new TimesheetConfigExtension($config); $sut = new TimesheetConfigExtension($config);
$this->assertFalse($sut->isDurationOnly()); $this->assertFalse($sut->isDurationOnly());
$this->assertFalse($sut->isPunchInOut());
}
public function testIsPunchInOut()
{
$loader = $this->getMockBuilder(ConfigLoaderInterface::class)->getMock();
$config = new TimesheetConfiguration($loader, ['mode' => 'punch']);
$sut = new TimesheetConfigExtension($config);
$this->assertFalse($sut->isDurationOnly());
$this->assertTrue($sut->isPunchInOut());
} }
} }

View File

@@ -628,10 +628,6 @@ För närvarande har %user% användare %records% tidsrekord som räknas upp till
<source>ROLE_USER</source> <source>ROLE_USER</source>
<target state="translated">Användare</target> <target state="translated">Användare</target>
</trans-unit> </trans-unit>
<trans-unit id="ROLE_CUSTOMER">
<source>ROLE_CUSTOMER</source>
<target state="translated">Kund</target>
</trans-unit>
<!-- <!--
Statistics data for Dashboard & Users profile Statistics data for Dashboard & Users profile

View File

@@ -36,11 +36,15 @@
</trans-unit> </trans-unit>
<trans-unit id="label.timesheet.mode_default"> <trans-unit id="label.timesheet.mode_default">
<source>label.timesheet.mode_default</source> <source>label.timesheet.mode_default</source>
<target>Standard Modus: erfasst Start und Enddatum</target> <target>[Standard] Start- und Endzeiten können bearbeitet werden</target>
</trans-unit> </trans-unit>
<trans-unit id="label.timesheet.mode_duration_only"> <trans-unit id="label.timesheet.mode_duration_only">
<source>label.timesheet.mode_duration_only</source> <source>label.timesheet.mode_duration_only</source>
<target>Dauer: ersetzt das Enddatum durch ein Eingabefeld für Dauer</target> <target>[Dauer] ersetzt die Endzeit durch ein Eingabefeld für Dauer</target>
</trans-unit>
<trans-unit id="label.timesheet.mode_punch">
<source>label.timesheet.mode_punch</source>
<target>[Stechuhr] Benutzer kann Aufzeichnungen starten und stoppen, aber weder Zeiten noch Dauer bearbeiten</target>
</trans-unit> </trans-unit>
<trans-unit id="label.timesheet.rules.allow_future_times"> <trans-unit id="label.timesheet.rules.allow_future_times">
<source>label.timesheet.rules.allow_future_times</source> <source>label.timesheet.rules.allow_future_times</source>

View File

@@ -36,11 +36,15 @@
</trans-unit> </trans-unit>
<trans-unit id="label.timesheet.mode_default"> <trans-unit id="label.timesheet.mode_default">
<source>label.timesheet.mode_default</source> <source>label.timesheet.mode_default</source>
<target>Default: accept start and end date</target> <target>[Default] start and end times can be edited</target>
</trans-unit> </trans-unit>
<trans-unit id="label.timesheet.mode_duration_only"> <trans-unit id="label.timesheet.mode_duration_only">
<source>label.timesheet.mode_duration_only</source> <source>label.timesheet.mode_duration_only</source>
<target>Duration only: replaces the end date field with an input for duration</target> <target>[Duration] replaces the end time with a duration input-field</target>
</trans-unit>
<trans-unit id="label.timesheet.mode_punch">
<source>label.timesheet.mode_punch</source>
<target>[Time-clock] user can start and stop records, but not edit the times or duration</target>
</trans-unit> </trans-unit>
<trans-unit id="label.timesheet.rules.allow_future_times"> <trans-unit id="label.timesheet.rules.allow_future_times">
<source>label.timesheet.rules.allow_future_times</source> <source>label.timesheet.rules.allow_future_times</source>