Release 2.0.10 (#3927)
* allow API calls via GET * allow to stop timesheet via GET * improve form handling and validation * improve stop button handling * bump version
This commit is contained in:
@@ -106,6 +106,7 @@ final class TimesheetController extends BaseApiController
|
||||
if ('all' === $userId) {
|
||||
$query->setUser(null);
|
||||
} else {
|
||||
/** @var User|null $user */
|
||||
$user = $userRepository->find($userId);
|
||||
if ($user === null) {
|
||||
throw $this->createNotFoundException('Unknown user: ' . $userId);
|
||||
@@ -447,11 +448,15 @@ final class TimesheetController extends BaseApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops an active timesheet record
|
||||
* Stops an active timesheet record.
|
||||
*
|
||||
* This route is available via GET and PATCH, as users over and over again run into errors when stopping.
|
||||
* Likely caused by a slow JS engine and a fast-click after page reload.
|
||||
*/
|
||||
#[IsGranted('stop', 'timesheet')]
|
||||
#[OA\Response(response: 200, description: 'Stops an active timesheet record and returns it afterwards.', content: new OA\JsonContent(ref: '#/components/schemas/TimesheetEntity'))]
|
||||
#[OA\Parameter(name: 'id', in: 'path', description: 'Timesheet record ID to stop', required: true)]
|
||||
#[Rest\Get(path: '/{id}/stop', name: 'stop_timesheet_get', requirements: ['id' => '\d+'])]
|
||||
#[Rest\Patch(path: '/{id}/stop', name: 'stop_timesheet', requirements: ['id' => '\d+'])]
|
||||
#[ApiSecurity(name: 'apiUser')]
|
||||
#[ApiSecurity(name: 'apiToken')]
|
||||
|
||||
@@ -17,11 +17,11 @@ class Constants
|
||||
/**
|
||||
* The current release version
|
||||
*/
|
||||
public const VERSION = '2.0.9';
|
||||
public const VERSION = '2.0.10';
|
||||
/**
|
||||
* The current release: major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
public const VERSION_ID = 20009;
|
||||
public const VERSION_ID = 20010;
|
||||
/**
|
||||
* The software name
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,7 @@ final class TimesheetTeamController extends TimesheetAbstractController
|
||||
/** @var ArrayCollection<Team> $teams */
|
||||
$teams = $createForm->get('teams')->getData();
|
||||
|
||||
/** @var array<User> $allUsers */
|
||||
$allUsers = $users->toArray();
|
||||
/** @var Team $team */
|
||||
foreach ($teams as $team) {
|
||||
|
||||
@@ -337,11 +337,7 @@ class Timesheet implements EntityWithMetaFields, ExportableItem
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return Timesheet
|
||||
*/
|
||||
public function setUser(User $user): Timesheet
|
||||
public function setUser(?User $user): Timesheet
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
@@ -353,11 +349,7 @@ class Timesheet implements EntityWithMetaFields, ExportableItem
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Activity $activity
|
||||
* @return Timesheet
|
||||
*/
|
||||
public function setActivity($activity): Timesheet
|
||||
public function setActivity(?Activity $activity): Timesheet
|
||||
{
|
||||
$this->activity = $activity;
|
||||
|
||||
@@ -374,22 +366,14 @@ class Timesheet implements EntityWithMetaFields, ExportableItem
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Project $project
|
||||
* @return Timesheet
|
||||
*/
|
||||
public function setProject(Project $project): Timesheet
|
||||
public function setProject(?Project $project): Timesheet
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @return Timesheet
|
||||
*/
|
||||
public function setDescription($description): Timesheet
|
||||
public function setDescription(?string $description): Timesheet
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Model\QuickEntryModel;
|
||||
use App\Validator\Constraints\QuickEntryTimesheet;
|
||||
use DateTime;
|
||||
@@ -129,8 +130,12 @@ final class QuickEntryWeekType extends AbstractType
|
||||
return $transformValue;
|
||||
}
|
||||
|
||||
$user = $transformValue->getUser();
|
||||
if ($user === null && $options['user'] instanceof User) {
|
||||
$user = $options['user'];
|
||||
}
|
||||
foreach ($transformValue->getTimesheets() as $timesheet) {
|
||||
$timesheet->setUser($transformValue->getUser() ?? $options['user']);
|
||||
$timesheet->setUser($user);
|
||||
$timesheet->setProject($project);
|
||||
$timesheet->setActivity($activity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user