Project API and globalActivities flag (#3564)

* expose globalActivities setting in project entity
* fix globalActivities being true by default if created via API
This commit is contained in:
Kevin Papst
2022-10-01 18:14:22 +02:00
committed by GitHub
parent 6cfcbccabc
commit 1d445d9eb6
5 changed files with 82 additions and 0 deletions

View File

@@ -257,6 +257,9 @@ class Project implements EntityWithMetaFields, EntityWithBudget
*
* @var bool
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @ORM\Column(name="global_activities", type="boolean", nullable=false, options={"default": true})
* @Assert\NotNull()
*/

View File

@@ -10,6 +10,7 @@
namespace App\Form\API;
use App\Form\ProjectEditForm;
use App\Form\Type\APITrueFalseType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -23,6 +24,11 @@ class ProjectApiEditForm extends ProjectEditForm
parent::buildForm($builder, $options);
$builder->remove('metaFields');
$builder->remove('globalActivities');
$builder->add('globalActivities', APITrueFalseType::class, [
'label' => 'label.globalActivities',
'empty_data' => '1',
]);
}
/**

View File

@@ -0,0 +1,30 @@
<?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\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class APITrueFalseType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'false_values' => [0, '0', false],
'required' => false,
]);
}
public function getParent(): string
{
return CheckboxType::class;
}
}