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:
@@ -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()
|
||||
*/
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
30
src/Form/Type/APITrueFalseType.php
Normal file
30
src/Form/Type/APITrueFalseType.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user