copy timesheet meta fields on restart record (#1030)
This commit is contained in:
@@ -409,8 +409,6 @@ class TimesheetController extends BaseApiController
|
||||
* required=true,
|
||||
* )
|
||||
*
|
||||
* @Security("is_granted('delete_own_timesheet') or is_granted('delete_other_timesheet')")
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
@@ -523,8 +521,6 @@ class TimesheetController extends BaseApiController
|
||||
* required=true,
|
||||
* )
|
||||
*
|
||||
* @Security("is_granted('stop_own_timesheet') or is_granted('stop_other_timesheet')")
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
* @throws \App\Repository\RepositoryException
|
||||
@@ -568,9 +564,7 @@ class TimesheetController extends BaseApiController
|
||||
* required=true,
|
||||
* )
|
||||
*
|
||||
* @Rest\RequestParam(name="copy", requirements="all|tags|description", strict=true, nullable=true, description="Whether description and tags are copied to the new entry. Allowed values: all, tags, description (default: nothing is copied)")
|
||||
*
|
||||
* @Security("is_granted('start_own_timesheet') or is_granted('start_other_timesheet')")
|
||||
* @Rest\RequestParam(name="copy", requirements="all|tags|description", strict=true, nullable=true, description="Whether description and tags are copied to the new entry. Allowed values: all, tags, description, meta (default: nothing is copied)")
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
@@ -582,8 +576,6 @@ class TimesheetController extends BaseApiController
|
||||
{
|
||||
/** @var Timesheet $timesheet */
|
||||
$timesheet = $this->repository->find($id);
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
if (null === $timesheet) {
|
||||
throw new NotFoundException();
|
||||
@@ -593,6 +585,9 @@ class TimesheetController extends BaseApiController
|
||||
throw new AccessDeniedHttpException('You are not allowed to re-start this timesheet');
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
$entry = new Timesheet();
|
||||
$entry
|
||||
->setBegin($this->dateTime->createDateTime())
|
||||
@@ -611,6 +606,13 @@ class TimesheetController extends BaseApiController
|
||||
$entry->addTag($tag);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($copy, ['meta', 'all'])) {
|
||||
foreach ($timesheet->getMetaFields() as $metaField) {
|
||||
$metaNew = clone $metaField;
|
||||
$entry->setMetaField($metaNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$errors = $validator->validate($entry);
|
||||
@@ -650,8 +652,6 @@ class TimesheetController extends BaseApiController
|
||||
* required=true,
|
||||
* )
|
||||
*
|
||||
* @Security("is_granted('edit_export_own_timesheet') or is_granted('edit_export_other_timesheet')")
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user