API: allow to set user for timesheet (#1259)
This commit is contained in:
@@ -307,12 +307,13 @@ class TimesheetController extends BaseApiController
|
|||||||
$form = $this->createForm(TimesheetApiEditForm::class, $timesheet, [
|
$form = $this->createForm(TimesheetApiEditForm::class, $timesheet, [
|
||||||
'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_user' => $this->isGranted('create_other_timesheet'),
|
||||||
'allow_begin_datetime' => $mode->canUpdateTimesWithAPI(),
|
'allow_begin_datetime' => $mode->canUpdateTimesWithAPI(),
|
||||||
'allow_end_datetime' => $mode->canUpdateTimesWithAPI(),
|
'allow_end_datetime' => $mode->canUpdateTimesWithAPI(),
|
||||||
'date_format' => self::DATE_FORMAT,
|
'date_format' => self::DATE_FORMAT,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$form->submit($request->request->all());
|
$form->submit($request->request->all(), false);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
if (null === $timesheet->getEnd()) {
|
if (null === $timesheet->getEnd()) {
|
||||||
@@ -387,6 +388,7 @@ class TimesheetController extends BaseApiController
|
|||||||
$form = $this->createForm(TimesheetApiEditForm::class, $timesheet, [
|
$form = $this->createForm(TimesheetApiEditForm::class, $timesheet, [
|
||||||
'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_user' => $this->isGranted('edit', $timesheet),
|
||||||
'allow_begin_datetime' => $mode->canUpdateTimesWithAPI(),
|
'allow_begin_datetime' => $mode->canUpdateTimesWithAPI(),
|
||||||
'allow_end_datetime' => $mode->canUpdateTimesWithAPI(),
|
'allow_end_datetime' => $mode->canUpdateTimesWithAPI(),
|
||||||
'date_format' => self::DATE_FORMAT,
|
'date_format' => self::DATE_FORMAT,
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ class TimesheetApiEditForm extends TimesheetEditForm
|
|||||||
parent::buildForm($builder, $options);
|
parent::buildForm($builder, $options);
|
||||||
|
|
||||||
$builder->remove('metaFields');
|
$builder->remove('metaFields');
|
||||||
|
|
||||||
|
if ($builder->has('user')) {
|
||||||
|
$builder->get('user')->setRequired(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ class TimesheetEditForm extends AbstractType
|
|||||||
'group_by' => null,
|
'group_by' => null,
|
||||||
'query_builder' => function (ProjectRepository $repo) use ($builder, $project, $customer, $isNew) {
|
'query_builder' => function (ProjectRepository $repo) use ($builder, $project, $customer, $isNew) {
|
||||||
// is there a better wa to prevent starting a record with a hidden project ?
|
// is there a better wa to prevent starting a record with a hidden project ?
|
||||||
if ($isNew && !is_object($project)) {
|
if ($isNew && !empty($project) && (is_int($project) || is_string($project))) {
|
||||||
/** @var Project $project */
|
/** @var Project $project */
|
||||||
$project = $repo->find($project);
|
$project = $repo->find($project);
|
||||||
if (null !== $project) {
|
if (null !== $project) {
|
||||||
|
|||||||
Reference in New Issue
Block a user