added project detail report (#2651)
- avatars via css only - random colors for entities - improves print view - added colors for teams - added color to tag
This commit is contained in:
@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ActivityTeamPermissionForm extends AbstractType
|
||||
{
|
||||
use EntityFormTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
51
src/Form/ColorTrait.php
Normal file
51
src/Form/ColorTrait.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
|
||||
use App\Form\Type\ColorChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
|
||||
trait ColorTrait
|
||||
{
|
||||
protected function addColor(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder
|
||||
->add('color', ColorChoiceType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
// this code exists only for backward compatibility
|
||||
$builder->addEventListener(
|
||||
FormEvents::PRE_SET_DATA,
|
||||
function (FormEvent $event) {
|
||||
if (!$event->getForm()->getConfig()->hasOption('choices')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $event->getData();
|
||||
$choices = $event->getForm()->getConfig()->getOption('choices');
|
||||
if (\is_object($data) && method_exists($data, 'getColor')) {
|
||||
$color = $data->getColor();
|
||||
if (!empty($color) && array_search($color, $choices) === false) {
|
||||
$choices[$color] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
$event->getForm()->add('color', ColorChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => $choices,
|
||||
]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CustomerTeamPermissionForm extends AbstractType
|
||||
{
|
||||
use EntityFormTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -9,18 +9,17 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\Type\ColorChoiceType;
|
||||
use App\Form\Type\DurationType;
|
||||
use App\Form\Type\MetaFieldsCollectionType;
|
||||
use App\Form\Type\YesNoType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
|
||||
trait EntityFormTrait
|
||||
{
|
||||
use ColorTrait;
|
||||
|
||||
public function addCommonFields(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$this->addColor($builder);
|
||||
@@ -50,39 +49,10 @@ trait EntityFormTrait
|
||||
]);
|
||||
}
|
||||
|
||||
public function addColor(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder
|
||||
->add('color', ColorChoiceType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
// this code exists only for backward compatibility
|
||||
$builder->addEventListener(
|
||||
FormEvents::PRE_SET_DATA,
|
||||
function (FormEvent $event) use ($builder) {
|
||||
if (!$builder->get('color')->hasOption('choices')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $event->getData();
|
||||
$choices = $builder->get('color')->getOption('choices');
|
||||
if (\is_object($data) && method_exists($data, 'getColor')) {
|
||||
$color = $data->getColor();
|
||||
if (!empty($color) && array_search($color, $choices) === false) {
|
||||
$choices[$color] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
$event->getForm()->add('color', ColorChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => $choices,
|
||||
]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.15
|
||||
* @param FormBuilderInterface $builder
|
||||
*/
|
||||
public function addCreateMore(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder->add('create_more', CheckboxType::class, [
|
||||
|
||||
@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ProjectTeamPermissionForm extends AbstractType
|
||||
{
|
||||
use EntityFormTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Tag;
|
||||
use App\Form\Type\ColorPickerType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -18,6 +17,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TagEditForm extends AbstractType
|
||||
{
|
||||
use ColorTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -34,7 +35,8 @@ class TagEditForm extends AbstractType
|
||||
'description' => 'The tag name (forbidden character: comma)',
|
||||
],
|
||||
])
|
||||
->add('color', ColorPickerType::class);
|
||||
;
|
||||
$this->addColor($builder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TeamEditForm extends AbstractType
|
||||
{
|
||||
use ColorTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -37,7 +39,9 @@ class TeamEditForm extends AbstractType
|
||||
'type' => 'string',
|
||||
'description' => 'Name of the team',
|
||||
],
|
||||
])
|
||||
]);
|
||||
$this->addColor($builder);
|
||||
$builder
|
||||
->add('teamlead', UserType::class, [
|
||||
'label' => 'label.teamlead',
|
||||
'multiple' => false,
|
||||
|
||||
@@ -67,6 +67,7 @@ class ProjectType extends AbstractType
|
||||
'activity_select' => 'activity',
|
||||
'activity_visibility' => ActivityQuery::SHOW_VISIBLE,
|
||||
'ignore_date' => false,
|
||||
'join_customer' => false,
|
||||
]);
|
||||
|
||||
$resolver->setDefault('query_builder', function (Options $options) {
|
||||
@@ -78,6 +79,9 @@ class ProjectType extends AbstractType
|
||||
if (true === $options['ignore_date']) {
|
||||
$query->setIgnoreDate(true);
|
||||
}
|
||||
if (true === $options['join_customer']) {
|
||||
$query->setWithCustomer(true);
|
||||
}
|
||||
|
||||
return $repo->getQueryBuilderForFormType($query);
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\AvatarType;
|
||||
use App\Form\Type\LanguageType;
|
||||
@@ -25,6 +26,15 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
*/
|
||||
class UserEditType extends AbstractType
|
||||
{
|
||||
use ColorTrait;
|
||||
|
||||
private $configuration;
|
||||
|
||||
public function __construct(SystemConfiguration $configuration)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -39,9 +49,17 @@ class UserEditType extends AbstractType
|
||||
'label' => 'label.title',
|
||||
'required' => false,
|
||||
])
|
||||
->add('avatar', AvatarType::class, [
|
||||
;
|
||||
|
||||
if ($this->configuration->isThemeAllowAvatarUrls()) {
|
||||
$builder->add('avatar', AvatarType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
$this->addColor($builder);
|
||||
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'label.email',
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user